VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Digi-web on August 24, 2018, 13:22:46 PM

Title: Future Request - Meta String in Pagination Results
Post by: Digi-web on August 24, 2018, 13:22:46 PM
Hello,

Due to google robot reporting duplicate meta description in multiple pages such as the following:
https://demo.virtuemart.net/product-attributes?limit=60
https://demo.virtuemart.net/product-attributes

Is it possible to create a string in the meta Description and Title So it will also include some string like "page name - Category title - STRING_NAME" Where STRING_NAME could be something like "Products from page 60"
I am aware that these pages do have a canonical ref to the main category pages and should not pose a problem but google keeps reporting these page urls in Webmaster tools as problematic and it takes time to identify them...

PS. The only relative topic i found is this:
https://forum.virtuemart.net/index.php?topic=113166.msg380712#msg380712

Edit:
Possible code in views/category/view.html.php

      // check if pagination is set - code from virtuemart router check
      if (is_int(vmrouterHelper::$limit) === false) {
         
         //check if page no from pagination exists  eg: results,25-48 (page 2)
         if( $pageNo !== "" ){
            
            $limitConst = $pageNo;
            //update meta title end description
            $metadesc .=' - '.vmText::_('COM_VIRTUEMART_SEF_PAGE').': '.$limitConst;
            $document->setMetaData('description',$metadesc);
            //will be set bellow
            $title .=' - '.vmText::_('COM_VIRTUEMART_SEF_PAGE').': '.$limitConst;
         }else{
            //should check somehow how the product view number changes eg from 24 to 48 eg: results,1-48
            $limitConst = vmrouterHelper::$limit;
            $limitConstclean = str_replace(",","",$limitConst); // may be like 24,48 if multiple values are inserted
            
            $jinput = JFactory::getApplication()->input;
            $limitget = $jinput->get('limit');
            
            if( ($limitget !== null) && ($limitConstclean !== $limitget) ){
               //ADD a CUSTOM COM_VIRTUEMART_SEF_PAGINATION IN JOOMLA OVERIDES something like pagination (should show Title - pagination: 12)
               
               //update meta title end description
               $metadesc .=' - '.vmText::_('COM_VIRTUEMART_SEF_PAGINATION').': '.$limitget;
               $document->setMetaData('description',$metadesc);
               //will be set bellow
               $title .=' - '.vmText::_('COM_VIRTUEMART_SEF_PAGINATION').': '.$limitget;
            }
         }         
         
      }
      //edit end

Best regards,
Alexander
Title: Re: Future Request - Meta String in Pagination Results
Post by: Studio 42 on August 24, 2018, 19:31:47 PM
In query parameters :
first result index exist it's set to 'limitstart'(if empty then you are in page 0)
'limit' is the number of result and should exist to.
So you can use this 2 values to change the title and metadesc
Title: Re: Future Request - Meta String in Pagination Results
Post by: Digi-web on August 27, 2018, 08:42:04 AM
Hi, thank you the info i have figured it out regarding pagination and it is working ok. I have edited the initial post for the code as well.

What i was also trying to achieve is :

We do have pagination so in case of lets say a category has 30 products and we have a limit to 24 i press the page 2 and the url becomes /results,25-48 (page 2) so we are OK here i can detect that.
What i cannot detect is in case a page has 30 products and i press the button to see not 24 products but eg 48 so no pagination is set but the actual URL changes and becomes /results,1-48.
In my tests there is no variable to detect that as vmrouterHelper::$limit is always set from config and the get variables are unset. Any ideas?

BR,
Alexander
Title: Re: Future Request - Meta String in Pagination Results
Post by: Studio 42 on August 27, 2018, 13:07:50 PM
If you want set it when this are unknow, you have to use same code as in the router.
Or perhaps in the category model getpaginationlimit, i never checked if VIrtuemart return the right limit in all case.
Title: Re: Future Request - Meta String in Pagination Results
Post by: Digi-web on August 27, 2018, 13:23:42 PM
Quote from: Studio 42 on August 27, 2018, 13:07:50 PM
If you want set it when this are unknow, you have to use same code as in the router.
Or perhaps in the category model getpaginationlimit, i never checked if VIrtuemart return the right limit in all case.
Yes but the router after it sees the GET requests then it unsets them so i cannot access them afterwards... all pagination vars are not set from my var_dumps or there is no useful info in order to step on it and create a certain rule... Anyway i am glad i took this so far as most of duplicate issues will be gone :)

I will give it a try when i have more time perhaps.
Title: Re: Future Request - Meta String in Pagination Results
Post by: GJC Web Design on August 27, 2018, 16:28:53 PM
is it still not in

$jinput = JFactory::getApplication()->input;
$limit = $jinput->get('limit');
Title: Re: Future Request - Meta String in Pagination Results
Post by: Digi-web on August 27, 2018, 18:13:29 PM
Yes indeed this is the first i checked ... limit is a get request and it is unset in the virtuemart main router.php so it does not exist afterwards... o thing in oir case it is zero and this is why it is unset but we have nothing to work on...  i am not sure if theee is anu way to check it before router i think not .
Title: Re: Future Request - Meta String in Pagination Results
Post by: Digi-web on August 28, 2018, 15:32:51 PM
Code updated, tested locally and seems to work OK, what do you think?
The SEO text has to change of course...
Title: Re: Future Request - Meta String in Pagination Results
Post by: Digi-web on August 29, 2018, 12:05:35 PM
I found some issues in the last edit so i fixed them today, tested successfully in both local and live server.