Forums / All Other Contributions/Addons / Simple SEO URL (OLD version) [support thread]

Simple SEO URL (OLD version) [support thread]

Views: 1,114,883

Results 41 to 60 of 5,058
27 Jan 2008, 9:43 AM
#41
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Simple SEO URL (OLD version) [support thread]

I think you are in the wrong support thread, this thread is not for ultimate seo url.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

28 Jan 2008, 4:37 AM
#42
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Simple SEO URL (OLD version) [support thread]

I want to know if we are all okie with the current link structure, it will be hard to change things later:

http://demo.rubikintegration.com/zencart/

Otherwise we will stick with it.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

28 Jan 2008, 4:45 AM
#43
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

Re: Simple SEO URL (OLD version) [support thread]

yellow1912:

I want to know if we are all okie with the current link structure, it will be hard to change things later:

http://demo.rubikintegration.com/zencart/

Otherwise we will stick with it.

I like yourr suggestion in post #37. The link above does not seem to be using the shorter version at this point.

Jim
Wheaton Website Services

28 Jan 2008, 5:18 AM
#44
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Simple SEO URL (OLD version) [support thread]

Check again, see if you like something like this:

http://demo.rubikintegration.com/zencart/product_info/c-big-linked-22/p-a-bug-s-life-multi-pak-special-2003-collectors-edition-34

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

28 Jan 2008, 7:06 AM
#45
skaimauve avatar

skaimauve

New Zenner

Join Date:
Dec 2007
Posts:
15
Plugin Contributions:
0

Re: Simple SEO URL (OLD version) [support thread]

:clap: Great work yellow1912! :clap:

I am posting three changes in case they could be of any help:

  1. I changed .htaccess to avoid passing the variable MR which is failing on some servers:
#### BOF SSU
RewriteEngine On
RewriteBase /site/

# Deny access from .htaccess
RewriteRule ^\.htaccess$ - [F]

# Existing files shouldn't get rewritten
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

# The rest can go to ZC
RewriteRule ^(.+) index.php/$1 [E=VAR1:$1,QSA,L]
#### EOF SSU
  1. I changed the URL parsing function so it can handle whatever file extension that the user sets. In init_ssu.php:
function parse_url($debug=false){
	$link = $_SERVER['REQUEST_URI'];

	// taking care of the shop catalog
	$catalog_dir = (isset($_SERVER['HTTPS']) || $_SERVER['SERVER_PORT']==443) ? DIR_WS_HTTPS_CATALOG : DIR_WS_CATALOG;
    $link = str_replace($catalog_dir, '' , $link);

	// taking care of file extension
	$link = str_replace('.'.SSU_FILE_EXTENSION, '' , $link);

	// taking care of parameters
	$mr_parts = explode('/', current(explode('?', $link)));
	$mr_parts_count = count($mr_parts);
			
	// first element is always main_page
	// even if this is a "static" page, assigning first element to 
	$_GET['main_page'] = $mr_parts[0];
	for($i= 1; $i < $mr_parts_count; $i = $i + 2){
		if(isset($mr_parts[($i + 1)])){
			$_GET[$mr_parts[$i]] = $mr_parts[($i + 1)];
		}
		else{
		$_GET[$mr_parts[$i]] = '';
		}
	}
	unset($mr_parts, $mr_parts_count);
		
	// taking care of product and category name
	if(isset($_GET['products_id'])){
		$products_id = explode(SSU_ID_DELIMITER,$_GET['products_id']);
		$_GET['products_id'] = $products_id[count($products_id)-1];
	}
	if(isset($_GET['cPath'])){
		$cPath = explode('-',$_GET['cPath']);
		$_GET['cPath'] = $cPath[count($cPath)-1];
	}

	if($debug)
		print_r($_GET);
}
  1. Finally, the category three was not preserved (for example, clicking a top category would open its sub-category tree, but clicking on a sub-category would close the whole tree). In init_ssu.php:
	function get_category_name($cPath){
		global $db;
		if(empty($cPath)) return '';
		$category_id = explode('_',$cPath);
		$category_id = $category_id[count($category_id)-1];
		
		$file_name = $this->build_category_filename($category_id);
		if(($content = file_get_contents($this->cache_folder.$file_name)) !== false)
			return $content;	

		return $this->set_category_name($cPath, $category_id);
	}
	
	function set_category_name($cPath, $category_id){
		$file_name = $this->build_category_filename($cPath);
		$sql_query = 'SELECT categories_name FROM '.TABLE_CATEGORIES_DESCRIPTION.' WHERE categories_id ='.$category_id.' LIMIT 1';
		return $this->_get_name($file_name,$sql_query,'categories_name',$cPath);
	}
	
	function build_category_filename($category_id){
		 return "c$category_id";
	}
