Jump to content
FWR Media

ULTIMATE Seo Urls 5 - by FWR Media

Recommended Posts

On 9/18/2020 at 10:31 AM, ecartz said:

If it's that there is code that you used to add immediately after the language code, then you can just move it into the i() function.  Change


     if ( !self::$_singleton instanceof Usu_Main ) {
       self::$_singleton = new self;
     }

 

Hi @ecartz,

I finally got a free day to check this contribution. I found your solution will not work because Usu_main has to be initialized after set_session_language and before ensure_navigation_history to work. If not, links are correctly generated but $_GET variable is not updated and Phoenix redirects to index in all pages that expects parameters, like product_info.

I found its code could be placed in application.php inside the set_session_language function, or it could be loaded by creating an entry inside hooks table between those two functions (an startApplication method). But as far as I see it implies giving a non-consecutive numerical sort order to the table entry (something like _16B_start_SEO ) and it seems a bit dirty to me.

Is there a cleaner way to do it?

Another thing: I've seen fix_numeric_locale is being called twice (from a hook and inside set_session_language function. Is this needed or has the function call just been forgotten?

Files outside ROOT seems to work now; I'm into fixing the ENABLE_SSL stuff. Is there any post where the changes introduced has been explained?

 

Share this post


Link to post
Share on other sites

I think that a "non-consecutive numerical sort order" is probably the best solution.  Note that it doesn't need to be a database entry.  A hook file in includes/hooks/system would work as well. 

The closest thing to documentation is the commit notes (and the commit itself):  https://github.com/gburton/CE-Phoenix/commit/ae01e0d4d91b2e4a561735168ef4fbe6ba8e6899

Related commit:  https://github.com/gburton/CE-Phoenix/commit/d2adabebe2efbdcd28513c6057758cd25ed48fc4

I don't think that it is very complicated.  HTTP_SERVER . DIR_WS_CATALOG should always be used now, where previously it was only sometimes used (in the ENABLE_SSL false case).  For the most part, this is just simpler.  Because instead of having to check various things to determine the correct link, the code can just consistently use one thing.  The old system was complicated, as it had to try to mix SSL and non-SSL pages.  But this always uses whatever the HTTP_SERVER is configured to provide. 


Always back up before making changes.

Share this post


Link to post
Share on other sites
11 hours ago, piernas said:

That's correct for other SEO contribution. This is Ultimate SEO 5 and it's different, it needs a lot more tweaks.

I wonder if the contribution name should be changed to avoid this kind of confusions.

So is it being developed for 1.0.7.9? That will be so cool dear.. 🤩

Share this post


Link to post
Share on other sites

Hi @ecartz,

I've found an issue with a core module (nb_shopping_cart.php).

For constructing the URI the module uses this code:

// nb_shopping_cart.php (line 19):

  echo sprintf(MODULE_NAVBAR_SHOPPING_CART_PRODUCT, $p['id'], $p['quantity'], $p['name']);

// languages/english/modules/navbar/nb_shopping_cart.php:

  define('MODULE_NAVBAR_SHOPPING_CART_PRODUCT', '<a class="dropdown-item" href="' . tep_href_link('product_info.php', 'products_id=%s') . '">%s x %s</a>');

This means tep_href_link is called by the define before executing the sprintf command, so the llink is created literally as product_info.php?products_id=%s, avoiding the URL rewriter to be able to parse it correctly.

To make it work code should at least generate the real link in the module itself instead of the language file:

// language file:
  define('MODULE_NAVBAR_SHOPPING_CART_PRODUCT', '<a class="dropdown-item" href="%s">%s x %s</a>');


// module:
        echo sprintf(MODULE_NAVBAR_SHOPPING_CART_PRODUCT, tep_href_link('product_info.php', 'products_id=' .$p['id'] ), $p['quantity'], $p['name']);

or even more logical and simpler:

