欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

为什么这个框架里面的选项切换后只显示4个

程序员文章站 2022-04-07 08:49:09
...

为什么这个框架里面的选项切换后只显示4个

想让它显示8个内容,也就是两行,更改appsindexcontrollersindex.php里的

    $recentItems = $itemsClass->getAll(0, 4 " `status` = 'active' ", '`datetime` DESC');

修改为

    $recentItems = $itemsClass->getAll(0, 8, " `status` = 'active' ", '`datetime` DESC');

刷新确实显示8个内容,并且是两行,
但是点击上面的任意按钮,又变成4个了

页面html如下

{literal} {/literal}
{/if}

appsindexcontrollersindex.php代码如下:

getAll(0, 0, $itemsClass->usersWhere);
    abr('users', $users);


#推荐作品
    $weeklyItems = $itemsClass->getAll(0, 4, " `status` = 'active' AND `weekly_to` >= '".date('Y-m-d')."' ", "`datetime` DESC");
    abr('weeklyItems', $weeklyItems);
    
    if($itemsClass->foundRows > 10) {
        abr('haveWeekly', 'yes');
    }

#加载分类
        require_once ROOT_PATH.'/apps/categories/models/categories.class.php';
        $categoriesClass = new categories();
    
        $categories = $categoriesClass->getAll();
        abr('categories', $categories);     
    
#近期作品
    $recentItems = $itemsClass->getAll(0, 8, " `status` = 'active' ", '`datetime` DESC');
    kshuffle($recentItems);
    abr('recentItems', $recentItems);
    
    //免费作品
    $freeItem = $itemsClass->getAll(0, 4, " `status` = 'active' AND `free_file` = 'true' ", '`datetime` DESC');

    abr('freeItem', $freeItem);
    
#推荐作者
    require_once ROOT_PATH.'/apps/users/models/users.class.php';
    $usersClass = new users();
    //获取用户信息及粉丝
    $featuredAuthor = $usersClass->getAll(0, 0, " `status` = 'activate' AND `featured_author` = 'true' ", 'RAND()');
    // if(is_array($featuredAuthor)) {
    //     //作者的一些作品
    //     $featuredItems = array();
    //      foreach($featuredAuthor as $itear){
    //         $featuredItems[$itear['user_id']] = $itemsClass->getAll(0, 2, " `status` = 'active' AND `user_id` = '".intval($itear['user_id'])."' ");
    //     }
    //     abr('featuredItems', $featuredItems);
        
    //     abr('featuredAuthorInfo', langMessageReplace($langArray['featured_author_info'], array(
    //                                                             'USERNAME' => $featuredAuthor['username'],
    //                                                             'MONTH' => $langArray['monthArr'][date('n', strtotime($featuredAuthor['register_datetime']))],
    //                                                             'YEAR' => date('Y', strtotime($featuredAuthor['register_datetime'])),
    //                                                             'ITEMS' => $featuredAuthor['items'],
    //                                                             'SALES' => $featuredAuthor['sales']
    //                                                         )));
    // }
    abr('featuredAuthor', $featuredAuthor);


#推荐作者
    require_once ROOT_PATH.'/apps/users/models/users.class.php';
    $usersClass = new users();
    $newAuthor = $usersClass->getAll(0, 8, " `status` = 'activate' ", 'RAND()');
    abr('newAuthor', $newAuthor);

#用户关注的作者的最新作品
    if(check_login_bool()) {
        $following = $usersClass->getFollowersID($_SESSION['user']['user_id']);
        if(is_array($following)) {
            $whereQuery = '';
            foreach($following as $f) {
                if($whereQuery != '') {
                    $whereQuery .= ' OR ';
                }
                $whereQuery .= " `user_id` = '".intval($f['follow_id'])."' ";
            }
            
            $followingItems = $itemsClass->getAll(0, 0, " `status` = 'active' AND ($whereQuery) ", "`datetime` DESC");
            abr('followingItems', $followingItems);
            
            abr('followingItemsCount', $itemsClass->foundRows);
            abr('emptyThumb', (10-$itemsClass->foundRows));
        }
    }
#王牌作者
    

        $topAuthors = $usersClass->getAll(0, 9, " `status` = 'activate' and `sales` > 0 ", "`sales` DESC");
        abr('topAuthors', $topAuthors);
        
        abr('topAuthorsCount', $usersClass->foundRows);
        abr('emptyThumb', (9-$usersClass->foundRows));
        
    

#随机分类
    $randCategories = array_rand($mainCategories, 5);
    abr('randCategories', $randCategories);    
    