28 Jan 2008, 7:18 AM
#46
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Simple SEO URL (OLD version) [support thread]

You are right, I made some stupid changes and didnt keep the category tree, will fix that.

As for part 2, that's better than having to change the htaccess file, good job :laugh:

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

28 Jan 2008, 8:01 AM
#47
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Simple SEO URL (OLD version) [support thread]

New version updated to make changes suggested by skaimauve.

@skaimauve: we cant use str_replace to replace the catalog_dir because is is possible that somewhere in the url contains a string that is exactly the same with catalog_dir and will be replaced as well.

I used preg_replace to limit the replacement to 1 only.

Next update will cover:

  1. ezpage link is not created the way it should be, will fix that
  2. Allow store owner to stack more than 1 category names into the links, and allow store owner to limit the number of category names on the links as well.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

28 Jan 2008, 9:24 AM
#48
skaimauve avatar

skaimauve

New Zenner

Join Date:
Dec 2007
Posts:
15
Plugin Contributions:
0

Re: Simple SEO URL (OLD version) [support thread]

Oups... :wink:

D    Simple_SEO_URL/admin/includes/module_installation/install.sql
28 Jan 2008, 9:34 AM
#49
skaimauve avatar

skaimauve

New Zenner

Join Date:
Dec 2007
Posts:
15
Plugin Contributions:
0

Re: Simple SEO URL (OLD version) [support thread]

:clap: Good work on the update code yellow1912! :clap:

Wow , we have a winner. This feature is nicely implemeted!

28 Jan 2008, 11:07 AM
#50
skaimauve avatar

skaimauve

New Zenner

Join Date:
Dec 2007
Posts:
15
Plugin Contributions:
0

Re: Simple SEO URL (OLD version) [support thread]

How about creating links on this format?

http://host/store/product_info/c2-vinyl/p4-led-zep

Again, if this is of any help. In init_ssu.php:

  1. Change what is inside the loop:
	function parse_url($debug=false){
		global $request_type;
		// attempt to check current protocol being used
		// This check is not perfect, but should work most of the time
		if ($request_type == 'SSL') 
			$catalog_dir = DIR_WS_CATALOG;
		else
			$catalog_dir = DIR_WS_HTTPS_CATALOG;
		$extension = trim(SSU_FILE_EXTENSION);
		// we want to remove $catalog_dir and 
		$mr_parts = explode('/', trim(current(explode('?', ($catalog_dir=='/' && empty($extension)) ? getenv('REQUEST_URI') : preg_replace(array($catalog_dir,'/\.'.$extension.'/'),'',getenv('REQUEST_URI'), 1))), '/'));
		$mr_parts_count = count($mr_parts);
		// first element is always main_page
		// even if this is a "static" page, assigning first element to 
		$_GET['main_page'] = $mr_parts[0];
		for($i= 1; $i < $mr_parts_count; $i++){
>			$file_name = current(explode(SSU_ID_DELIMITER, $mr_parts[$i],2));
			// TODO: an more efficient way to do this?
>			if($file_name[0] == 'c') {
>			  if(file_get_contents($this->cache_folder.$file_name) !== false)
>					$_GET['cPath'] = substr($file_name,1); 					
			}
>			elseif($file_name[0] == 'p') {
>			  if(file_get_contents($this->cache_folder.$file_name) !== false)
>					$_GET['products_id'] = substr($file_name,1); 					
			}
			elseif(isset($mr_parts[($i + 1)])){
				$_GET[$mr_parts[$i]] = $mr_parts[($i + 1)];
				$i++;
			}
			else{
				$_GET[$mr_parts[$i]] = '';
				$i++;
			}
		}
		unset($mr_parts, $mr_parts_count);
		if($debug)
			print_r($_GET);
	}