// Module:

  echo '<a class="dropdown-item" href="' . tep_href_link("product_info.php", 'products_id=' .$p['id']) .  ' ">' . sprintf (MODULE_NAVBAR_SHOPPING_CART_PRODUCT, $p['quantity'], $p['name']) . "</a>'";

// Language file:
  define('MODULE_NAVBAR_SHOPPING_CART_PRODUCT', '%s x %s');

I'll still have to figure out how to modify this app to parse links with {X}Y after the product id.

 

Edited by piernas

Share this post


Link to post
Share on other sites

I've almost finished this app. Still want to make a couple of tweaks and add proper instructions but all seems to work well. I've attached it in case someone wants to test it.

No core changes, tested with Phoenix 1.0.7.10. Just upload the files and go to admin->configuration->Ultimate Seo Urls and enable the app. Feedback will be appreciated.

USU3_beta.zip

Share this post


Link to post
Share on other sites
9 minutes ago, piernas said:

I've almost finished this app. Still want to make a couple of tweaks and add proper instructions but all seems to work well. I've attached it in case someone wants to test it.

No core changes, tested with Phoenix 1.0.7.10. Just upload the files and go to admin->configuration->Ultimate Seo Urls and enable the app. Feedback will be appreciated.

USU3_beta.zip

Notice: Undefined index: languages_id in C:\xampp\htdocs\test1711\includes\classes\usu_init.php on line 21
Notice: Undefined index: language in C:\xampp\htdocs\test1711\includes\classes\usu_init.php on line 22
Notice: Undefined variable: current_code in C:\xampp\htdocs\test1711\includes\apps\ultimate_seo_urls\main\bootstrap.php on line 376

the errors will disappear after refreshing the site ...
there is core file will overwrite  ht_canonical.php , I think it was forgotten there as there is no changes in it (same as core file)

well done 


Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites
2 minutes ago, Omar_one said:

Notice: Undefined index: languages_id in C:\xampp\htdocs\test1711\includes\classes\usu_init.php on line 21
Notice: Undefined index: language in C:\xampp\htdocs\test1711\includes\classes\usu_init.php on line 22
Notice: Undefined variable: current_code in C:\xampp\htdocs\test1711\includes\apps\ultimate_seo_urls\main\bootstrap.php on line 376

the errors will disappear after refreshing the site ...
there is core file will overwrite  ht_canonical.php , I think it was forgotten there as there is no changes in it (same as core file)

well done 

Thank you, I'll take a look at those errors. Does the app work?

Share this post


Link to post
Share on other sites

@piernas  It seems to working well (Phoenix 1.0.7.11) 👍

Edited by Omar_one

Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites

@omar the new ht_canonical should be slightly different. It adds canonical tags to write review (review.php) that is currently rewritten to review.html. It's not important as this page should not be indexed by spiders but I think I should also add it to noindex pages.

I want to study the new pages system to see if it's good to add rewrite rules to it, too, so / info.php?pages_id=4 would become /slug.html

 

 

Share this post


Link to post
Share on other sites

@piernas I just compare the ht_canonical from your zip file with ht_canonical from Phoenix 1.0.7.11 they are same 

image.thumb.png.447f71f6678785354311a6fffe6e38c5.png
 

10 hours ago, piernas said:

I want to study the new pages system to see if it's good to add rewrite rules to it, too, so / info.php?pages_id=4 would become /slug.html

👍


Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites
1 hour ago, Omar_one said:

@piernas I just compare the ht_canonical from your zip file with ht_canonical from Phoenix 1.0.7.11 they are same

Thank you, then I uploaded the stock one. It should contain these lines, I'll fix it on the final upload:

 

        case 'write.php':
          $oscTemplate->addBlock('<link rel="canonical" href="' . tep_href_link($PHP_SELF, 'products_id=' . (int)$_GET['products_id'], 'SSL', false) . '" />' . PHP_EOL, $this->group);
        break;

 

Share this post


Link to post
Share on other sites
On 12/1/2020 at 8:42 PM, piernas said:

