name_based_urls

Open to all! Ask other shopowners for help.
loop
Contributor
Posts: 253
Joined: Thu Mar 25, 2021 12:26 pm
Phoenix Version:
Has thanked: 7 times
Been thanked: 3 times

name_based_urls

Post by loop »

Hi All
Everything works fine, the only thing the language is done with the session_id, and what i need for creating "alternate" urls in the <head> to link to the other language pages, so google know it's the same page in a other language
<link rel="alternate" hreflang="en" href="URL..." />
<link rel="alternate" hreflang="it" href="URL..." />

so i'm wondering how i can create the links in italian / english / german on the same page like this:
echo $GLOBALS['Linker']->build('product_info.php')->retain_query_except(['page','action','language','osCsid'])->set_parameter('language', 'fr');

but it does not work, as the language is from the session. Any ideas how i can achieve my goal to get the name based links in the languages i need?

maybe make a class extention which replace the function where it takes $_session['language'] and change it to the $_GET['language'] but at the moment i don't know exactly how to do this

thank you alot!
Last edited by loop on Wed Jul 13, 2022 8:02 pm, edited 1 time in total.


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: name_based_urls

Post by ecartz »

I don't believe that the version in Pro is multilingual. I think that you have to upgrade to the paid version for that. So for support for the multilingual version, I think that you need to contact Rainer directly.

If it works off the session language, you could potentially change the session language between each link. E.g.

Code: Select all

<?php
  $original_language = $_SESSION['language'];
  $_SESSION['language'] = 'english';
?>
<link rel="alternate" hreflang="en" href="URL..." />
<?php $_SESSION['language'] = 'italian';
<link rel="alternate" hreflang="it" href="URL..." />
<?php $_SESSION['language'] = $original_language; ?>
Or if it uses language_id, you could do much the same with that.

There may of course be a simpler way. Or someone could simply pay Rainer to make a proper alternate module and let him worry about how to make it work.
loop
Contributor
Posts: 253
Joined: Thu Mar 25, 2021 12:26 pm
Phoenix Version:
Has thanked: 7 times
Been thanked: 3 times

Re: name_based_urls

Post by loop »

Hi eCartz

thank you for your answer!
i already have the paid version, but i couldn't find the "paid forum" to ask.

i think the solution with change the session language probably works, but i think it's not so nice to change the variable for every link and in the end change it back to the real session language, i think it's a too ugly hack....hmmm
artfulweb
Contributor
Posts: 184
Joined: Thu Oct 29, 2020 12:34 pm
Phoenix Version: v1.1.0.6
Has thanked: 29 times
Been thanked: 14 times

Re: name_based_urls

Post by artfulweb »

loop wrote: Wed Jul 13, 2022 8:05 pm Hi eCartz

thank you for your answer!
i already have the paid version, but i couldn't find the "paid forum" to ask.

i think the solution with change the session language probably works, but i think it's not so nice to change the variable for every link and in the end change it back to the real session language, i think it's a too ugly hack....hmmm
Hi, Loop,
There is no "paid forum", you simply send a private message to the creator of the addon. Click on his username in the addon and you can PM him or send an email. He is really quick to respond.
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: name_based_urls

Post by lecarlb »

Hello,

I'm using the demo version on my 1.0.8.16 site and Google is giving an Alternate page with proper canonical tag error. I believe it's because either this addon or something else is attaching session id's and examples of (?products_id=231, ?cPath=3_7/, AND ?sort=2a&manufacturers_id=15) to the end of the url.

@ecartz do you think this issue is because it's the demo version or something else?
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: name_based_urls

Post by ecartz »

lecarlb wrote: Thu May 18, 2023 4:21 am to the end of the url.
Which URL? The canonical URLs should not have extra parameters attached to them like sessions or sorts.

If they do have extra parameters (sessions, sorts) with this add-on, then try turning the add-on off and seeing if that fixes them. If it does, then it's a bug in the add-on. Let Rainer know (or perhaps check if lacking canonical URL support is a known characteristic of the demo version). If they're still broken without the add-on, I'll try to look more into it this weekend.

Regardless, the regular, non-canonical URLs would be expected to have extra parameters. So long as the canonical URLs are correct, that shouldn't matter.
Omar_one
Senior Contributor
Posts: 679
Joined: Fri Oct 25, 2019 5:06 pm
Phoenix Version: v1.0.8.16
Has thanked: 100 times
Been thanked: 56 times

Re: name_based_urls

Post by Omar_one »

Hello,
any idea why I am getting blank admin page on 1.0.8.20 Pro with name_based_urls lite version

Code: Select all

PHP Notice:  Undefined index: Linker in /home/XXXX/public_html/test/includes/system/override/name_based_urls.php on line 100
PHP Fatal error:  Uncaught Error: Call to a member function get_prefix() on null in /home/XXXX/public_html/test/includes/system/override/name_based_urls.php:100
Stack trace:
#0 /home/XXXX/public_html/test/includes/system/override/name_based_urls.php(125): name_based_urls->__construct()
#1 /home/XXXX/public_html/test/includes/system/versioned/1.0.8.1/hooks.php(170): name_based_urls::listen_hrefLink(Array)
#2 /home/XXXX/public_html/test/includes/system/versioned/1.0.8.5/href.php(137): hooks->chain('hrefLink', Array)
#3 /home/XXXX/public_html/test/includes/system/versioned/1.0.8.5/href.php(142): Href->link()
#4 /home/XXXX/public_html/test/admin/includes/template_top.php(21): Href->__toString()
#5 /home/XXXX/public_html/test/admin/index.php(24): require('/home/XXXX/p...')
#6 {main}
  thrown in /home/XXXX/public_html/test/includes/system/override/name_based_urls.php on line 100
same error version updated from 1.0.8.19 and on clean version 1.0.8.20 ( on same databases from the updated one )

thank you in advance for your help
Omar
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: name_based_urls

Post by ecartz »

Omar_one wrote: Sun May 21, 2023 6:37 pm any idea why I am getting blank admin page on 1.0.8.20 Pro with name_based_urls lite version
It looks like something is trying to create a link before Linker exists. If you call it as

Code: Select all

Guarantor::ensure_global('Linker')->get_prefix
on line 100 that might fix it. You could also hunt down whatever is creating the link and move it lower in the code so it gets called later. That might mean moving it out of a constructor.
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: name_based_urls

Post by raiwa »

Tested with Phoenix 1.0.8.19 pro and confirmed the issue and the suggested fix.
I'll update all versions applying the fix.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: name_based_urls

Post by raiwa »

Just found that the above fix breaks the code on the public store side.
What works for me on both sides, is the following:

Code: Select all

    $this->base_url = isset($GLOBALS['Admin'])
                    ? Guarantor::ensure_global('Linker')->get_prefix
                    : $Linker->get_prefix();
Can you please confirm @ecartz , @Omar_one .
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply