| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Clean Url settings | ||||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Clean Url settings
Looking to start using xcart 5, but having trouble with clean urls. I am trying to figure out how to adjust clean url settings in xcart 5. The clean urls are using ".html", and I would prefer to use "/" so as to keep page names consistent with my existing site. How would I go about changing this? Just to make sure what I'm asking is clear I want "example.com/page/" instead of "example.com/page.html".
__________________
Ver 5.2.6 |
|||||||
#2
|
|||||||||
|
|||||||||
Re: Clean Url settings
Phil,
I think I have found the class you would need to decorate. Take a look at classes/XLite/Core/Converter.php function buildCleanURL This line in particular: $urlParams[] = $product->getCleanURL() . '.html'; Try changing that to a / instead of .html Of course, don't modify the core file, decorate it in your module.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey XcartGuru X-cart Tutorials | X-cart 5 Tutorials Check out the responsive template for X-cart. |
|||||||||
|
#3
|
|||||||
|
|||||||
Re: Clean Url settings
Quote:
<?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\Produc t')->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\Catego ry')->find($params['category_id']); if (isset($category) && $category->getCleanURL()) { foreach (array_reverse($category->getPath()) as $node) { if ($node->getCleanURL()) { $urlParams[] = $node->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 |
|||||||
#4
|
|||||||||
|
|||||||||
Re: Clean Url settings
Phil,
The only thing I see that I don't understand is the abstract declaration. It also looks like you are missing defining {} brackets around your class itself. abstract class Converter extends \XLite\Core\Converter implements \XLite\Base\IDecorator { Function goes here } Other obvious questions are, is this module activated? is it functioning in other ways? So, I investigated this and was able to successfully change .html to .htm But when I tried to change it to / it failed 404 error not found. So I think some .htaccess magic is needed in addition to this change.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey XcartGuru X-cart Tutorials | X-cart 5 Tutorials Check out the responsive template for X-cart. |
|||||||||
|
#5
|
|||||||
|
|||||||
Re: Clean Url settings
Quote:
__________________
Ver 5.2.6 |
|||||||
#6
|
|||||||||
|
|||||||||
Re: Clean Url settings
This '/' may be getting in the way of non-.html urls - so there is probably another piece of code to add '/' if it is not product... it may not be htacess issue.
On the other hand there is this in htaccess Code:
which works on non-folder and non-directory and with htm or html extensions only. Have you tried any other extension like .hhh to see if it works - if it doesn't then it is definitely this line in htaccess
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
|
#7
|
|||||||
|
|||||||
Re: Clean Url settings
Quote:
__________________
Ver 5.2.6 |
|||||||
#8
|
|||||||||
|
|||||||||
Re: Clean Url settings
The line
RewriteRule ^((([/_a-z0-9-]+)/)?([_a-z0-9-]+)/)?([_a-z0-9-]+)(\.(htm|html))?$ cart.php?url=$5&last=$4&rest looks for only htm and html to rewrite url. You can try adding hhh to see if it will work - if it does it is definitely this rul RewriteRule ^((([/_a-z0-9-]+)/)?([_a-z0-9-]+)/)?([_a-z0-9-]+)(\.(hhh|htm|html))?$ cart.php?url=$5&last=$4&rest You can also try RewriteRule ^((([/_a-z0-9-]+)/)?([_a-z0-9-]+)/)?([_a-z0-9-]+)(\.(\/|htm|html))?$ cart.php?url=$5&last=$4&rest for the / but I am guessing this may get in the way of categories, not sure
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
|
#9
|
|||||||
|
|||||||
Re: Clean Url settings
Quote:
__________________
Ver 5.2.6 |
|||||||
#10
|
|||||||
|
|||||||
Re: Clean Url settings
Quote:
Here is the RewriteRule I used: RewriteRule ^((([/_a-z0-9-]+)/)?([_a-z0-9-]+)/)?([_a-z0-9-]+)(\/)?$ cart.php?url=$5&last=$4&rest=$3&ext=$7 [NC,L,QSA] I'm still working on the categories if anyone has any suggestions on this. A BIG THANK YOU to Mike and Steve for all of your help so far. You guys have been a huge help.
__________________
Ver 5.2.6 |
|||||||
|
|||
X-Cart forums © 2001-2020
|