I've almost finished this app. Still want to make a couple of tweaks and add proper instructions but all seems to work well. I've attached it in case someone wants to test it.

No core changes, tested with Phoenix 1.0.7.10. Just upload the files and go to admin->configuration->Ultimate Seo Urls and enable the app. Feedback will be appreciated.

USU3_beta.zip

Hi,

Is this version compatible with Phoenix 1.0.7.12. is it possible to make clearer installation instructions pls.

 Tried this with not much luck https://apps.oscommerce.com/36rDo&amp;ultimate-seo-urls.

Thanks,

Share this post


Link to post
Share on other sites

Final version for CE Phoenix 1.0.7.10+ attached. I will open a new topic (this one is very old and almost nothing relates to the currrent app due to the huge amount of changes and fixes). I will upload it to the addons page soon, too.

I didn't receive any feedback other than from @Omar_one. Does nobody consider this app of interest anymore?

@zeeshop yes it works on phoenix  1.0.7.12. Please download new package attached and see the readme included for instructions.

Ultimate_SEO_Urls v3.0.0.zip

Share this post


Link to post
Share on other sites

Hi piernas

Glad you are still improving and updating this addon, for people like me who have very old URLS and do not want to lose the history of the links its very important.

Has X-default in the Hreflang alternate language been addressed yet

If I have understood it correct its just the fallback language of the page, for example my site is in english, most of the world is in english, I have a a alternate lang in FR there should also be a x-default alternate on all pages including the FR ones to the English

should be a easy thing to have as all the data is on the page in USU5, just wish I knew how to do it. somewhere around here

        $alternate .= '<link rel="alternate" hreflang="' . $code . '" href="' . $this_link . '" />' . PHP_EOL;
        if ( $data['directory'] != $this->language ) {
        $links_icons .= ' <a href="' . $this_link . '">' . tep_image($language_image_path, $data['name'], NULL, NULL, NULL, false) . '</a>';
        $links_list .= '<a class="dropdown-item" href="' . $this_link . '">' . tep_image($language_image_path, $data['name'], NULL, NULL, NULL, false) . '&nbsp;' . LANGUAGES_CHANGE_TO . "&nbsp;" . $data['name'] . '</a>' . PHP_EOL;
        }
      }

David

 


David

Share this post


Link to post
Share on other sites
8 hours ago, DAVID3733 said:

If I have understood it correct its just the fallback language of the page, for example my site is in english, most of the world is in english, I have a a alternate lang in FR there should also be a x-default alternate on all pages including the FR ones to the English
 

Hi David, I dodn't know about that tag - I'll add it in the future once the app has been tested.

Share this post


Link to post
Share on other sites
2 hours ago, piernas said:

Hi David, I dodn't know about that tag - I'll add it in the future once the app has been tested.

If you can tell me how to add it to the previous version below I can let you know in a few weeks if it works and gets listed for Goggle as I have thousands of pages listed as alternatives, en and FR already in google and have for at least a year, just not X-default🙂

 

 