And two lines here

		// Appending category name and product name into the link
		if(strstr($parameters,'cPath')!==false || strstr($parameters,'products_id')!==false || $page ==''){
    		$parameters = explode('/',$parameters);
    		
    		for($i=0; $i < count($parameters); $i++){
    			if($parameters[$i]=='cPath'){
>    				$parameters[$i] = 'c'.$this->get_category_name($parameters[$i+1]);
    				unset($parameters[$i+1]);
    			}
    			elseif($parameters[$i]=='products_id'){
>    				$parameters[$i] = 'p'.$this->get_product_name($parameters[$i+1]);
    				unset($parameters[$i+1]);
    			}
    			elseif($parameters[$i]=='main_page'){
    				$page = $parameters[$i+1];
    				unset($parameters[$i]);
    				unset($parameters[$i+1]);
    			}
    		}
    		//print_r($parameters);
    		$this->array_clean_up($parameters);
    		$parameters = implode('/',$parameters);
    	}

And one line here:

	function _get_name($file_name, $sql_query, $field_name, $original_value){
		global $db;
		$result = $original_value;
		$sql_result = $db->Execute($sql_query);
		if($sql_result->RecordCount() > 0){
			// remove non alphanumeric
			$result = preg_replace("/[^a-zA-Z0-9s]/", SSU_NAME_DELIMITER, $sql_result->fields[$field_name]);
			// remove excess underscore
			$result = preg_replace('/'.SSU_NAME_DELIMITER.SSU_NAME_DELIMITER.'+/', SSU_NAME_DELIMITER, $result);
			// remove trailing _
			$result = strtolower(trim($result, SSU_NAME_DELIMITER));
			// now prepend the id
>			$result = $original_value.SSU_ID_DELIMITER.$result;
 			// write into file. Cant use file_put_contents since it's not in php4
			if($handle = @fopen($this->cache_folder.$file_name, "w")){
				if (fwrite($handle, $result) === FALSE) {
	        		// TODO: sound the alarm
	    		}
	    		fclose($handle);
			}
			else{
				// TODO: sound the alarm here
			}
		}
		return $result;
	}
28 Jan 2008, 2:31 PM
#52
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Simple SEO URL (OLD version) [support thread]

@skaimauve: so you want the id first? Anyone else wants this link format:
%%BBCODE_CODE_0%%

Instead of:

http://demo.rubikintegration.com/zencart/product_info/c-big-linked-22/p-a-bug-s-life-multi-pak-special-2003-collectors-edition-34

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

28 Jan 2008, 4:29 PM
#53
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Simple SEO URL (OLD version) [support thread]

Alpha 2.6 is now released with new fixes and new features:

  1. EZ page links are built correctly now
  2. Allowing you to set the category depth level as far as you want.
    Example: assuming you a category tree like this: 10_11_13_15
    You can set it so that the names of the 3 last categories appear on the link:
    c-category11name-category13name-category15name-10_11_13_15

For upgrader: there is a database patch in this new update, make sure you read the doc first.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

29 Jan 2008, 12:31 AM
#54
skaimauve avatar

skaimauve

New Zenner

Join Date:
Dec 2007
Posts:
15
Plugin Contributions:
0

