You are here:  » Pagination pages (urls)


Pagination pages (urls)

Submitted by APZ215 on Tue, 2019-01-29 16:03 in

Hello David,
I Have a pagination question,
I would like to have the pagename in the pagination pages.

(current version)
/2.html
/3.html
/4.html

(preferred new option A)
/categoryname-2.html
/categoryname-3.html
/categoryname-4.html

(preferred new option B)
/categoryname/categoryname-2.html
/categoryname/categoryname-3.html
/categoryname/categoryname-4.html

I think (preferred new option B) is the most easy

Thanks Greetings Arlo

--------------------------------------------------------------
Page (current version)
https://www.example.com/category/categoryname/
https://www.example.com/brand/brandname/
https://www.example.com/merchant/merchantname/

Page + Pagination page 2 (current version)
https://www.example.com/category/categoryname/2.html
https://www.example.com/brand/brandname/2.html
https://www.example.com/merchant/merchantname/2.html
--------------------------------------------------------------

(preferred new option A)
Is it possible to create this pagination url ?
https://www.example.com/category/categoryname-2.html
https://www.example.com/brand/brandname-2.html
https://www.example.com/merchant/merchantname-2.html

(preferred new option B)
Is it possible to create this pagination url ?
https://www.example.com/category/categoryname/categoryname-2.html
https://www.example.com/brand/brandname/brandname-2.html
https://www.example.com/merchant/merchantname/merchantname-2.html

Submitted by support on Mon, 2019-02-04 09:53

Hello Arlo,

Sure - option B is no problem.

To try this, first edit html/navigation.php and look for the following code at line 14:

    global $q;

...and REPLACE with:

    global $q;
    $parts = explode(":",$q);

...and then the following code at line 35:

          $prevHREF = $prevPage.".html";

...and REPLACE with:

          $prevHREF = tapestry_hyphenate($parts[1])."-".$prevPage.".html";

And then the following code at line 100:

          $pageHREF = $i.".html";

...and REPLACE with:

          $pageHREF = tapestry_hyphenate($parts[1])."-".$i.".html";

And then the following code at line 126:

        $nextHREF = $nextPage.".html";

...and REPLACE with:

        $nextHREF = tapestry_hyphenate($parts[1])."-".$nextPage.".html";

Edit .htaccess and look for the following rule at line 13:

RewriteRule ^merchant/(.*)/(.*).html$ search.php?q=merchant:$1:&page=$2&rewrite=1&%{QUERY_STRING} [B,L]

...and REPLACE with:

RewriteRule ^merchant/(.*)/(.*)-([0-9]+).html$ search.php?q=merchant:$1:&page=$3&rewrite=1&%{QUERY_STRING} [B,L]

And then the following rule at line 17:

RewriteRule ^category/(.*)/(.*).html$ search.php?q=category:$1:&page=$2&rewrite=1&%{QUERY_STRING} [L,B]

...and REPLACE with:

RewriteRule ^category/(.*)/(.*)-([0-9]+).html$ search.php?q=category:$1:&page=$3&rewrite=1&%{QUERY_STRING} [L,B]

And finally the following rule at line 21:

RewriteRule ^brand/(.*)/(.*).html$ search.php?q=brand:$1:&page=$2&rewrite=1&%{QUERY_STRING} [B,L]

...and REPLACE with:

RewriteRule ^brand/(.*)/(.*)-([0-9]+).html$ search.php?q=brand:$1:&page=$3&rewrite=1&%{QUERY_STRING} [B,L]

Cheers,
David.
--
PriceTapestry.com

Submitted by APZ215 on Mon, 2019-02-04 12:46

Hello David,
It almost works perfect :-)

There is a problem with page 10 and more.

https://www.example.com/category/categoryname/categoryname-10.html (nothing found)
https://www.example.com/category/categoryname/categoryname-11.html (shows page 1)
https://www.example.com/category/categoryname/categoryname-12.html (shows page 2)
https://www.example.com/category/categoryname/categoryname-13.html (shows page 3)
etc..
https://www.example.com/category/categoryname/categoryname-20.html (nothing found)

I have an online exmaple @

{link saved}

Greetings Arlo

Submitted by support on Mon, 2019-02-04 13:02

Hello Arlo,

Ah - the replacement RewriteRule expressions require the preceding "-" before the page match so

([0-9]+)

...should be:

-([0-9]+)

(corrected in the replacements above)

Cheers,
David.
--
PriceTapestry.com

Submitted by APZ215 on Mon, 2019-02-04 13:11

Thank you very much David! It works :)

Submitted by APZ215 on Tue, 2019-02-05 08:25

Hello David,

Some Pricetapestry websites there are have stripped the '.html', what to do to strip the .html in the Pagination pages (urls) according this ticket. Or is that to complicated?

