0

请不要关闭我的类别页面的分页真的需要帮助。我用聪明的。我的主页分页工作正常。我也希望类别页面也一样。我的桌子

1. products-(contains image, details). 
2. product_tags-(contains tag, perma) 
3. product_tag_joins-(contains tag_id, product_id)

我的 category.php 代码:

此代码工作正常,根据类别名称显示产品。请对此进行分页。

if (@$tag){
$tag = $product->getCategoryByPerma($tag);
if ($tag){
    $tagid = $tag['id'];
    $tag = $tag['tag'];

    $tagproducts = $product->getProductsByCategory($tagid);
    if (!count($tagproducts)){
        $tagproducts = '';
    } else {
    sort($tagproducts);
        foreach($tagproducts as $key => $val){
            @extract($val);
            $description = nl2br(stripslashes($description));
            if (strlen($description)>=220) $description = substr($description,0,220)."...";
            $tagmovies[$key]['description']=$description;
            $tagmovies[$key]['title']=stripslashes($title);
        }
    }
    $smarty->assign("tagproducts",$tagproducts);

}} else {$tag = '';}$seodata['category']=$tag;$smarty->assign("tag",$tag);

getCategoryByPerma:

public function getCategoryByPerma( $perma );
{
    $perma = mysql_real_escape_string( $perma );
    if ( !( $e = mysql_query( "SELECT id,tag FROM product_tags WHERE perma='{$perma}'" ) ) )
    {
        exit( mysql_error( ) );
    }
    if ( mysql_num_rows( $e ) )
    {
        extract( mysql_fetch_array( $e ) );
        return array(
            "id" => $id,
            "tag" => $tag
        );
    }
    return "";
}

getProductsByCategory

public function getProductsByCategory( $tagid )
{
    $tagid = mysql_real_escape_string( $tagid );
    if ( !( $e = mysql_query( "SELECT * FROM products WHERE id IN (SELECT product_id FROM product_tags_join WHERE tag_id='{$tagid}')" ) ) )
    {
        exit( mysql_error( ) );
    }
    $product = array( );
    while ( mysql_num_rows( $e ) && ( $s = mysql_fetch_array( $e ) ) )
    {
        extract( $s );
        $products[$id] = array( );
        $products[$id]['title'] = $title;
        $products[$id]['description'] = $description;
        $products[$id]['thumbnail'] = $thumb;
        $products[$id]['permalink'] = $perma;
    }
    return $products;
}

这是我的分页主页 php 代码,它工作正常。我也希望类别页面也一样。

$maxperpage = $settings->getSetting("maxproductsperpage"); $displaymode = $settings->getSetting("display_mode_product");   if (!@$p) $p = 1;if (((is_array($displaymode)) && (empty($displaymode))) || ($displaymode==0)){
if ($maxperpage){
    $count = $product->getRealProductCount();
    $productlist = $product->getRealProduct($p,$maxperpage);
    if ($seolinks){
        $pagination = $product->getBasicPagination($count,$p,$maxperpage,$baseurl."/products/");
    } else {
        $pagination = $product->getBasicPagination($count,$p,$maxperpage,$baseurl."/index.php?menu=products&p=");
    }
} else {
    $productlist = $product->getRealProducts();
    if ($seolinks){
        $pagination = '<a href="'.$baseurl.'/products">1</a>';
    } else {
        $pagination = '<a href="'.$baseurl.'/index.php?menu=products">1</a>';
    }
}

if (count($productlist)){
    foreach($productlist as $key => $val){
        @extract($val);
        $description = nl2br(stripslashes($description));
        if (strlen($description)>=380) $description = substr($description,0,380)."...";
        $productlist[$key]['description']=$description;
        $productlist[$key]['title']=stripslashes(stripslashes($title));
    }
} else {
    $productlist = '';
}

$smarty->assign("productlist",$productlist);
$smarty->assign("pagination",$pagination);
$smarty->assign("displaymode","0");} 
 else {
    $productlist = '';
}
4

1 回答 1

0

下面我列出了一些资源链接,这些链接可能会让您开始尝试实现的目标

Smarty Paginate是一个与 smarty 模板引擎一起工作的分页插件。

一些与该主题相关的 SO 链接

使用 Smarty 进行分页(上一个 | 下一个)

php-sql-smarty 分页

浏览这些资源并找到更多资源,然后在实施解决方案时询问您是否遇到任何特定问题/错误

于 2013-03-18T21:07:30.957 回答