在PHP/Magento中分页时,url中的页码消失

在PHP/Magento中分页时,url中的页码消失,magento,pagination,Magento,Pagination,:-) 我目前正在通过添加rel=“prev”和rel=“next”链接使分类页面SEO友好。页面分为多个页面,每个页面上有12个产品-带有一个“页面菜单栏”,与正常分页一样。我跟着。例如,如果我输入url:examplesite.com/tables.html?ajaxcatalog=true&p=2(源代码包含带有正确页码的rel=“prev”和rel=“next”链接),那么一切都正常工作 但是-如果我在菜单栏中单击页码(在页面菜单栏中),例如“2”。正在打开的页面是examplesite

:-)

我目前正在通过添加rel=“prev”和rel=“next”链接使分类页面SEO友好。页面分为多个页面,每个页面上有12个产品-带有一个“页面菜单栏”,与正常分页一样。我跟着。例如,如果我输入url:examplesite.com/tables.html?ajaxcatalog=true&p=2(源代码包含带有正确页码的rel=“prev”和rel=“next”链接),那么一切都正常工作

但是-如果我在菜单栏中单击页码(在页面菜单栏中),例如“2”。正在打开的页面是examplesite.com/tables.html?ajaxcatalog=true&即使通过按钮/链接的href=“”,也不包含“p=2”,如果我检查它,这是正确的

我真的不明白为什么网页号码不会显示在url中。希望你能帮助我!我需要url中的数字,以便在源代码上显示正确的prev和next链接

奇怪的是,如果我输入examplesite.com/tables.html?ajaxcatalog=true&%3B&p=2链接并在页面上四处点击,页码就会一直在那里,而且所有功能都正常

如何创建上一个链接(我所在页面前一页)的示例:

<?php if (!$this->isFirstPage()): ?>
        <li>
            <a class="previous<?php if(!$this->getAnchorTextForPrevious()): ?> i-previous<?php endif;?>" href="<?php echo $this->getPreviousPageUrl() ?>" title="<?php echo $this->__('Previous') ?>">


  • 以下是我应用的解决方案: 在smartwave porto中查找此文件(ajax.phtml),在我的示例中,它位于以下位置:

    \app\design\frontend\smartwave\porto\template\smartwave\ajaxcatalog\ajax.phtml

    在那个文件中找到这一行

    url.replace(页面参数“”)

    在线160369周围的某个地方。在两个位置都用这个来改变。您的分页功能将起作用:)

    url.replace(page_param,page_param);“

    我正在连接你需要更改这条线的块

    var hist = url;
                            if(url.indexOf("p=") > -1){
                                var len = url.length-url.indexOf("p=");
                                var str_temp = url.substr(url.indexOf("p="),len);
                                var page_param = "";
                                if(str_temp.indexOf("&") == -1){
                                    page_param = str_temp;
                                } else {
                                    page_param = str_temp.substr(0,str_temp.indexOf("&"));
                                }
                                hist = url.replace(page_param,""); /* Change here !! */
                            }
    

    为什么不干脆取消对所有代码块的注释并添加
    var hist=url而不是?:)