#最低价格
    $lowPrice = $itemsClass->getAll(0, 1, " `status` = 'active' ", "`price` ASC");
    if(is_array($lowPrice)) {
        $lowPrice = array_shift($lowPrice);
        $lowPrice = $lowPrice['price'];
    }
    abr('lowPrice', $lowPrice);
    
#快讯
    
    require_once ROOT_PATH.'/apps/qnews/models/qnews.class.php';
    $qnews = new qnews();
    $data = array();
    foreach($qnews->getAll(0, 1, "`visible` = 'true'") AS $key => $value) {
        if($value['photo']) {
            $data[$key] = $value;
            $data[$key]['thumb'] = 'static/uploads/qnews/260x140/' . $value['photo'];
        }
    }
    
    abr('qnews_data', $data);
    
#面包屑
    abr('breadcrumb', ''.$langArray['home'].'');


//读取所有tags   require_once ROOT_PATH. "/apps/tags/models/tags.class.php";//引入tag的数据库模型类
//读取所有tags           $tags = new tags();
//读取所有tags           $getTags = $tags->getAll();//获取数据模型,结果为一个数组
//读取所有tags           abr('tags_new',$getTags);//在smarty模板中加入变量‘tags_new’
//读取所有tags {foreach from=$tags_new item=t}
//读取所有tags {$t.name}
//读取所有tags {/foreach}
    
//开始。。
//获取所有一级分类
    require_once ROOT_PATH . "/apps/categories/models/categories.class.php";
    $categoriesClass = new categories();
    $allCategories_0 = $categoriesClass->getAll(0, 0, " `visible` = 'true' AND `sub_of`=0 ");
    $data = array();
    foreach ($allCategories_0 as $categories_data) {
        //获取当前分类子分类
        $categories_son = $categoriesClass->getAll(0, 0, " `visible` = 'true' AND `sub_of`= ".intval($categories_data['id'])." ");
        //获取一级分类下得所有作品
        $whereQuery = " AND `id` IN (SELECT `item_id` FROM `items_to_category` WHERE `categories` LIKE '%,".intval($categories_data['id']).",%') ";
        $items = $itemsClass->getAll(0, 0, " `status` = 'active' ".$whereQuery);
        $data[$categories_data['id']][] = array(
            'categories' => $categories_data,
            'categories_son' => $categories_son,
            'items' => $items
        );
    }
    abr('data',$data);
    
?>

网站地址

回复内容:

为什么这个框架里面的选项切换后只显示4个

想让它显示8个内容,也就是两行,更改appsindexcontrollersindex.php里的

    $recentItems = $itemsClass->getAll(0, 4 " `status` = 'active' ", '`datetime` DESC');

修改为

    $recentItems = $itemsClass->getAll(0, 8, " `status` = 'active' ", '`datetime` DESC');

刷新确实显示8个内容,并且是两行,
但是点击上面的任意按钮,又变成4个了

页面html如下

{literal} {/literal}
{/if}

appsindexcontrollersindex.php代码如下:

getAll(0, 0, $itemsClass->usersWhere);
    abr('users', $users);


#推荐作品
    $weeklyItems = $itemsClass->getAll(0, 4, " `status` = 'active' AND `weekly_to` >= '".date('Y-m-d')."' ", "`datetime` DESC");
    abr('weeklyItems', $weeklyItems);
    
    if($itemsClass->foundRows > 10) {
        abr('haveWeekly', 'yes');
    }

#加载分类
        require_once ROOT_PATH.'/apps/categories/models/categories.class.php';
        $categoriesClass = new categories();
    
        $categories = $categoriesClass->getAll();
        abr('categories', $categories);     
    
#近期作品
    $recentItems = $itemsClass->getAll(0, 8, " `status` = 'active' ", '`datetime` DESC');
    kshuffle($recentItems);
    abr('recentItems', $recentItems);
    
    //免费作品
    $freeItem = $itemsClass->getAll(0, 4, " `status` = 'active' AND `free_file` = 'true' ", '`datetime` DESC');

    abr('freeItem', $freeItem);
    
