Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

ULTIMATE Seo Urls 5 - by FWR Media


Recommended Posts

hi

 

i been trying to use the dev module to create a module for extra_info_pages contrib.

 

instead of the name of the page title in addres bar i am getting..

 

http://www.mysite.com/-q-15.html .. the page title is Shipping & Returns.

 

here is the code of what i have done.

 

 

I know i missing something but dont know what.if any body ahs an idea please do let me know.

 

regards

 

nafri

 

Good effort but the file had a few "issues" .. try this ..

 

<?php
/**
*
* ULTIMATE Seo Urls 5
*
* 
* @package Ultimate Seo Urls 5
* @license http://www.opensource.org/licenses/gpl-2.0.php GNU Public License
* @link http://www.fwrmedia.co.uk
* @copyright Copyright 2008-2009 FWR Media
* @copyright Portions Copyright 2005 Bobby Easland
* @author Robert Fisher, FWR Media, http://www.fwrmedia.co.uk 
* @lastdev $Author:: Rob                                              $:  Author of last commit
* @lastmod $Date:: 2009-11-29 11:13:08 +0000 (Sun, 29 Nov 2009)       $:  Date of last commit
* @version $Rev:: 105                                                 $:  Revision of last commit
* @Id $Id:: Usu_Information.php 105 2009-11-29 11:13:08Z Rob          $:  Full Details   
*/

class Usu_Extra_Info_Pages extends aDataMap {

 const MARKER = '-q-';  // Could for example be -c- or -l- etc.
 const DEPENDENCY = 'pages_id'; // _GET key like e.g. cPath or lPath etc.
 const FILENAME = 'extra_info_pages.php'; // The filename define of the file where this code will be actioned
 public $dependency = self::DEPENDENCY;
 public $dependency_tags = array( self::MARKER => self::FILENAME ); // key value pair of tag (like e.g. -c-) => filename ( e.g. FILENAME_DEFAULT )
 private $page_relations = array( self::FILENAME => 1 ); // Page relation for this module ( e.g. FILENAME_DEFAULT or FILENAME_LINKS )
 private $markers = array( self::MARKER => self::DEPENDENCY ); // Markers as key value pair like -c- => cPath or perhaps -l- => lPath
 private $base_query; // Template query with placeholders ( :placeholder ) waiting for real values
 private $query; // The final query which will be $base_query but with the placeholders replaced with real values
 private $pages_title; // property populated in the acquire() method, there may be multiples of these, rename in line with the query results
 private $dependency_value; // Dependency value, so if the dependency was cPath and cPath = 27 then this value would be 27
 private $installed = false; // Unless it is a core module $installed should only be true if the contribution is installed ( e.g. articles or links manager etc )

 public function __construct(){
   if ( defined( 'FILENAME_PAGES' ) && defined( 'TABLE_PAGES_DESCRIPTION' ) ) {
     // The items with a colon : are placeholders which must match the $placeholders array in method acquire()
     $this->base_query = "SELECT pages_title FROM " . TABLE_PAGES_DESCRIPTION . " WHERE pages_id=':pages_id' AND language_id=':languages_id' LIMIT 1";
     usu::$registry->merge( 'seo_pages', $this->page_relations );
     usu::$registry->merge( 'markers', $this->markers );
     usu::$registry->addPageDependency( array( self::FILENAME => self::DEPENDENCY ));
     /**
     * For modules which are optional ( like information pages etc)
     * we would check for the existance of certain defines and if present set $this->installed to true
     * e.g. for the links contribution we would use ..
     * if ( defined( 'FILENAME_LINKS' ) && defined( 'TABLE_LINK_CATEGORIES_DESCRIPTION' ) ) {
     *   $this->installed = true;
     * }  
     */
     $this->installed = true; // xxx Hardcoded to true in this instance - see above comment.
   }
 }

