I think you are in the wrong support thread, this thread is not for ultimate seo url.
Printable View
I think you are in the wrong support thread, this thread is not for ultimate seo url.
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.
Check again, see if you like something like this:
Code:http://demo.rubikintegration.com/zencart/product_info/c-big-linked-22/p-a-bug-s-life-multi-pak-special-2003-collectors-edition-34
: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:
2. I changed the URL parsing function so it can handle whatever file extension that the user sets. In init_ssu.php:Code:#### 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
3. 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:PHP Code:
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);
}
PHP Code:
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";
}
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:
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.
Oups... :wink:
Code:D Simple_SEO_URL/admin/includes/module_installation/install.sql
:clap: Good work on the update code yellow1912! :clap:
Wow , we have a winner. This feature is nicely implemeted!
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:
And two lines herePHP Code:
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 one line here:PHP Code:
// 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);
}
PHP Code:
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;
}