<?php

  class FWR_hreflang {

    protected $page;
    protected $mode;
    protected $get;
    protected $lng;
    protected $language;
    protected $root_path;
    protected $language_image_width = '24';
    protected $language_image_height = '15';
    protected $session_started;
    protected $language_code_array = array();
    protected $links_icons;
    protected $links_list;
    protected $alternate_hreflang;
    protected $lang_array;

    public function __construct( navigationHistory $navigation, $language, $lng = false, $session_started = false ) {
      require(DIR_FS_CATALOG . 'includes/languages/' . $language . '/hreflang.php');
      $navigation_data = array_pop( $navigation->path );
      $this->page = $navigation_data['page'];
      $this->mode = $navigation_data['mode'];
      $this->get =  $navigation_data['get'];
      $this->setLanguage( $lng );
      $this->language = $language;
      $this->root_path = realpath( dirname( __FILE__ ) . '/../../' ) . '/';
      $this->session_started = $session_started;
      $this->getLanguageSelectionHtml();
    }

    // Returns an unordered list of links to the
    public function __toString() {
      return $this->links_icons;
    }
    // Returns an array containing data of all alternate languages (other than current language)
    public function lang_array() {
      return $this->lang_array;
    }
    // Returns an array containing data of all alternate languages (other than current language)
    public function links_list() {
      return $this->links_list;
    }
    public function hreflang_tags() {
    // Returns a string containing all the hreflang tags pertinent to this page (other than current language)
      return $this->alternate_hreflang;
    }

    protected function setLanguage( $lng ) {
      if ( ( false === $lng ) || ( !$lng instanceof language ) ) {
        include_once 'includes/classes/language.php';
        $this->lng = new language();
        $this->setLanguageArray();
        return $this->lng;
      }
      $this->lng = $lng;
      $this->setLanguageArray();
    }

    protected function setLanguageArray() {
      foreach ( $this->lng->catalog_languages as $code => $unused ) {
        $this->language_code_array[] = $code;
      }
    }

    protected function getLanguageSelectionHtml() {
      global $languages_id,$language;
      $alternate = $links_icons = $links_list = "";
      $output = '<ul style="list-style-type:none; padding:0; margin:0;">';
      foreach ( $this->lng->catalog_languages as $code => $data ) {

        // Sets USU language to the current selection
        Usu_Main::i()->initiate( array(), $data['id'],  $data['directory'], true );

        $language_image_path = 'includes/languages/' . $data['directory'] . '/images/icon.gif';

        $this_link = $this->buildLink( $default = ( $code === DEFAULT_LANGUAGE ), $code );

        $hr [$data['id']]['id']=$data['id'];
        $hr [$data['id']]['name']=$data['name'];
        $hr [$data['id']]['image']=$data['image'];
        $hr [$data['id']]['directory']=$data['directory'];
        $hr [$data['id']]['href']=$this_link ;

        $alternate .= '<link rel="alternate" hreflang="' . $code . '" href="' . $this_link . '" />' . PHP_EOL;
        if ( $data['directory'] != $this->language ) {
        $links_icons .= ' <a href="' . $this_link . '">' . tep_image($language_image_path, $data['name'], NULL, NULL, NULL, false) . '</a>';
        $links_list .= '<a class="dropdown-item" href="' . $this_link . '">' . tep_image($language_image_path, $data['name'], NULL, NULL, NULL, false) . '&nbsp;' . LANGUAGES_CHANGE_TO . "&nbsp;" . $data['name'] . '</a>' . PHP_EOL;
        }
      }
      $this->links_list = $links_list;
      $this->links_icons = $links_icons;
      $this->alternate_hreflang = $alternate;
      $this->lang_array =$hr;
        // Resets USU language to the current language for the rest of the links on the page
      Usu_Main::i()->initiate( array(), $languages_id, $language, true );
    }

    protected function buildLink($default = false, $code ) {
      if ( false === $this->session_started ) {
      //  return  $this->multiLanguage( tep_href_link( 'index.php', '', 'NONSSL' ), $default, $code );
      }
      $curlink = tep_href_link ($this->page, $this->getQuery(), $this->mode, true, false, $code);
      return $this->multiLanguage( $curlink , $default, $code );
    }

    protected function getQuery() {
      if ( tep_not_null( $this->get ) ) {
        if ( array_key_exists( tep_session_name(), $this->get ) ) {
          unset( $this->get[tep_session_name()] );
        }
        return http_build_query( $this->get );
      }
      return '';
    }

    protected function removeQueryString( $target ) {
      if ( false === strpos( $target, '?' ) ) {
        return $target;
      }
      return substr( $target, 0, strpos( $target, '?' ) );
    }

    protected function removeLanguageMarkers( $target, $cookie_path ) {
      $return = preg_replace( '@' . $cookie_path . '(' . implode( '|', $this->language_code_array ) . ')/@', $cookie_path, $target );
      $return = preg_replace( '@' . $this->page . '/(' . implode( '|', $this->language_code_array ) . ')@', $this->page, $return );
      return $return;
    }

    protected function multiLanguage( $link, $default, $code ) {
      $server = ( $this->mode == 'NONSSL' ) ? HTTP_SERVER : HTTPS_SERVER;
      $cookie_path = ( $this->mode == 'NONSSL' ) ? HTTP_COOKIE_PATH : HTTPS_COOKIE_PATH;
      $server = $server . $cookie_path;
      $link = $this->removeLanguageMarkers( $link, $cookie_path );
      if ( false !== $default ) {
        $no_querystring = $this->removeQueryString( $link );
        // Is the page FILENAME_DEFAULT and after the querystring is removed is FILENAME_DEFAULT the ending characters of the URL, if so we chop it off leaving just the domain
        if ( ( $this->page == 'index.php' ) && ( substr( $no_querystring, ( strlen( $no_querystring ) - strlen( $this->page ) ), strlen( $no_querystring ) ) == $this->page ) ) {
          return str_replace( $this->page, '', $link );
        }
        return $link;
      }
      // If the .php filename is present in the link
      if ( false !== strpos( $link, $this->page ) ) {
        return str_replace( $this-> page, $this->page . '/' . $code, $link );
      }
      return str_replace( $server, $server . $code . '/', $link );
    }

  }

 