 protected function acquire( $base_path, $full_path ) {
   $this->dependency_value = $full_path; // Full path perhaps with underscores
   /**
   * About placeholders
   *  
   * The placeholders (items with a colon :) must match those in the query ( $this->base_query in the constructor )
   */
   $placeholders = array( ':pages_id', ':languages_id' );
   // Do the below values need to be typecast?
   $values = array( (int)$base_path, (int)usu::$languages_id ); // xxx These values will replace the placeholders above in $this->base_query
   $this->query = str_replace( $placeholders, $values, $this->base_query ); // Replace the placeholders with actual values
   $result = usu::query( $this->query ); // Action the query
   $this->query = null; // Unset the query for future usage
   $row = tep_db_fetch_array( $result ); // Return the array of data ( or false if there are no results )
   tep_db_free_result( $result ); // Housekeeping
   if ( false === $row ) {
     return false; // No results for the query so abort
   }
   /**
   *  Values obtained from the query, these properties will populate the registry via the method getProperties()
   * Method $this->linkText() should be used here to convert the text into seo url format e.g.
   * my great product .. may become .. my-great-product
   * You may have more than one of these like ..
   * $this->parentname, $this->catname dependent on how many results you retrieve from your query
   */
   $this->pages_title = $this->linkText( $row['pages_title']  );

   // If the registry item doesn't exist as a key then set a blank array
   if ( false === isset( usu::$registry->{self::DEPENDENCY} ) ) {
     usu::$registry->{self::DEPENDENCY} = array();
   }
   /**
   * Populate the registry with the properties we have set in this class
   */
   usu::$registry->attach( self::DEPENDENCY, $this->dependency_value, $this->getProperties() );
 } // End method

  protected function getProperties() {
    $properties = get_object_vars( $this ); // $properties becomes an array of all properties within this class
    unset( $properties['page_relations'] ); // Get rid of this key as it is not needed in the registry
    return $properties;  
  } // End method

  private function get_full_path( $path ) {
    // Only used for modules that require paths with parents like .. 2_6_35
    // See Usu_Categories.php for usage
    return $path;
  } // End method

  private function get_parents() {
    // Only used for modules that require paths with parents like .. 2_6_35
    // See Usu_Categories.php for usage
  } // End method

  /**
  * Builds the seo url
  * 
  * @param string $page - file name of the calling page e.g. index.php
  * @param array $valuepair - key => value pair array containing dependency(e.g. cPath) => value (e.g. 2_24_52)
  * @param string $url - $url passed by reference created by the method linkCreate() 
  * @param array $added_qs - passed by reference containing key value pairs for _GET
  * @param string $parameters - Currently unused
  */
  public function buildLink( $page, $valuepair, &$url, &$added_qs, $parameters ) {
    if ( ( $valuepair[0] != self::DEPENDENCY ) || ( false === array_key_exists( 1, $valuepair ) )
                                               || ( false === $this->installed )
                                               || !tep_not_null( $valuepair[1] ) ) {
      return false; // Either this module is not installed or the value pair does not meet our requirements so abort
    }
    $base_path = $valuepair[1]; // well it might be a single top level item
    if ( false !== strpos( $valuepair[1], '_' ) ) { // It is a path with parents? ( has underscores )
      $base_path = ltrim( strrchr( $valuepair[1], '_' ), '_' ); // Grab the base path which is the number at the end of a path with parents ( e.g. 2_23_37_52 = 52 ) 
    }
    // Sanity check - if the $base_path is not numeric then we dump it
    if ( false === is_numeric( $base_path ) ) {
      trigger_error( __CLASS__ . ' Incorrect ' . self::DEPENDENCY . ' presented: ' . $valuepair[1], E_USER_WARNING );
      return false;
    }
    // Get a full path with underscores from the database
    $full_path = $this->get_full_path( $base_path );
    // If this item is not already in the registry we use the acquire() method to query for the data
    if ( !isset( usu::$registry->vars[self::DEPENDENCY][$full_path] ) ) {
      if ( false === $this->acquire( $base_path, $full_path ) ) {
        return false; // Looks like an invalid request so dump it
      }
    } else {
      usu::$performance['queries_saved']++; // Already in the registry so we saved one query
    }
    /**
    * About $reg_item
    * 
    * We grab the array of data from the registry and place it in $reg_item for convenience
    * The data stored in the registry was set in the method acquire as properties of this class
    * These are then set in the registry using the method getProperties()
    * the specific array keys like $reg_item['catname'] will be specific and differ in each module 
    */
    $reg_item = array();
    $reg_item = usu::$registry->vars[$valuepair[0]][$full_path];

    /**
    * Set the link text from reg_item
    * e.g. $link_text = $reg_item['parentname'] . '-' . $reg_item['catname'];
    */
    $link_text = $reg_item['pages_title']; // the property added in the acquire function this would have been set in the acquire method like $this->xxxname


    switch( true ){
      case $page == self::FILENAME:
        $url = $this->linkCreate( self::FILENAME, $link_text, self::MARKER, $full_path );
        break;
      default:
        // Add leftovers to the querystring _GET
        $added_qs[filter_var( $valuepair[0], FILTER_SANITIZE_STRING )] = usu::cleanse( $valuepair[1] );
        break;
    } # end switch
  }
}  
?>

Link to comment
Share on other sites

I don't know if the problem I'm having is related to this addon (which used to work great) but thought I'd try anyhow. I have a heavily modified store which uses USU5.

 