I tried this, that didnt went well
(Remove .html from end of url https://www.pricetapestry.com/node/2296)

{link saved}

Greetings Arlo

Submitted by support on Tue, 2019-02-05 08:36

Hi Arlo,

With the matching against -(page-number) it is just a case of removing .html from the rules and each instance of where it is generated in the navigation.

So in .htaccess simply remove .html from each RewriteRule so you will have at line 13:

RewriteRule ^merchant/(.*)/(.*)-([0-9]+)$ search.php?q=merchant:$1:&page=$3&rewrite=1&%{QUERY_STRING} [B,L]

line 17:

RewriteRule ^category/(.*)/(.*)-([0-9]+)$ search.php?q=category:$1:&page=$3&rewrite=1&%{QUERY_STRING} [L,B]

and line 21:

RewriteRule ^brand/(.*)/(.*)-([0-9]+)$ search.php?q=brand:$1:&page=$3&rewrite=1&%{QUERY_STRING} [B,L]

And then in html/navigation.php just replace

".html"

with empty string:

""

...at lines 35, 100 and 126 and that should be all you need to do...

Cheers,
David.
--
PriceTapestry.com

Submitted by APZ215 on Tue, 2019-02-05 11:52

Thank you very much David! It works... again! :)

Submitted by APZ215 on Mon, 2019-02-11 07:53

Hello David,
Is there an easy way to adjust the sitemap (sitemapCategories.php & sitemapBrands.php.php)(node/2437) that it will be using the same urls just like the 'Pagination page (urls)' requested urls in (node/6589)?

Greetings Arlo

Exmaple url@ https://example.com/sitemapCategories.php?category=Accessoires+honden

Exmaple url@ https://example.com/category/Accessoires-honden/2.html (how it works know)

Exmaple url@ https://example.com/category/Accessoires-honden/Accessoires-honden-2.html (requested option)

Submitted by support on Mon, 2019-02-11 09:15

Hi Arlo,

Sure - in each of the sitemap scripts look for this line:

       if ($page > 1) $loc .= $page.".html";

...and in sitemapCategories.php REPLACE with:

       if ($page > 1) $loc .= tapestry_hyphenate($category)."-".$page.".html";

...and in sitemapBrands.php REPLACE with:

       if ($page > 1) $loc .= tapestry_hyphenate($brand)."-".$page.".html";

Cheers,
David.
--
PriceTapestry.com

Submitted by APZ215 on Wed, 2019-02-13 08:35

Hello David,
Thanks again, it works fine... you did it again! Greetings Arlo

Submitted by APZ215 on Thu, 2019-10-24 09:16

Hello David, i tried to get / at the end of the page navigation but what i tried failed.

--------------------------------------------------------------
Page (current version)

{link saved}

RewriteRule ^example/(.*)/(.*)$ search.php?q=merchant:$1:&page=$2&rewrite=1&%{QUERY_STRING} [B,L]

--------------------------------------------------------------

(preferred new option C)

/2/
/3/
/4/

{link saved}

How do i get the / at the end of the page url?

Thanks greetings Arlo

Submitted by support on Thu, 2019-10-24 10:46

Hello Arlo,

The change to that line of .htaccess is correct, but it has to be moved above the page 1 RewriteRule otherwise it takes priority, e.g. you need to use:

RewriteRule ^example/(.*)/(.*)$ search.php?q=merchant:$1:&page=$2&rewrite=1&%{QUERY_STRING} [B,L]
RewriteRule ^example/(.*)/$ search.php?q=merchant:$1:&rewrite=1&%{QUERY_STRING} [B,L]

And then the changes to html/navigation.php,

Look for the following code beginning at line 28:

        if ($prevPage == 1)
        {
          $prevHREF = "./";
        }
        else
        {
          $prevHREF = $prevPage.".html";
        }

...and REPLACE with:

        if ($prevPage == 1)
        {
          $prevHREF = "../";
        }
        else
        {
          $prevHREF = "../".$prevPage."/";
        }

Look for the following code beginning at line line 77:

        $pageOneHREF = "./";

...and REPLACE with:

        $pageOneHREF = "../";

Look for the following code beginning at line line 93:

        if ($i==1)
        {
          $pageHREF = "./";
        }
        else
        {
          $pageHREF = $i.".html";
        }

...and REPLACE with:

        if ($page==1)
        {
          if ($i==1)
          {
            $pageHREF = "./";
          }
          else
          {
            $pageHREF = $i."/";
          }
        }
        else
        {
          if ($i==1)
          {
            $pageHREF = "../";
          }
          else
          {
            $pageHREF = "../".$i."/";
          }
        }

Look for the following code beginning at (now) line 139:

        $nextHREF = $nextPage.".html";

...and REPLACE with:

        if ($page==1)
        {
          $nextHREF = "2/";
        }
        else
        {
          $nextHREF = "../".$nextPage."/";
        }

Hope this helps!

Cheers,
David.
--
PriceTapestry.com