global linker class ... add callback to get url/seo rewrite working

Ask the community for help and support.
philpla
Posts: 27
Joined: Sun Feb 28, 2021 8:37 am
Has thanked: 2 times
Been thanked: 1 time

global linker class ... add callback to get url/seo rewrite working

Post by philpla »

hi,

Would it be possible to add some kind of callback to the linker class, so that one could use it to rewrite hrefs for SEO/url rewrite?

thx phil.
burt
Lead Developer
Lead Developer
Posts: 2423
Joined: Tue Oct 29, 2019 9:37 am
Has thanked: 49 times
Been thanked: 137 times

Re: global linker class ... add callback to get url/seo rewrite working

Post by burt »

Thanks to @ecartz, it is already possible to change this area of Phoenix up to do pretty much whatever you wish. See the following references:

https://github.com/CE-PhoenixCart/Phoen ... .sql#L1112
https://github.com/CE-PhoenixCart/Phoen ... 5/href.php

This code has been in Phoenix for quite a long time, but remains relatively unexplored...

It's really important to be aware that changing href links etc can have a substantial (and long lasting, potentially negative if it goes wrong) impact on such things as SEO (Search Engine Optimisation) etc, so it could be a good idea to not only explore your own ideas for this area but also maybe to call in expert help from out Certified Developers if it turns out that this is something that out of reach for DIY...

app.php/developers

Whichever way you go, be sure to make any changes on a test shop so that you can test and test and test again prior to putting any changes on your live shop.
Gamechanger Addon: Queued Emails, try before you buy.
Piernas
Posts: 96
Joined: Thu Mar 11, 2021 2:16 am
Has thanked: 2 times
Been thanked: 4 times

Re: global linker class ... add callback to get url/seo rewrite working

Post by Piernas »

Hello @burt ,

I have been asked to update Ultimate Seo Addon for current release. I stopped doing this about 1.0.8.4 because there were imortant changes that broke backwars compatibility with tep_href_link, especially the way product_info pages are now generated in two steps from products class (first a link to the file itself and then adding the products part with linker) so that involves modifying several classes. It would be of help knowing what's the purpose of handling product_info links in two steps instead of one for not clashing with other addons that use this process, and also if that mechanism is already definitive or there will be substantial changes.
philpla
Posts: 27
Joined: Sun Feb 28, 2021 8:37 am
Has thanked: 2 times
Been thanked: 1 time

Re: global linker class ... add callback to get url/seo rewrite working

Post by philpla »

@burt thx for the reply

Do you see an easier way, as the one mention by @Piernas?

And of course: Would this be stable for the upcoming versions?
radhavallabh
VIP Member
VIP Member
Posts: 364
Joined: Tue Oct 27, 2020 4:09 am
Has thanked: 23 times
Been thanked: 1 time

Re: global linker class ... add callback to get url/seo rewrite working

Post by radhavallabh »

Piernas wrote: Tue Apr 26, 2022 7:10 am Hello @burt ,

I have been asked to update Ultimate Seo Addon for current release. I stopped doing this about 1.0.8.4 because there were imortant changes that broke backwards compatibility with tep_href_link, especially the way product_info pages are now generated in two steps from products class (first a link to the file itself and then adding the products part with linker) so that involves modifying several classes. It would be of help knowing what's the purpose of handling product_info links in two steps instead of one for not clashing with other addons that use this process, and also if that mechanism is already definitive or there will be substantial changes.
Hi dear @ecartz and @burt , please could you clarify this to dear @Piernas by PM or here so that this wonderful addon at

app.php/addons/free_addon/ultimate_seo_urls/
could be updated for the whole Phoenix community....

@Piernas has been waiting for the reply since long....

Thank you very much in advance;
Very Warm Regds.
radhavallabh
burt
Lead Developer
Lead Developer
Posts: 2423
Joined: Tue Oct 29, 2019 9:37 am
Has thanked: 49 times
Been thanked: 137 times

Re: global linker class ... add callback to get url/seo rewrite working

Post by burt »

It would not be a good idea to wait for core code to settle down and never change before coding something. If some member of the community wants to make something very cool, they could do so for X.x.y.z version and then stop there - there is no onus on them to continue to keep on coding as core evolves and gets better.

One of the main reasons we have a VIP area is for those who are asking technical questions, to get more in-depth help from core code developers and from certified developers - it's a bonus of being a VIP.