#推荐作者
    require_once ROOT_PATH.'/apps/users/models/users.class.php';
    $usersClass = new users();
    //获取用户信息及粉丝
    $featuredAuthor = $usersClass->getAll(0, 0, " `status` = 'activate' AND `featured_author` = 'true' ", 'RAND()');
    // if(is_array($featuredAuthor)) {
    //     //作者的一些作品
    //     $featuredItems = array();
    //      foreach($featuredAuthor as $itear){
    //         $featuredItems[$itear['user_id']] = $itemsClass->getAll(0, 2, " `status` = 'active' AND `user_id` = '".intval($itear['user_id'])."' ");
    //     }
    //     abr('featuredItems', $featuredItems);
        
    //     abr('featuredAuthorInfo', langMessageReplace($langArray['featured_author_info'], array(
    //                                                             'USERNAME' => $featuredAuthor['username'],
    //                                                             'MONTH' => $langArray['monthArr'][date('n', strtotime($featuredAuthor['register_datetime']))],
    //                                                             'YEAR' => date('Y', strtotime($featuredAuthor['register_datetime'])),
    //                                                             'ITEMS' => $featuredAuthor['items'],
    //                                                             'SALES' => $featuredAuthor['sales']
    //                                                         )));
    // }
    abr('featuredAuthor', $featuredAuthor);


#推荐作者
    require_once ROOT_PATH.'/apps/users/models/users.class.php';
    $usersClass = new users();
    $newAuthor = $usersClass->getAll(0, 8, " `status` = 'activate' ", 'RAND()');
    abr('newAuthor', $newAuthor);

#用户关注的作者的最新作品
    if(check_login_bool()) {
        $following = $usersClass->getFollowersID($_SESSION['user']['user_id']);
        if(is_array($following)) {
            $whereQuery = '';
            foreach($following as $f) {
                if($whereQuery != '') {
                    $whereQuery .= ' OR ';
                }
                $whereQuery .= " `user_id` = '".intval($f['follow_id'])."' ";
            }
            
            $followingItems = $itemsClass->getAll(0, 0, " `status` = 'active' AND ($whereQuery) ", "`datetime` DESC");
            abr('followingItems', $followingItems);
            
            abr('followingItemsCount', $itemsClass->foundRows);
            abr('emptyThumb', (10-$itemsClass->foundRows));
        }
    }
#王牌作者
    

        $topAuthors = $usersClass->getAll(0, 9, " `status` = 'activate' and `sales` > 0 ", "`sales` DESC");
        abr('topAuthors', $topAuthors);
        
        abr('topAuthorsCount', $usersClass->foundRows);
        abr('emptyThumb', (9-$usersClass->foundRows));
        
    

#随机分类
    $randCategories = array_rand($mainCategories, 5);
    abr('randCategories', $randCategories);    
    
#最低价格
    $lowPrice = $itemsClass->getAll(0, 1, " `status` = 'active' ", "`price` ASC");
    if(is_array($lowPrice)) {
        $lowPrice = array_shift($lowPrice);
        $lowPrice = $lowPrice['price'];
    }
    abr('lowPrice', $lowPrice);
    
#快讯
    
    require_once ROOT_PATH.'/apps/qnews/models/qnews.class.php';
    $qnews = new qnews();
    $data = array();
    foreach($qnews->getAll(0, 1, "`visible` = 'true'") AS $key => $value) {
        if($value['photo']) {
            $data[$key] = $value;
            $data[$key]['thumb'] = 'static/uploads/qnews/260x140/' . $value['photo'];
        }
    }
    
    abr('qnews_data', $data);
    
#面包屑
    abr('breadcrumb', ''.$langArray['home'].'');


//读取所有tags   require_once ROOT_PATH. "/apps/tags/models/tags.class.php";//引入tag的数据库模型类
//读取所有tags           $tags = new tags();
//读取所有tags           $getTags = $tags->getAll();//获取数据模型,结果为一个数组
//读取所有tags           abr('tags_new',$getTags);//在smarty模板中加入变量‘tags_new’
//读取所有tags {foreach from=$tags_new item=t}
//读取所有tags {$t.name}
//读取所有tags {/foreach}
    
//开始。。
//获取所有一级分类
    require_once ROOT_PATH . "/apps/categories/models/categories.class.php";
    $categoriesClass = new categories();
    $allCategories_0 = $categoriesClass->getAll(0, 0, " `visible` = 'true' AND `sub_of`=0 ");
    $data = array();
    foreach ($allCategories_0 as $categories_data) {
        //获取当前分类子分类
        $categories_son = $categoriesClass->getAll(0, 0, " `visible` = 'true' AND `sub_of`= ".intval($categories_data['id'])." ");
        //获取一级分类下得所有作品
        $whereQuery = " AND `id` IN (SELECT `item_id` FROM `items_to_category` WHERE `categories` LIKE '%,".intval($categories_data['id']).",%') ";
        $items = $itemsClass->getAll(0, 0, " `status` = 'active' ".$whereQuery);
        $data[$categories_data['id']][] = array(
            'categories' => $categories_data,
            'categories_son' => $categories_son,
            'items' => $items
        );
    }
    abr('data',$data);
    
?>

网站地址