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

Simple SEO URL (OLD version) [support thread]

Views: 1,114,883

Results 61 to 80 of 5,058
29 Jan 2008, 3:22 AM
#61
yellow1912 avatar

yellow1912

Totally Zenned

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

Simple SEO URL (OLD version) [support thread]

Basically, we will parse the url to rebuild all $_GET elements, if the link is changed intentionally (heck, you can even do so with the original query string), $_GET will not contain the expected values. But then the user will not gain anything from it, he will get to a page-not-found or an error page depend on the situation. No harm done.

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:36 AM
#62
skaimauve avatar

skaimauve

New Zenner

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

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

Here is the patch on the latest 2.6 code to provide links such as:

http://localhost/site/index/c2s4s6-vinyl-albums/p6-led-zep-ii
$ diff Simple_SEO_URL/includes/init_includes/init_ssu.php site/includes/init_includes/init_ssu.php 
34,39c34,35
< 		if ($request_type == 'SSL') 
< 			$catalog_dir = DIR_WS_CATALOG;
< 		else
< 			$catalog_dir = DIR_WS_HTTPS_CATALOG;
< 			$extension = SSU_FILE_EXTENSION;
< 			$extension = trim($extension);
---
> 		$catalog_dir =  ($request_type == 'SSL') ? DIR_WS_CATALOG : DIR_WS_HTTPS_CATALOG;
> 		$extension = trim(SSU_FILE_EXTENSION);
47a44
> 				$file_name = current(explode(SSU_ID_DELIMITER, $mr_parts[$i],2));
49,51c46,48
< 				if(strstr($mr_parts[$i],'c'.SSU_ID_DELIMITER)){
< 					$cPath = explode(SSU_ID_DELIMITER, $mr_parts[$i]);
< 					$_GET['cPath'] = $cPath[count($cPath)-1]; 					
---
> 				if($file_name[0] == 'c') {
> 					if(file_get_contents($this->cache_folder.$file_name) !== false)
> 						$_GET['cPath'] = str_replace('s','_',substr($file_name,1)); 					
53,55c50,52
< 				elseif(strstr($mr_parts[$i],'p'.SSU_ID_DELIMITER)){
< 					$products_id = explode(SSU_ID_DELIMITER, $mr_parts[$i]);
< 					$_GET['products_id'] = $products_id[count($products_id)-1]; 					
---
> 				elseif($file_name[0] == 'p') {
> 					if(file_get_contents($this->cache_folder.$file_name) !== false)
> 						$_GET['products_id'] = substr($file_name,1); 					
200d196
< 		$result = 'c'.SSU_ID_DELIMITER.$result.SSU_ID_DELIMITER.$cPath;
201a198
> 		$result = $file_name.SSU_ID_DELIMITER.$result;
208c205
< 		return "c$cPath";
---
> 		return 'c'. str_replace('_','s',$cPath);
226c223
< 		$result = 'p'.SSU_ID_DELIMITER.$result.SSU_ID_DELIMITER.$products_id;
---
> 		$result = $file_name.SSU_ID_DELIMITER.$result;
29 Jan 2008, 3:37 AM
#63
skaimauve avatar

skaimauve

New Zenner

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

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

Oh, and I forgot, thanks again yellow1912!

29 Jan 2008, 9:06 PM
#64
cjpinder avatar

cjpinder

Totally Zenned

Join Date:
Apr 2007
Location:
Herts. UK
Posts:
893
Plugin Contributions:
0

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

If you want to keep your URLs ultra simple then you don't actually need to include the full cPath. The only bit that is needed is the final category ID. e.g. if the cPath is 1_2_3_4 then you only need the 4. The full cPath can then be rebuilt from the category ID. This also helps if you move categories around which confuses the heck out of Google.

In fact you don't need the cPath at all except on linked products (and category pages of course).

Regards,
Christian.

30 Jan 2008, 12:05 AM
#65
yellow1912 avatar

yellow1912

Totally Zenned

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

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

It's a good idea, will do that on the next release.
Will ZC handles the cPath rebuild, or we must do that on the mod?

Also, it would be interesting to see someone comes up with a proper 301 redirect method that should work in most cases. Being an open source mod, SSU is open for anyone to modify and improve it to suit their needs. And hopefully any code improvement will be posted back here so that everyone can benefit from it.

Expecting more and more code/feature suggestions will come in. And maybe this mod can be incorporated into the new version of ZC, or can be of any help for the developers to build an even better one.

CJPinder:

If you want to keep your URLs ultra simple then you don't actually need to include the full cPath. The only bit that is needed is the final category ID. e.g. if the cPath is 1_2_3_4 then you only need the 4. The full cPath can then be rebuilt from the category ID. This also helps if you move categories around which confuses the heck out of Google.

In fact you don't need the cPath at all except on linked products (and category pages of course).

Regards,
Christian.

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

30 Jan 2008, 3:18 AM
#66
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 with minor changes in codes:

Change some local params to class params to allow re-use.
Redirect site.com/index.php or site.com/index.php? or site.com/? to site.com

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

30 Jan 2008, 3:26 PM
#67
skaimauve avatar

skaimauve

New Zenner

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

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

CJPinder:

If you want to keep your URLs ultra simple then you don't actually need to include the full cPath.

Not exactly. If you don't have the full cPath, the menus will not show properly, which was a problem of a previous version.

More precisely, you would not have access to menu Level 3 because the engine would not know which path to display.

Steps to reproduce the bug:

  1. Click on Level 1:

the page refresh with Level 1 opened becasue cPath = ID of Level 1

  1. Click on Level 2:

the page refresh with Level 1 closed because cPath = ID of Level 2

30 Jan 2008, 3:45 PM
#68
cjpinder avatar

cjpinder

Totally Zenned

Join Date:
Apr 2007
Location:
Herts. UK
Posts:
893
Plugin Contributions:
0

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

skaimauve:

Not exactly. If you don't have the full cPath, the menus will not show properly, which was a problem of a previous version.
If you re-read my original post you will see that I said that you can rebuild the full cPath from the category ID.

Regards,
Christian.

30 Jan 2008, 3:52 PM
#69
cjpinder avatar

cjpinder

Totally Zenned

Join Date:
Apr 2007
Location:
Herts. UK
Posts:
893
Plugin Contributions:
0

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

yellow1912:

Will ZC handles the cPath rebuild, or we must do that on the mod?

You would need to do it on the mod but it is pretty straight forward. The following code will do it...

  $current_category_id = <insert category id here>
  $rebuild_categories = array();
  zen_get_parent_categories($rebuild_categories, $current_category_id);
  $rebuild_categories = array_reverse($rebuild_categories);
  $cPath = implode('_', $rebuild_categories);
  if (zen_not_null($cPath)) $cPath .= '_';
  $cPath .= $current_category_id;

As there is a one-to-one mapping between category IDs and cPaths the process could be cached pretty easily.

Regards,
Christian.

30 Jan 2008, 3:56 PM
#70
yellow1912 avatar

yellow1912

Totally Zenned

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

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

No, if I ever decide to do that, I wont use zen_get_parent_categories because it will require mysql query. I will store the category tree in file which can be retrieved later.

Example:
17_19_21 will be stored in file t21

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

30 Jan 2008, 4:02 PM
#71
skaimauve avatar

skaimauve

New Zenner

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

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

CJPinder:

If you re-read my original post you will see that I said that you can rebuild the full cPath from the category ID.

Right. My point anyway was that "you have to rebuild the full cPath" in addition to "you can rebuild the full cPath" which some mods forget to do.

And I forgot, nice code suggestion!

30 Jan 2008, 4:05 PM
#72
cjpinder avatar

cjpinder

Totally Zenned

Join Date:
Apr 2007
Location:
Herts. UK
Posts:
893
Plugin Contributions:
0

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

yellow1912:

No, if I ever decide to do that, I wont use zen_get_parent_categories because it will require mysql query. I will store the category tree in file which can be retrieved later.

Example:
17_19_21 will be stored in file t21

Exactly, the code is there to show how the cPath can be rebuilt. Once it has been then cache it in a file or db table. Depending on the server setup, db caching may provide better performance then file caching, but maybe not.

Regards,
Christian.

30 Jan 2008, 4:21 PM
#73
cjpinder avatar

cjpinder

Totally Zenned

Join Date:
Apr 2007
Location:
Herts. UK
Posts:
893
Plugin Contributions:
0

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

skaimauve:

Right. My point anyway was that "you have to rebuild the full cPath" in addition to "you can rebuild the full cPath" which some mods forget to do.
The best option for product URLs is to not include the cPath at all except on linked products which require special consideration for SEO anyway.

Regards,
Christian.

30 Jan 2008, 4:23 PM
#74
yellow1912 avatar

yellow1912

Totally Zenned

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

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

Some people prefer having the category name in the link, and even want to have more than 1 name. Now I dont know which one should I listen to, lol

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

30 Jan 2008, 4:27 PM
#75
cjpinder avatar

cjpinder

Totally Zenned

Join Date:
Apr 2007
Location:
Herts. UK
Posts:
893
Plugin Contributions:
0

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

yellow1912:

Some people prefer having the category name in the link, and even want to have more than 1 name. Now I dont know which one should I listen to, lol
I meant remove the cPath except on linked products to help control duplicate content issues (and keep the URLs short). As for keyword stuffing in the URLs, well that is purely a personal preference and you will never please everyone :wacko:

Regards,
Christian.

30 Jan 2008, 5:58 PM
#76
skaimauve avatar

skaimauve

New Zenner

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

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

CJPinder:

The best option for product URLs is to not include the cPath at all except on linked products which require special consideration for SEO anyway.

Exactly.

For my own education, what is a "linked product"?

30 Jan 2008, 6:10 PM
#77
yellow1912 avatar

yellow1912

Totally Zenned

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

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

A product that is in more than 1 categories. For instance, I have a book which is in both science and fiction categories.

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

30 Jan 2008, 6:17 PM
#78
skaimauve avatar

skaimauve

New Zenner

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

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

Here is a patch for revision @123 to get the following URL style:

http://localhost/site/c2s6-mens-clothing/p4-shirt/product_info.html
diff includes/init_includes/init_ssu.php /www/site/includes/init_includes/init_ssu.php
31,33c31,32
< 		$this->cache_folder = DIR_FS_SQL_CACHE."/ssu/";
< 		$this->extension = SSU_FILE_EXTENSION;
< 		$this->extension = trim($this->extension);
---
> 		$this->cache_folder = DIR_FS_SQL_CACHE.'/ssu/';
> 		$this->extension = '.'.trim(SSU_FILE_EXTENSION);
36c35,37
< 		$this->mr = trim(($this->catalog_dir=='/' && empty($this->extension)) ? getenv('REQUEST_URI') : preg_replace(array($this->catalog_dir,'/\.'.$this->extension.'/'),'',getenv('REQUEST_URI'), 1),'/ ');
---
> 		$this->mr = getenv('REQUEST_URI');
> 		if(substr($this->mr,0,strlen($this->catalog_dir)) == $this->catalog_dir)
> 			$this->mr = substr($this->mr,strlen($this->catalog_dir));
63,74c64,80
< 		// first element is always main_page
< 		// even if this is a "static" page, assigning first element to
< 		$_GET['main_page'] = $this->mr_parts[0];
< 		for($i= 1; $i < $this->mr_parts_count; $i++){
< 			// TODO: a more efficient way to do this?
< 			if(strstr($this->mr_parts[$i],'c'.SSU_ID_DELIMITER)){
< 				$cPath = explode(SSU_ID_DELIMITER, $this->mr_parts[$i]);
< 				$_GET['cPath'] = $cPath[count($cPath)-1];
< 			}
< 			elseif(strstr($this->mr_parts[$i],'p'.SSU_ID_DELIMITER)){
< 				$products_id = explode(SSU_ID_DELIMITER, $this->mr_parts[$i]);
< 				$_GET['products_id'] = $products_id[count($products_id)-1];
---
> 		if($debug)
> 		print_r($this->mr_parts);
> 		// element with extension is always main_page 
> 		for($i= 0; $i < $this->mr_parts_count; $i++){
> 			$part = $this->mr_parts[$i];
> 			// TODO: an more efficient way to do this?
> 			$part_break = strpos($part,SSU_ID_DELIMITER);
> 			if($part_break>0){
> 		  	// Use cache to validate structure
> 				$file_name = substr($part,0,$part_break);
> 				if(file_get_contents($this->cache_folder.$file_name) != substr($part,$part_break)){
> 					if ($file_name[0] == 'c') 
> 						$_GET['cPath'] = str_replace('s','_',substr($file_name,1)); 					
> 					elseif ($file_name[0] == 'p') 
> 						$_GET['products_id'] = substr($file_name,1);
> 				continue;
> 				}
75a82,84
> 			if(substr($part,strlen($part)-strlen($this->extension )) == $this->extension ){
> 				$_GET['main_page'] = substr($part,0,strlen($part)-strlen($this->extension ));
> 			}					
77c86
< 				$_GET[$this->mr_parts[$i]] = $this->mr_parts[($i + 1)];
---
> 				$_GET[$part] = $this->mr_parts[($i + 1)];
81c90
< 				$_GET[$this->mr_parts[$i]] = '';
---
> 				$_GET[$part] = '';
111,113c120
< 		$link = HTTP_SERVER;
< 		if ($connection == 'SSL' && ENABLE_SSL == 'true')
< 		$link = HTTPS_SERVER ;
---
> 		$link = ($connection == 'SSL' && ENABLE_SSL == 'true') ? HTTPS_SERVER : HTTP_SERVER;
116,122c123,124
< 		if ($use_dir_ws_catalog) {
< 			if ($connection == 'SSL' && ENABLE_SSL == 'true') {
< 				$link .= DIR_WS_HTTPS_CATALOG;
< 			} else {
< 				$link .= DIR_WS_CATALOG;
< 			}
< 		}
---
> 		if ($use_dir_ws_catalog)
>       $link .= ($connection == 'SSL' && ENABLE_SSL == 'true') ? DIR_WS_HTTPS_CATALOG : DIR_WS_CATALOG;
171,182c173,180
< 		// Any param? No? return page.extension
< 		if(empty($parameters)){
< 			if(empty($sid))
< 			return $link.$page.(trim(SSU_FILE_EXTENSION)=='' ? '' : '.'.SSU_FILE_EXTENSION);
< 			else
< 			return $link.$page.'/'.$sid;
< 		}
< 
< 		$parameters = zen_output_string($parameters);
< 		$link .= $page.'/'.$parameters;
< 
< 		while (substr($link, -1) == '/') $link = substr($link, 0, -1);
---
> 		// Any param? 
> 		if(!empty($parameters)){
>     	$parameters = zen_output_string($parameters);
> 		  $link .= $parameters.'/';
> 		}
> 		
> 		// return page.extension
> 	  $link .= $page.((trim(SSU_FILE_EXTENSION)=='') ? '' : '.'.trim(SSU_FILE_EXTENSION)); 
200c198
< 		return 'c'.SSU_ID_DELIMITER.$content.SSU_ID_DELIMITER.$cPath;
---
> 		return $file_name.SSU_ID_DELIMITER.$content;
225c223
< 		return "c$cPath";
---
> 		return 'c'. str_replace('_','s',$cPath);
227c225
< 
---
> 	
234c232
< 		return 'p'.SSU_ID_DELIMITER.$content.SSU_ID_DELIMITER.$products_id;
---
> 		return $file_name.SSU_ID_DELIMITER.$content;
30 Jan 2008, 6:46 PM
#79
yellow1912 avatar

yellow1912

Totally Zenned

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

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

Here is what I'm thinking:
we either: remove cpath completely from product_info links, rebuild later
or: we make sure the cPath will always be the same, and always be there for a specific product.

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

30 Jan 2008, 8:15 PM
#80
skaimauve avatar

skaimauve

New Zenner

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

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

My take is that we've disquised cPath in the URL so far to make things prettier while and not sacrifice speed. If we can do without cPath in the URL, then great!

The question is to choose the ultimate URL format. The code will follow.