Asking questions in the Open Community area is fine too, and you may get answers or idea from other community members. Just be aware that you are not being ignored (everyone has to apportion their time as best they can) and that sometimes if you don't get an answer, it may be one of those questions where it is better asked elsewhere.

We were sort of hoping that the Community would be helping each other in this area of the forum, without the input of (very time limited) developers.
Gamechanger Addon: Queued Emails, try before you buy.
burt
Lead Developer
Lead Developer
Posts: 2423
Joined: Tue Oct 29, 2019 9:37 am
Has thanked: 49 times
Been thanked: 137 times

Re: global linker class ... add callback to get url/seo rewrite working

Post by burt »

As a side note, do note that I have been working on a system of URLs but it's going nowhere at the moment due to that limitation of time.

phoenixcart.org/green-apple (instead of eg https://phoenixcart.org/demo/product_in ... ducts_id=7 )
Link does not work, it just gives the idea/basis for the code I was working on 18 months ago.

Well, anyway, I hope this last two posts helps a bit.
Gamechanger Addon: Queued Emails, try before you buy.
Omar_one
VIP Member
VIP Member
Posts: 481
Joined: Fri Oct 25, 2019 5:06 pm
Has thanked: 48 times
Been thanked: 27 times

Re: global linker class ... add callback to get url/seo rewrite working

Post by Omar_one »

@burt I am with you by this ,, but as we are using this module in all versions what we used so almost for 12 yeas ,, and we are planning to to live with phoenix before June, what will happened with all google indexs , seo ,etc..?
burt
Lead Developer
Lead Developer
Posts: 2423
Joined: Tue Oct 29, 2019 9:37 am
Has thanked: 49 times
Been thanked: 137 times

Re: global linker class ... add callback to get url/seo rewrite working

Post by burt »

I don't know. I've never used this code.

Rightly or wrongly, my feeling is that if something gets abandoned by the original maker, then the code should be considered buried. If someone else takes it over who is able to code then that is great and helpful.

Open source coding is very different to any other type of coding.
Gamechanger Addon: Queued Emails, try before you buy.
ecartz
Lead Developer
Lead Developer
Posts: 2637
Joined: Tue Nov 05, 2019 6:02 pm
Has thanked: 4 times
Been thanked: 181 times

Re: global linker class ... add callback to get url/seo rewrite working

Post by ecartz »

Piernas wrote: Tue Apr 26, 2022 7:10 am I have been asked to update Ultimate Seo Addon for current release. I stopped doing this about 1.0.8.4 because there were imortant changes that broke backwars compatibility with tep_href_link, especially the way product_info pages are now generated in two steps from products class (first a link to the file itself and then adding the products part with linker) so that involves modifying several classes. It would be of help knowing what's the purpose of handling product_info links in two steps instead of one for not clashing with other addons that use this process, and also if that mechanism is already definitive or there will be substantial changes.
I would prefer that all product links look the same, so I would prefer to centralize the link as much as possible. https://github.com/CE-PhoenixCart/Phoen ... p#L25..L37

However, that only works when a Product object exists. Since there remain situations where one doesn't but a link is still desirable, that's probably not a good place to change how links are created.

I'm not clear on why you are focused on Linker, as that's just a helper class to save having to write

Code: Select all

$href = new Href($url_prefix, ...$other_arguments);
every time one wants to make a link. As Burt already posted, there is already a hook that is called immediately before an Href is converted into a string. That hook has to be invoked before a link can be used, as an Href object cannot be displayed without first converting it to a string. That hook has the Href object and its string representation as parameters.

With the Href object, you should be able to rebuild the link in whatever format is desired. You could even remove the existing database hook listener and replace it with your own. I am absolutely befuddled at the claim that you'd have to modify any core code in order to implement a URL rewriter. I rather think that it should be as simple as writing a single adapter method (as a hook listener) that calls Chemo's existing URL rewrite class when needed or Href->real_link when not. That method could replace the existing database hook listener.

In terms of stability, the hook was added in 1.0.8.1 and hasn't changed since. I have no plans to make additional changes. Might it change in the future? Sure. For one thing, since no one is currently using it, we might find out that there was a problem that required a change. That happened with the filter hook. But in core, everything seems to be working as desired.

The tep_href_link function itself will disappear in the 1.0.9.* series. Most of what I've been doing since 1.0.8.3 has been going through files and replacing calls to the legacy functions like that. But since tep_href_link calls Href, if people migrate to Href, it shouldn't matter when tep_href_link actually goes away.
Post Reply