• Home
  • Get help
  • Ask a question
Last post 2 hours 50 min ago
Posts last week 128
Average response time last week 28 min
All time posts 70381
All time tickets 10863
All time avg. posts per day 20

Helpdesk is open from Monday through Friday CET

Please create an (free) account to post any question in the support area.
Please check the development versions area. Look at the changelog, maybe your specific problem has been resolved already!
All tickets are private and they cannot be viewed by anyone. We have made public only a few tickets that we found helpful, after removing private information from them.

#8612 – Automatic setting Canonical page

Posted in ‘4SEO’
This is a public ticket. Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.
Friday, 25 March 2022 12:02 UTC
oesch-web-gmail-com

Hi
I'm looking for a automatic setting of canonical pages. 
There is an interesting API function: forseo_page_canonical_or_duplicate

I have written a php script to iterate throug phoca cart shop and set the canonical path. How can i add it automatically to all dublicates? May be with the API function above?

Can you shor give me an overvie how to do it or an code snippet?

Best Regards
Walter Oesch

Friday, 25 March 2022 13:03 UTC
wb_weeblr

Hi

I'm looking for a automatic setting of canonical pages. 

There is an interesting API function: forseo_page_canonical_or_duplicate

This does not serve this exact purpose, or rather is used later on in the process. Whether a page is canonical or not is identified by 4SEO by computing a "page_id". For instance, if you have 2 URLs to the same Joomla article with id=42:

index.php?option=com_content&view=article&id=42&Itemid=123

and

index.php?option=com_content&view=article&id=42&Itemid=456&catid=3

4SEO knows that for a Joomla article, in that case, Itemid and catid don't matter. It computes the page_id as option=com_content&view=article&id=42, and therefore one page will be the canonical and the other a duplicate. 

I think the ideal hook to use in your case would rather be: forseo_page_build_content_id. You use it by:

- creating/opening this file: /libraries/weeblr/forseo_functions.php

- it should start with:

          return $id;
}
$view = $pageData->get('view');
$id = $pageData->get('id');
$Itemid = $pageData->get('Itemid');

// extract here other variables from the $pageData object as needed.
// The $id is actually an array of variables.
// To removed something from the id, unset the variable:
if(some_condition) {
unset($id['Itemid'];
} return $id;
}
);

 This is just the basic to get you started. I can't provide custom programming as part of support but hopefully you can make sense of it.

The global idea is that if 2 pages are for the same product, they should have the same page_id. IF you manage that, then 4SEO will take it from there and all the rest will work, including adding the canonical, excluding from the sitemap, etc

So what you need to find is why Phoca cart is having multiple URLs to the same product (a product can be in 2 categories for instance?) and translate that into that page_id.

Note that after you made any change here, you must Reset the analysis so that this new function is taken into account.

Best regards

Yannick Gaultier

weeblr.com / @weeblr

 

 

 
Monday, 25 April 2022 05:34 UTC
system
This ticket has been automatically closed. All tickets which have been inactive for a long time are automatically closed. If you believe that this ticket was closed in error, please contact us.
This ticket is closed, therefore read-only. You can no longer reply to it. If you need to provide more information, please open a new ticket and mention this ticket's number.