Re: Simple SEO URL (OLD version) [support thread]

yellow1912:

@skaimauve: so you want the id first?

Well, I am toying with different options.The great thing is that your code is that it's clear and it allows for customization. All I need is to suit the client's preference.

In my case, the client does not like Amazon links:

http://www.amazon.com/Led-Zeppelin-II/dp/B000002J03 

CRE Loaded SEO links are acceptable:

Example of Category URL: 
http://host.com/Mens/c30/index.html
Example of Product URL: 
http://host.com/Mens/c30/p53/poloshirt/product_info.html

All it needs is to be readable!

29 Jan 2008, 12:54 AM
#55
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Simple SEO URL (OLD version) [support thread]

Im glad it helped you, there are plenty of other things you need to take care of b4 using it on a live site:

A proper 301 direction is need, especially if the site is not new
Also, the way we put the cpath and pid right, while making the link shorter, expose it to various possible errors, but good thing is that these errors will not occur unless the users play with the link, and even, so no harm will be done. This mod does not effect ZC internal security mechanism in anyway, so as long as ZC properly sanitizes all the inputs as it is doing now, there is nothing to worry about.

If you happen to develop something on the current code, dont forget to post it here and I'll gladly merge that into the current one if possible.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

29 Jan 2008, 1:20 AM
#56
skaimauve avatar

skaimauve

New Zenner

Join Date:
Dec 2007
Posts:
15
Plugin Contributions:
0

Re: Simple SEO URL (OLD version) [support thread]

yellow1912:

Alpha 2.6 is now released with new fixes and new features:

  1. EZ page links are built correctly now
  2. Allowing you to set the category depth level as far as you want.
    Example: assuming you a category tree like this: 10_11_13_15
    You can set it so that the names of the 3 last categories appear on the link:
    c-category11name-category13name-category15name-10_11_13_15

Nicely done! Just remember to clear the cache after changing the category depth level. Maybe the code should do that for you.

29 Jan 2008, 1:32 AM
#57
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Simple SEO URL (OLD version) [support thread]

Right now, to build a category tree name with x cats for the FIRST time the mod has to query database x times. Even though this is done only ONCE, it is not efficient**. **
I should either try to make use of the name already retrieved in files, or use just 1 query. There is a a problem with trying to use 1 single query string tho, how should we select....in() yet still make the category names in the exact order.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

29 Jan 2008, 3:12 AM
#58
skaimauve avatar

skaimauve

New Zenner

Join Date:
Dec 2007
Posts:
15
Plugin Contributions:
0

Re: Simple SEO URL (OLD version) [support thread]

yellow1912:

Right now, to build a category tree name with x cats for the FIRST time the mod has to query database x times. Even though this is done only ONCE, it is not efficient.

My take on this is:

  1. it is done once, therefore it is efficient, considering
  2. it is looping though simple queries, therefore less prone to bugs

If someone has a site with x cats, where x is large, they should have the power to run these Simple SEO URL queries, cause the rest of ZenCart will require a lot of power anyway.

And again, if this is Simple SEO URL, we should have relatively compact code.

29 Jan 2008, 3:16 AM
#59
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Simple SEO URL (OLD version) [support thread]

Thanks skaimauve, I thought so as well.

Also, I have made minor changes to the code, previously the content in files are stored like this:
example: c-name1-name2-19_20

From now on, we will simply store the names only: name1-name2

This allows us to re-use the names if we ever need to.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

29 Jan 2008, 3:18 AM
#60
skaimauve avatar

skaimauve

New Zenner

Join Date:
Dec 2007
Posts:
15
Plugin Contributions:
0

Re: Simple SEO URL (OLD version) [support thread]

yellow1912:

... these errors will not occur unless the users play with the link, and even, so no harm will be done..

Maybe you could check that the link exists in the cache before processing it, in a way similar to the code I have submitted.

  if(file_get_contents($this->cache_folder.$file_name) !== false)

Just a thought.