当前位置:Gxlcms > PHP教程 > 为什么这个框架里面的选项切换后只显示4个

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

时间:2021-07-01 10:21:17 帮助过:5人阅读

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

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

修改为

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

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

页面html如下

最新上传的作品 {if $recentItems} 全部 {if $mainCategories} {foreach from=$mainCategories item=c} 婚礼相册 清新简约 企业宣传 生日祝寿 毕业纪念 片头LOGO 儿童卡通 唯美浪漫 写真MV 年会颁奖 震撼大气 节日庆典 动感时尚 白事葬礼 微信小视频 水墨中国风 字幕条 {/foreach} {/if} 更多 {foreach from=$recentItems item=i}
{$i.name|escape} {foreach from=$i.categories item=e} {foreach from=$e item=c name=foo} {if $smarty.foreach.foo.last}{$categories[$c].name}{/if} {/foreach} {/foreach} {$i.price}

{$i.name|escape}

{if $users[$i.user_id].avatar != ''} {$users[$i.user_id].nickname} {else} {$users[$i.user_id].nickname} {/if}
{/foreach} 加载中 {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); ?>

网站地址

回复内容:

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

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

修改为

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

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

页面html如下

最新上传的作品 {if $recentItems} 全部 {if $mainCategories} {foreach from=$mainCategories item=c} 婚礼相册 清新简约 企业宣传 生日祝寿 毕业纪念 片头LOGO 儿童卡通 唯美浪漫 写真MV 年会颁奖 震撼大气 节日庆典 动感时尚 白事葬礼 微信小视频 水墨中国风 字幕条 {/foreach} {/if} 更多 {foreach from=$recentItems item=i}
{$i.name|escape} {foreach from=$i.categories item=e} {foreach from=$e item=c name=foo} {if $smarty.foreach.foo.last}{$categories[$c].name}{/if} {/foreach} {/foreach} {$i.price}

{$i.name|escape}

{if $users[$i.user_id].avatar != ''} {$users[$i.user_id].nickname} {else} {$users[$i.user_id].nickname} {/if}
{/foreach} 加载中 {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); ?>

网站地址

人气教程排行