Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Clean Url settings

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #11  
Old 10-15-2014, 10:58 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: Clean Url settings

Good to see you worked it out. It was the dot in (\.(\/|htm|html)) - that's what happens when I don't pay much attention

By the way you can try

RewriteRule ^((([/_a-z0-9-]+)/)?([_a-z0-9-]+)/)?([_a-z0-9-]+)(\/|(\.(htm|html)))?$ cart.php?url=$5&last=$4&rest=$3&ext=$7 [NC,L,QSA]

just to keep the original as well
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
Phil Richman (10-15-2014)
  #12  
Old 10-15-2014, 11:05 AM
 
Phil Richman Phil Richman is offline
 

Advanced Member
  
Join Date: May 2012
Posts: 94
 

Default Re: Clean Url settings

Quote:
Originally Posted by cflsystems
Good to see you worked it out. It was the dot in (\.(\/|htm|html)) - that's what happens when I don't pay much attention

By the way you can try

RewriteRule ^((([/_a-z0-9-]+)/)?([_a-z0-9-]+)/)?([_a-z0-9-]+)(\/|(\.(htm|html)))?$ cart.php?url=$5&last=$4&rest=$3&ext=$7 [NC,L,QSA]

just to keep the original as well
I replaced my rewrite rule with your latest suggestion. Now I just need to figure out the clean urls for categories. Currently the category clean urls are 'example.com/category/subcategory1/subcategory2/' and I would like for only the category / subcategory that you are in to show. I'm looking for something more like example.com/subcategory2. I'm wondering if maybe this is an htaccess change also to strip out everything except for the lowest subcategory, or if this is a change in the converter.php or a combo in between. What are your thoughts on this?
__________________
Ver 5.2.6
Reply With Quote
  #13  
Old 10-16-2014, 09:34 AM
 
Phil Richman Phil Richman is offline
 

Advanced Member
  
Join Date: May 2012
Posts: 94
 

Default Re: Clean Url settings

I'm close to having this the way that I want it to work. I have it only showing the clean url for the categories you are in just fine, but when you go to a product page it shows the last category you came from to get to the product. It is fine if you come from the home page because it is not a category page so it shows only the product clean url. Below is the code from my converter.php. Any ideas or suggestions?

Code:
<?php namespace XLite\Module\Pmall\PmallSkin\Core; abstract class Converter extends \XLite\Core\Converter implements \XLite\Base\IDecorator { public static function buildCleanURL($target = '', $action = '', array $params = array()) { $result = null; $urlParams = array(); if ('product' === $target && empty($action) && !empty($params['product_id'])) { $product = \XLite\Core\Database::getRepo('\XLite\Model\Product')->find($params['product_id']); if (isset($product) && $product->getCleanURL()) { $urlParams[] = $product->getCleanURL() . '/'; unset($params['product_id']); } } if ( ('category' === $target || ('product' === $target && !empty($urlParams))) && empty($action) && !empty($params['category_id']) ) { $category = \XLite\Core\Database::getRepo('\XLite\Model\Category')->find($params['category_id']); if (isset($category) && $category->getCleanURL()) { $urlParams[] = $category->getCleanURL(); } } if (!empty($urlParams)) { unset($params['category_id']); } static::buildCleanURLHook($target, $action, $params, $urlParams); if (!empty($urlParams)) { unset($params['target']); $result = implode('/', array_reverse($urlParams)); if (!empty($params)) { $result .= '?' . http_build_query($params); } } return $result; } }
__________________
Ver 5.2.6
Reply With Quote
  #14  
Old 10-16-2014, 10:01 AM
 
Phil Richman Phil Richman is offline
 

Advanced Member
  
Join Date: May 2012
Posts: 94
 

Default Re: Clean Url settings

Got it. Here is the final code if anyone else is interested in doing this.

Code:
<?php namespace XLite\Module\Pmall\PmallSkin\Core; abstract class Converter extends \XLite\Core\Converter implements \XLite\Base\IDecorator { public static function buildCleanURL($target = '', $action = '', array $params = array()) { $result = null; $urlParams = array(); if ('product' === $target && empty($action) && !empty($params['product_id'])) { $product = \XLite\Core\Database::getRepo('\XLite\Model\Product')->find($params['product_id']); if (isset($product) && $product->getCleanURL()) { $urlParams[] = $product->getCleanURL() . '/'; unset($params['product_id']); } } if ( ('category' === $target && empty($action) && !empty($params['category_id'])) ) { $category = \XLite\Core\Database::getRepo('\XLite\Model\Category')->find($params['category_id']); if (isset($category) && $category->getCleanURL()) { $urlParams[] = $category->getCleanURL(); } } if (!empty($urlParams)) { unset($params['category_id']); } static::buildCleanURLHook($target, $action, $params, $urlParams); if (!empty($urlParams)) { unset($params['target']); $result = implode('/', array_reverse($urlParams)); if (!empty($params)) { $result .= '?' . http_build_query($params); } } return $result; } }
__________________
Ver 5.2.6
Reply With Quote

The following user thanks Phil Richman for this useful post:
tony_sologubov (10-17-2014)
  #15  
Old 12-18-2014, 05:15 AM
 
Vanaja Vanaja is offline
 

Member
  
Join Date: Dec 2014
Posts: 13
 

Default Re: Clean Url settings

Hi,

In X-Cart 5.1.3, when Auto generating the Clean URL by default spaces are replaced with "_" underscore.

Is there any configuration setting in X-Cart 5 to change the default auto generation of clean URL to "-" hyphen ?

Thanks in Advance!
__________________
Vanaja
Reply With Quote
  #16  
Old 12-18-2014, 11:37 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Clean Url settings

Hello Vanaja,

The "-" is the default character for URL rewrites, but it might be changed in your configuration file.

Please check what value is specified for the "default_separator" setting in your [xc5]/etc/config.php file.

-------

UPDATE:
I've just realized that you use the 5.1.3 version.
This version is outdated and may have no such a setting in the configuration file.
Why don't you upgrade to the most recent 5.1.9?
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions

Last edited by qualiteam : 12-18-2014 at 11:40 PM.
Reply With Quote

The following user thanks qualiteam for this useful post:
Vanaja (12-18-2014)
  #17  
Old 12-22-2014, 03:45 AM
 
Vanaja Vanaja is offline
 

Member
  
Join Date: Dec 2014
Posts: 13
 

Default Re: Clean Url settings

Hi there,

I have upgraded X Cart version to 5.1.9. But still facing an issue with Clean URL generation.

I want my clean urls spaces to be separated by hyphen (-) instead of underscore (_).

I have set "default_separator" value to "-" in [xc5]/etc/config.php file.

I have checked the core files and found that '_' is the default separator is static in the below code.

In this file [xc5]/var/run/classes/XLite/Core/ConverterAbstract.php, check the below line.

'_' => '32,47,92,172,173,8211', # Replace spaces/slashes by the $subst_symbol('_' by default)


Click image for larger version

Name:	cleanurl.png
Views:	414
Size:	20.0 KB
ID:	4025

Can anyone check this and let me know the solution for this problem?

Thanks!
__________________
Vanaja
Reply With Quote
  #18  
Old 12-23-2014, 04:16 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Clean Url settings

Hi Vanaja,

I'll check this with the XC5 developers.

Thanks!
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #19  
Old 12-24-2014, 06:35 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: Clean Url settings

Hi Vanaja!

Judging by the code, the correct replacement should happen, but it does not. Please, report this bug into bt.x-cart.com.
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 06:35 AM.

   

 
X-Cart forums © 2001-2020