David

Share this post


Link to post
Share on other sites
20 hours ago, DAVID3733 said:

If you can tell me how to add it to the previous version below I can let you know in a few weeks if it works and gets listed for Goggle as I have thousands of pages listed as alternatives, en and FR already in google and have for at least a year, just not X-default🙂

Yes you'll just have to add it to the $alternate variable.

Share this post


Link to post
Share on other sites

Hi

Yes I thought it would be easy, unfortunately I am not a coder, not even close

looking at the page it appears to be able to get the EN and FR URL, this is so it can get the alternate lang for the HrefLang

But if I understand  the X-Default correct requirement right, in my case I want to tell Google that my fallback language is English

Although I am unable to read the code properly on the code I would imagine the Lang Variable on the page is indeed for the Language its on then swaps over to the other Lang for both languages

so it probably could not slip straight into the existing variable

I am sure this could be hardcoded something like   <link rel="alternate" href="https://www. websitepage_I_am_on_now.com(English)/" hreflang="x-default" />

as it only needs to be one language, the fall back one, 

But like I say no coder so do not know how to move forward

 

 


David

Share this post


Link to post
Share on other sites

I don't have a frozen test site anymore and I changed the code for phoenix, so can't do that for now. I'll do once I finish other work in progress; anyway I found google defaults to english if x-default is not set so your site should be indexed already.

Share this post


Link to post
Share on other sites

Hello @piernas

Happy new year, to you and the whole Oscommerce/Phoenix family. 

Thank you so so much for this add on. It is a major one, and many people were expecting it.

I stopped updating my Phoenix at 1.0.7.3 due to the absence of this mod update. Do you think I can install it on my current version, or I should upgrade before? 

Thanks

Share this post


Link to post
Share on other sites

Hi @piernas

I updated to 1.0.7.12 and installed the addon, and keep getting this error: 

Fatal error: Uncaught Error: Class 'usu_Main' not found in /home/XXXXX/XXXXXt/includes/classes/usu_init.php:16 Stack trace: #0 /home/XXXXX/XXXXX/includes/system/versioned/1.0.7.4/hooks.php(161): usu_init->i(Array) #1 /XXXXX/XXXXX/XXXXX/includes/application_top.php(33): hooks->generate('system', 'startApplicatio...') #2 /XXXXX/XXXXX/XXXXX/index.php(13): require('/XXXXX/XXXXX/...') #3 {main} thrown in /home/babouche/test/includes/classes/usu_init.php on line 16

Share this post


Link to post
Share on other sites

I tried to update from a previous version and ended up with:
Fatal error: Class 'Usu_Main' not found in /home2/cash/public_html/includes/application_top.php on line 349

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×