• Home
  • Get help
  • Ask a question

Reduced schedule during conference and annual break

We'll be operating with a reduced schedule from tomorrow and the next few weeks, as follows:

We'll be travelling and attending JoomlaDay USA from Tuesday April 22 to Friday April 25. Support will have extended response time during this period. From April 25 evening to Tuesday May 12 included, support will be closed for our annual break.

Don't forget to look up the documentation, including the videos, your answer may already be there! Likewise, be sure to check the Development versions area, in case your problem may already have been solved.

In case of emergency (ie your site is down with a fatal error directly linked to one of our extensions), please contact us by email (see contact icon at the bottom of all pages of this site)

#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.