Home php教程 php手册 SP框架限制分页数字长度

SP框架限制分页数字长度

Jun 13, 2016 am 10:53 AM
app path require Entrance Pagination exist number document frame transfer length limit

在入口文件调用
require(SP_PATH . "/SpeedPHP.php");
require(APP_PATH . '/include/functions.php');
spRun();

functions.php
[php] 
spAddViewFunction('pager', '__template_pager'); 
 
function __template_pager($params) { 
    if (!isset($params['pager']) || emptyempty($params['pager'])) 
        return ''; 
    $args = array(); 
    foreach ($params as $k => $v) 
        if (!in_array($k, array('c', 'a', 'pager', 'myclass', 'mypage', 'offset'))) 
            $args[$k] = $v; 
    $pagerhandle = isset($params['pager']['mypage']) ? $params['pager']['mypage'] : 'page'; 
    $html = "

"; 
    if ($params['pager']['current_page'] != $params['pager']['first_page']) { 
        $url = spUrl($params['c'], $params['a'], $args + array($pagerhandle => $params['pager']['prev_page'])); 
        $html .= ""; 
    } else { 
        $html .= ""; 
    } 
    $offset = $params['offset'] ? $params['offset'] : 200; // 可以在内用offset=x来调整 
 
    foreach ($params['pager']['all_pages'] as $page) { 
        if ($page == $params['pager']['current_page']) { 
            $html .= "{$page}"; 
        } else { 
            if (($params['pager']['current_page']                     ($params['pager']['current_page'] > $params['pager']['last_page'] - $offset && $page > $params['pager']['last_page'] - $offset ) || 
                    ( $page $params['pager']['current_page'] - $offset ) 
            ) { 
                $url = spUrl($params['c'], $params['a'], $args + array($pagerhandle => $page)); 
                $html .= "
{$page}"; 
            } 
        } 
    } 
    if ($params['pager']['current_page'] != $params['pager']['last_page']) { 
        $url = spUrl($params['c'], $params['a'], $args + array($pagerhandle => $params['pager']['next_page'])); 
        $html .= "Next >"; 
    } else { 
        $html .= "Next >"; 
    } 
    $html .= '
'; 
    return $html; 

模板调用方法


控制器内使用:

[php] 
//资讯列表 
    function newslist() { 
        $newsobj = spClass("lib_news"); 
        // 这里使用了spPager,同时用spArgs接受到传入的page参数 
        $this->results = $newsobj->spPager($this->spArgs('page', 1), 12)->findAll(null, 'id DESC'); 
        // 这里获取分页数据并发送到smarty模板内 
        $this->pager = $newsobj->spPager()->getPager(); 
        $this->display("admin/news_list.html"); 
    } 

CSS样式
[css] 
.num { 
    clear:both; margin:0 auto; width:500px; padding:15px 0 0 0;  

.num A { 
    BORDER-RIGHT: #ccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #ccc 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 2px; MARGIN: 2px; BORDER-LEFT: #ccc 1px solid; COLOR: #000; PADDING-TOP: 2px; BORDER-BOTTOM: #ccc 1px solid; TEXT-DECORATION: none 

.num A:hover { 
    BORDER: #0080C0 1px solid; COLOR: #000;  

.num A:active { 
    BORDER: #0080C0 1px solid; COLOR: #000;  

.num SPAN.current { 
    BORDER-RIGHT: #0080C0 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #0080C0 1px solid; PADDING-LEFT: 5px; FONT-WEIGHT: bold; PADDING-BOTTOM: 2px; MARGIN: 2px; BORDER-LEFT: #0080C0 1px solid; COLOR: #fff; PADDING-TOP: 2px; BORDER-BOTTOM: #0080C0 1px solid; BACKGROUND-COLOR: #0080C0 

.num SPAN.disabled { 
    BORDER-RIGHT: #eee 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #eee 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 2px; MARGIN: 2px; BORDER-LEFT: #eee 1px solid; COLOR: #ddd; PADDING-TOP: 2px; BORDER-BOTTOM: #eee 1px solid 

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1665
14
PHP Tutorial
1269
29
C# Tutorial
1249
24
Steps and precautions for registering a Hong Kong Apple ID (enjoy the unique advantages of the Hong Kong Apple Store) Steps and precautions for registering a Hong Kong Apple ID (enjoy the unique advantages of the Hong Kong Apple Store) Sep 02, 2024 pm 03:47 PM

Apple's products and services have always been loved by users around the world. Registering a Hong Kong Apple ID will bring more convenience and privileges to users. Let’s take a look at the steps to register a Hong Kong Apple ID and what you need to pay attention to. How to register a Hong Kong Apple ID When using Apple devices, many applications and functions require using Apple ID to log in. If you want to download applications from Hong Kong or enjoy the preferential content of the Hong Kong AppStore, it is very necessary to register a Hong Kong Apple ID. This article will detail the steps on how to register a Hong Kong Apple ID and what you need to pay attention to. Steps: Select language and region: Find the "Settings" option on your Apple device and enter

Blackmagic\'s pro-level video app lands on Android, but your phone probably can\'t run it Blackmagic\'s pro-level video app lands on Android, but your phone probably can\'t run it Jun 25, 2024 am 07:06 AM

Blackmagic Design has finally brought its well-praised Blackmagic Camera app to Android. The professional video camera app is free to download, and it offers complete manual controls. These controls aim to make it easier for you to take pro-level cin

How does the learning curve of PHP frameworks compare to other language frameworks? How does the learning curve of PHP frameworks compare to other language frameworks? Jun 06, 2024 pm 12:41 PM

The learning curve of a PHP framework depends on language proficiency, framework complexity, documentation quality, and community support. The learning curve of PHP frameworks is higher when compared to Python frameworks and lower when compared to Ruby frameworks. Compared to Java frameworks, PHP frameworks have a moderate learning curve but a shorter time to get started.

How do the lightweight options of PHP frameworks affect application performance? How do the lightweight options of PHP frameworks affect application performance? Jun 06, 2024 am 10:53 AM

The lightweight PHP framework improves application performance through small size and low resource consumption. Its features include: small size, fast startup, low memory usage, improved response speed and throughput, and reduced resource consumption. Practical case: SlimFramework creates REST API, only 500KB, high responsiveness and high throughput

Who holds up the thousand-yuan machine? vivo Y37m starts at NT$999! Who holds up the thousand-yuan machine? vivo Y37m starts at NT$999! Jul 25, 2024 pm 01:26 PM

As various companies have recently focused on mid-range performance phones priced between 2,000 and 3,000, a wave of phone replacements has occurred. It seems that there is no splash in the thousand-yuan range, but vivo has quietly launched the vivoY series. Two models, including vivoY37 and vivoY37m, have been officially launched on July 20, with vivoY37 starting at 1,199 yuan and vivoY37m starting at 999 yuan. Let’s take a look at how they are doing. vivoY37 and vivoY37m have the same appearance design, and provide a variety of color options such as distant mountain green and diamond purple. The overall design is thin and easy to hold, with smooth lines and a perfect combination of fashion and practicality. Light feel: Both weigh only 185g, making them light to hold.

Java Framework Learning Roadmap: Best Practices in Different Domains Java Framework Learning Roadmap: Best Practices in Different Domains Jun 05, 2024 pm 08:53 PM

Java framework learning roadmap for different fields: Web development: SpringBoot and PlayFramework. Persistence layer: Hibernate and JPA. Server-side reactive programming: ReactorCore and SpringWebFlux. Real-time computing: ApacheStorm and ApacheSpark. Cloud Computing: AWS SDK for Java and Google Cloud Java.

What are the platforms for virtual currency trading around the world? The top ten latest 2025 digital currency app rankings What are the platforms for virtual currency trading around the world? The top ten latest 2025 digital currency app rankings Feb 27, 2025 pm 06:09 PM

The top four global virtual currency trading platforms in 2025 are: Binance: a leader in the industry, providing diversified trading options and innovative products. OKX: A huge user base, providing comprehensive cryptocurrency services. Gate.io: User-friendly, offering a wide range of cryptocurrency options. Bitget: Focus on derivatives trading and provides high leverage futures contracts.

How to read and write files concurrently in Golang? How to read and write files concurrently in Golang? Jun 05, 2024 pm 06:12 PM

Concurrent file reading: create a goroutine to read data blocks concurrently, and use pipeline communication coordination; concurrent file writing: use goroutine to write data, and use a mutex to protect the write operation.

See all articles