name_based_urls

Open to all! Ask other shopowners for help.
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 »

raiwa wrote: Mon May 22, 2023 10:43 am 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 .
fix confirm for admin side
now the shop side not working blank page


Join The Code Co-op to get access to your library in the Code Co-op Forum
raiwa
Certified Developer
Posts: 1641
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 »

For me it works.
Can you post the error log please.
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
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 »

Code: Select all

HP Notice:  Undefined variable: Linker in /home/XXXX/public_html/test/includes/system/override/name_based_urls.php on line 103
[22-May-2023 14:54:43 Europe/Helsinki] 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:103
Stack trace:
#0 /home/XXXX/public_html/test/includes/system/override/name_based_urls.php(128): name_based_urls->__construct()
#1 /home/XXXX/public_html/test/includes/system/versioned/1.0.8.1/hooks.php(166): 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/includes/modules/boxes/bm_languages.php(36): Href->__toString()
#5 /home/XXXX/public_html/test/includes/system/versioned/1.0.8.4/template.php(79): bm_languages->execute()
#6 /home/XXXX/public_html/test/templates/default/in in /home/XXXX/public_html/test/includes/system/override/name_based_urls.php on line 103
the line 31-39 from bm_languages.php

Code: Select all

$languages_string = '';
        foreach ($lng->catalog_languages as $key => $value) {
          $image = Text::ltrim_once(
            language::map_to_translation("images/{$value['image']}", $value['directory']),
            DIR_FS_CATALOG);
          $languages_string .= ' <a href="' . $link->set_parameter('language', $key) . '">'
                             . (new Image($image, [], htmlspecialchars($value['name'])))->set_responsive(false)
                             . '</a> ';
        }
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 »

uninstall the box modules not helping new error (ht_canonical.php)

Code: Select all

PHP Notice:  Undefined variable: Linker in /home/XXXX/public_html/test/includes/system/override/name_based_urls.php on line 103
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:103
Stack trace:
#0 /home/XXXX/public_html/test/includes/system/override/name_based_urls.php(128): name_based_urls->__construct()
#1 /home/XXXX/public_html/test/includes/system/versioned/1.0.8.1/hooks.php(166): 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/includes/modules/header_tags/ht_canonical.php(50): Href->__toString()
#5 /home/XXXX/public_html/test/includes/system/versioned/1.0.8.4/template.php(79): ht_canonical->execute()
#6 /home/XXXX/public_html/test/templates/defa in /home/XXXX/public_html/test/includes/system/override/name_based_urls.php on line 103
raiwa
Certified Developer
Posts: 1641
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 »

It seems you have not the latest version.
Can you please try with this package:
Name_Based_URLs_Lite.zip
You do not have the required permissions to view the files attached to this post.
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
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 »

raiwa wrote: Mon May 22, 2023 12:10 pm It seems you have not the latest version.
Can you please try with this package:
Name_Based_URLs_Lite.zip
I am using the module which comes with 1.0.8.20 PRO...
the version which you post it above fix the issue ..^

thank you
raiwa
Certified Developer
Posts: 1641
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 »

@Omar_one Just checked and this fix breaks the xml sitemaps.
@ecartz it seems we need another solution for this maybe(untested):

Code: Select all

     $this->base_url = isset($Linker->get_prefix())?$Linker->get_prefix():Guarantor::ensure_global('Linker')->get_prefix;
or:
ecartz wrote: Sun May 21, 2023 11:13 pm 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.
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: 1641
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 »

@ecartz , @Omar_one
O.K. I tested it now for all cases:
- Admin side if a link is placed in a module/class constructor
- Shop side
- XML sitemap generator

and the following snippet works:

Code: Select all

    $this->base_url = null !== $Linker->get_prefix()
                      ? $Linker->get_prefix()
                      : Guarantor::ensure_global('Linker')->get_prefix;
Updated and included in the following Name Based URLs Lite package:
Name_Based_URLs_Lite.zip
You do not have the required permissions to view the files attached to this post.
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
14Steve14
Senior Contributor
Posts: 923
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Re: name_based_urls

Post by 14Steve14 »

raiwa wrote: Tue May 23, 2023 6:50 am @ecartz , @Omar_one
O.K. I tested it now for all cases:
- Admin side if a link is placed in a module/class constructor
- Shop side
- XML sitemap generator

and the following snippet works:

Code: Select all

    $this->base_url = null !== $Linker->get_prefix()
                      ? $Linker->get_prefix()
                      : Guarantor::ensure_global('Linker')->get_prefix;
Updated and included in the following Name Based URLs Lite package:
Name_Based_URLs_Lite.zip
I can confirm that adding this version removed the error of a blank admin page that was present when using the version in the 1.0.8.20 package.
14Steve14
Senior Contributor
Posts: 923
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Re: name_based_urls

Post by 14Steve14 »

Using name based urls lite which is supplied with supports code on a phoenix 1.0.9.0. test store on php8

@raiwa I am getting the following error in the error logs.
[20-Jul-2024 16:04:47 Europe/London] PHP Warning: Undefined array key 1 in /home/####/####/includes/system/override/name_based_urls.php on line 832
Line 832 is the blank line between the following lines of code

Code: Select all

    $url = $this->href_link($this->uri_parsed['path'], $params);

    switch(true){
Is there a fix that I have not seen.


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