The problem only arises on certain categories. Basically if you navigate to a certain category, the images aren't displayed and every link from there on outwards gives:

 

You do not have permission to access store/pagename.html on this server

Additionally a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

 

When it says you do not have permission to access the page suchandsuch.html. I know this isn't true as the page does work usually.

 

If I go back a page and avoid that certain category then everything works a treat.

 

I have turned the debug option on and reset the cache and have noticed for all the working categories, it displays the queries at the bottom (Select product name....) but when accessing the broken category there are no queries displayed.

 

If I turn USU5 off then all the categories and pages work.

 

I hope you can help as I'd really like to turn USU5 back on again. If you need more info, please let me know.

Link to comment
Share on other sites

I don't know if the problem I'm having is related to this addon (which used to work great) but thought I'd try anyhow. I have a heavily modified store which uses USU5.

 

The problem only arises on certain categories. Basically if you navigate to a certain category, the images aren't displayed and every link from there on outwards gives:

 

You do not have permission to access store/pagename.html on this server

Additionally a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

 

When it says you do not have permission to access the page suchandsuch.html. I know this isn't true as the page does work usually.

 

If I go back a page and avoid that certain category then everything works a treat.

 

I have turned the debug option on and reset the cache and have noticed for all the working categories, it displays the queries at the bottom (Select product name....) but when accessing the broken category there are no queries displayed.

 

If I turn USU5 off then all the categories and pages work.

 

I hope you can help as I'd really like to turn USU5 back on again. If you need more info, please let me know.

 

there are no known issues with USU5 and tbh that isn't much to go on. Is it possible to see the site with USU5 on ( and a link to the bad categories ).

 

What link do you see when you hover these bad category links?

Link to comment
Share on other sites

I have noticed with USU 5 that when a customer selects a manufacturer from the dropdown box, once the page has loaded if the customer then goes back to the dropdown box(which should have the loaded manufacturer preselected) and selects "Please Select" the USU 5 error page shows.

Is there a way around this to the show the index page for http://www.x.com/index.php?manufacturers_id=

 

I noticed this was bought up before but from memory no solution was posted and seems to be in all sites I have seen with this installed so it isn't just mine.

I dont have an issue with doing a custom error page but I just thought that this could be a common selection with customers and would prefer them not to see it unless an error has occured.

I tried some htaccess redirects and a few other things but none ended up being a great long term solution.

Thanks in advanced

Link to comment
Share on other sites

A member at post 797 asked the same thing. But did not see a solution, or I hope I haven't overlooked it.

 

This contribution has been running without any problems. In process of installing best_product_and_listing. Am having issues trying to incorporate into includes/modules/product_listing.php. The instruction # 59 - catalog/includes/modules/product_listing.php reads to find this:

 

            $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> '; 

 

and replace with this:

 

            $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'products_id')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';

 

