Author Topic: canonical is adding this string to my url results,1-0.html  (Read 706 times)

macigatto

  • Beginner
  • *
  • Posts: 18
  • A beginner
canonical is adding this string to my url results,1-0.html
« on: January 25, 2023, 17:58:23 pm »
hello, please help me.
I have joomla 3 last version and virtuemart 4

from the last upgrade to virtuemart 4, my canonical is not correct, to the homepage shop and to the category page it is added this /results,1-0.html

https://www.mysite.com/results,1-0.html

please help me, where to look at

thanks

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10689
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.8.8
Re: canonical is adding this string to my url results,1-0.html
« Reply #1 on: January 25, 2023, 18:04:38 pm »
Milbo told me is comes from around the router.php ~ 753

      if ( self::compareKey($splitted[0] ,'results')){
         array_pop($segments);
         $results = explode('-',$splitted[1],2);
         //Pagination has changed, removed the -1 note by Max Milbers NOTE: Works on j1.5, but NOT j1.7
         // limitstart is swapped by joomla to start ! See includes/route.php
         if ($start = intval($results[0])-1) $vars['limitstart'] = $start;
         else $vars['limitstart'] = 0 ;
         $vars['limit'] = (int)$results[1]-$results[0]+1;

      } else {
         $vars['limitstart'] = 0 ;

      }

Quote
the side effect of the fix "unsupported operand types ... " in router.

Haven't had time to look at any of this ....
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

macigatto

  • Beginner
  • *
  • Posts: 18
  • A beginner
Re: canonical is adding this string to my url results,1-0.html
« Reply #2 on: January 25, 2023, 19:24:27 pm »
sorry can you explain it please? thanks

macigatto

  • Beginner
  • *
  • Posts: 18
  • A beginner
Re: canonical is adding this string to my url results,1-0.html
« Reply #3 on: January 25, 2023, 21:50:31 pm »
I resolved commenting this code in file:
router.php

moreover i have not idea what this code is for, and if it is good what I did, anyway it resolved the canonical problem with results,1-0.html

at line 482

 /****   
            $limitstart = intval($limitstart);
            $limit = intval($limit);

            if ( $limitstart>0 ) {
               //For the urls leading to the paginated pages
               // using general limit if $limit is not set
               if ($limit === null) $limit= vmrouterHelper::$limit ;
               $segments[] = self::lang('results') .','. ($limitstart+1).'-'.($limitstart+$limit);
            } else if ($limit !== null && $limit != vmrouterHelper::$limit ) {
               //for the urls of the list where the user sets the pagination size/limit
               $segments[] = self::lang('results') .',1-'.$limit ;
            } else if(!empty($query['search']) or !empty($query['keyword'])){
               $segments[] = self::lang('results') .',1-'.vmrouterHelper::$limit ;
            }
            if(self::$debug)vmdebug('category link segments',$query, $segments); 
           
          ****/

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4675
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: canonical is adding this string to my url results,1-0.html
« Reply #4 on: January 26, 2023, 12:13:05 pm »
If you remove this
if ( $limitstart>0 ) {
Then pagination is not working anymore

macigatto

  • Beginner
  • *
  • Posts: 18
  • A beginner
Re: canonical is adding this string to my url results,1-0.html
« Reply #5 on: January 27, 2023, 11:23:55 am »
yes, my pagination is not working now.
please help me, how to resolved this problem of the canonical.

macigatto

  • Beginner
  • *
  • Posts: 18
  • A beginner
Re: VM 4 is adding to canonical this string pagination: results,1-0.html
« Reply #6 on: January 27, 2023, 13:50:57 pm »
I have resolved adding this line of code testing
if limit is != 0
this is preventing to have in url this results,1-0.html


else if ($limit !== null && $limit != vmrouterHelper::$limit ) {
               //for the urls of the list where the user sets the pagination size/limit
                   
                    if( $limit != 0)    //I HAVE ADDED THIS LINE
                    $segments[] = self::lang('results') .',1-'.$limit ;



please let me know if this is ok and if this is a VM bug resolved.

I have another question:
why some of my category page are paginated in URL by

?start=44

and others by

/results,45-44.html

??????

thanks

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10530
  • VM4.0.7 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: canonical is adding this string to my url results,1-0.html
« Reply #7 on: January 27, 2023, 20:32:31 pm »
my idea was to use instead
Code: [Select]
else if ($limit !== null &&
just
Code: [Select]
if (!empty($limit) &&
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

macigatto

  • Beginner
  • *
  • Posts: 18
  • A beginner
Re: canonical is adding this string to my url results,1-0.html
« Reply #8 on: Yesterday at 10:39:48 »
I have implemented with your code, and it is working fine.
Will this be a bug fixed in next VM realease?

thanks