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);

AND forgetCategoryByPerma:

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 "";
}

AND forgetProductsByCategory

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 に答える