But the line in product_listing is as following:

 

	      $lc_text['button_buy_now'] = '<a href="' . tep_href_link(basename($_SERVER['PHP_SELF']), tep_get_all_get_params(array('action','sort','products_id')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW, 'style="padding-bottom: 5px;"') . '</a>';

 

I've tried to insert the code as your instructions and compared the two lines. But it puts the table out of whack. I have included an image of what it should like before the changes. And you may go here to see the after.

 

[ img ]http://brs-giftshop.com/images/best_product.jpg[ /img ]

 

So if a possible fix, would be appreciated.

 

Thanks.

Edited by Jan Zonjee
Link to comment
Share on other sites

I have noticed with USU 5 that when a customer selects a manufacturer from the dropdown box, once the page has loaded if the customer then goes back to the dropdown box(which should have the loaded manufacturer preselected) and selects "Please Select" the USU 5 error page shows.

Is there a way around this to the show the index page for http://www.x.com/index.php?manufacturers_id=

 

I noticed this was bought up before but from memory no solution was posted and seems to be in all sites I have seen with this installed so it isn't just mine.

I dont have an issue with doing a custom error page but I just thought that this could be a common selection with customers and would prefer them not to see it unless an error has occured.

I tried some htaccess redirects and a few other things but none ended up being a great long term solution.

Thanks in advanced

 

This is an osCommerce issue not one of USU5 use the file in extras/replacements/

Link to comment
Share on other sites

A member at post 797 asked the same thing. But did not see a solution, or I hope I haven't overlooked it.

 

This contribution has been running without any problems. In process of installing best_product_and_listing. Am having issues trying to incorporate into includes/modules/product_listing.php.

 

I've tried to insert the code as your instructions and compared the two lines. But it puts the table out of whack. I have included an image of what it should like before the changes.

 

So if a possible fix, would be appreciated.

 

Thanks.

 

In a standard osCommerce where the buy now button is built there is ..

 

tep_get_all_get_params(array('action'))

 

This should be ..

 

tep_get_all_get_params(array('action', 'products_id'))

Edited by FWR Media
Link to comment
Share on other sites

Hello Robert,

 

because we are running a very large shop (>20.000 articles), you have send me a patch one month ago. This should prevent the issue that the shop does not work anymore if the cachefile(s) became too large.

 

I have build this in, but yesterday the 1_usucache_pID.cache file became a size of ~320kb and the shop did not load anymore (blank screen). After a reset of the SEO cache, the shop was working again.

 

I assume the we do not have enough memory, but we can't change this cause we are running the store at a hosting account.

 

I have set the "number of days to store the cache" from 7 to 3 now and hope that will do the trick. But I worry about what will happen if some search engine spider is scanning the shop - I am sure that will bring the cache to overflow again.

 

Is there something else we could do? Does it make any difference to use the database cache instead of the filesystem cache?

 

We had another issue 2 days before (which I did not associate with SEO Urls): Our Paypal IPN Receiver Module suddenly seems not working fully correct anymore. It receives the IPN message from paypal, but instead of sending a "HTTP 200 OK" back, paypal receives "HTTP 500 Internal Server Error" and therefore tried sending the IPN message again and again.

 

I could not understand what was happen, cause in a development and test copy of our store on the same server (with 100% the same scripts and configuration running) the IPN messages worked perfect.

 

The 1_usucache_pID.cache file of the live shop was about 270kb large at this moment and the shop was running with no problems (instead of the paypal issue).

 

I was not able to find the problem with IPN, but since I have reseted the SEO cache, even the paypal issue is gone away...

 

Do you have any statement about or any solution for that?

 

I whould like to prevent any further problems, maybe it whould a solution to turn off the SEO cache. But are there any disadvantages in doing that and if not, what must be modified to do that?

 

Thank you for any answer and solution.

 

Best regards

 

Michael

Link to comment
Share on other sites

Hi.

 

1. Category title and product title are shown on a product page, the same with description and keywords. I want product title shown only on a product page.

How to fix it?

 

 

2. In my children clothes shop I have the categories "jempers", "t-shirts"... and urls for those categories the following /jempers-c-60.php, /t-shirts -61.php.

I need to the word "child" be added to categoty's url for example "/child-jemper-c-60.php"

And i don't want to name the categories like "child jempers", "child t-shirts".

How to resolve it?

 

 

Thanks.

Link to comment
Share on other sites

How can i make custom urls to search results page?

Now it looks like this: /advanced_search_result.php?keywords=jeans&search_in_description=1&x=10&y=9.

 

Can it be made something like this: /search/jeans or similar?

Thanks in advance

Link to comment
Share on other sites

Hello Robert,

 

because we are running a very large shop (>20.000 articles), you have send me a patch one month ago. This should prevent the issue that the shop does not work anymore if the cachefile(s) became too large.

 

I have build this in, but yesterday the 1_usucache_pID.cache file became a size of ~320kb and the shop

 

I whould like to prevent any further problems, maybe it whould a solution to turn off the SEO cache. But are there any disadvantages in doing that and if not, what must be modified to do that?

 

Thank you for any answer and solution.

 

Best regards

 

Michael

 

Considering that you have products cache turned off the file size of 320kb is huge ( perhaps you could email me this ) .. how many categories does it have?

 

To turn caching off open up the class file dealing with your chosen cache method and change ..

 

private $use_cache = 'false';

Edited by FWR Media
Link to comment
Share on other sites

Hi.

 

1. Category title and product title are shown on a product page, the same with description and keywords. I want product title shown only on a product page.

How to fix it?

 

 

2. In my children clothes shop I have the categories "jempers", "t-shirts"... and urls for those categories the following /jempers-c-60.php, /t-shirts -61.php.

I need to the word "child" be added to categoty's url for example "/child-jemper-c-60.php"

And i don't want to name the categories like "child jempers", "child t-shirts".

How to resolve it?

 

 

Thanks.

 

You can't .. the seo urls are built using your naming for products and categories.

Link to comment
Share on other sites

How can i make custom urls to search results page?

Now it looks like this: /advanced_search_result.php?keywords=jeans&search_in_description=1&x=10&y=9.

 

Can it be made something like this: /search/jeans or similar?

Thanks in advance

 

There's no point .. the bots don't do searches.

Link to comment
Share on other sites

You can't .. the seo urls are built using your naming for products and categories.

What i have to do with title on a product page? 2 titles are shown there(title of a category page and title of a product page).

Link to comment
Share on other sites

Hi Rob,

Couldn't find anything wrong in the header and footer codes as well.

Must be somewhere else. Funny thing is I can see the correct SEO paths on the URL and also the correct page shows up for 1 sec and then back to home page!

Will try out the orig OSC install later in the day when I get back.

Thanks.

 

Regards,

Ram

I posted the fix for this somewhere in here if I could just remember where.

Bo

Link to comment
Share on other sites

Well I can tell you for a fact that it is you and not USU5.

 

Either you haven't correctly set .htaccess or you haven't correctly set includes/configure.php

If you installed this on a new site in a sub folder you will need to change this

RewriteBase / in the hatacess in the new folder If I understand correctly you have installed a another store in a new folder. I don't see how you could use the same hatcess file for both

 

Rewritebase / is root

Rewritebsae /otherfoldername for the other one or the hatacess will send you back to your root

Link to comment
Share on other sites

Hello,

 

I just upgraded to php 5.2 and installed ULTIMATE_Seo_Urls_5_r141_stable

 

In my categories box when I roll my mouse over the categories I still see at the bottom of the browser in the status bar

 

http://domainname.com/store/index.php?cPath=XXX

 

Is this normal?

 

When I click the category it says the proper SEO url in the address bar

 

I was hoping never to see index.php?cPath=XXX again.

 

Thanks,

Alex

Link to comment
Share on other sites

Hello,

 

I just upgraded to php 5.2 and installed ULTIMATE_Seo_Urls_5_r141_stable

 

In my categories box when I roll my mouse over the categories I still see at the bottom of the browser in the status bar

 

http://domainname.com/store/index.php?cPath=XXX

 

Is this normal?

 

When I click the category it says the proper SEO url in the address bar

 

I was hoping never to see index.php?cPath=XXX again.

 

Thanks,

Alex

 

never mind I just deleted everything in catalog/cache and now its working great, thanks for the great mod.

Link to comment
Share on other sites

Hello Rob,

 

Considering that you have products cache turned off the file size of 320kb is huge ( perhaps you could email me this ) .. how many categories does it have?

 

To turn caching off open up the class file dealing with your chosen cache method and change ..

 

private $use_cache = 'false';

 

thank you for your answer. At the moment the shop is running with the Configuration Value: "Set the number of days to store the cache." = 3 and the issue (blank screen) was not seen again. But 1_usucache_pID.cache file nevertheless seems to grow (but only slower than before). At the moment it has 71kb and I manually reseted the cache at June/18/2010...

 

We have 83 categories.

 

Maybe there is a bug in your patch for huge shops or you sent me the wrong patch files?

 

Unfortunately I missed to backup the 1_usucache_pID.cache file from June/18/2010 before the reset. But I have one from June/16/2010 which has 273kb size.

 

Any idea how a big 1_usucache_pID.cache file can cause the described problems with Paypal IPN communication? Since I reseted the cache we did not have any of such problems with Paypal IPN and the script code was not modified... With the cache file from June/16/2010 the described Paypal issue was already present!

 

I will email you the patch files you have sent to me (to verify that they are the right ones), the current 1_usucache_pID.cache file and that one from June/16/2010.

 

I hope you can find out something with this... As long as we did not run into further problems, I will keep the caching active...

 

 

Thank you in advance and best regards

 

Michael

Link to comment
Share on other sites

Hello Rob,

 

 

 

thank you for your answer. At the moment the shop is running with the Configuration Value: "Set the number of days to store the cache." = 3 and the issue (blank screen) was not seen again. But 1_usucache_pID.cache file nevertheless seems to grow (but only slower than before). At the moment it has 71kb and I manually reseted the cache at June/18/2010...

 

We have 83 categories.

 

Maybe there is a bug in your patch for huge shops or you sent me the wrong patch files?

 

Unfortunately I missed to backup the 1_usucache_pID.cache file from June/18/2010 before the reset. But I have one from June/16/2010 which has 273kb size.

 

Any idea how a big 1_usucache_pID.cache file can cause the described problems with Paypal IPN communication? Since I reseted the cache we did not have any of such problems with Paypal IPN and the script code was not modified... With the cache file from June/16/2010 the described Paypal issue was already present!

 

I will email you the patch files you have sent to me (to verify that they are the right ones), the current 1_usucache_pID.cache file and that one from June/16/2010.

 

I hope you can find out something with this... As long as we did not run into further problems, I will keep the caching active...

 

 

Thank you in advance and best regards

 

Michael

 

Hi Michael

 

Thanks for sending the files, I have received them .. I will examine the cache data and let you know when I have done so.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...