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".
|
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. |
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; } |
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. |
Re: Clean Url settings
Quote:
|
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:
<IfModule mod_rewrite.c> 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 |
Re: Clean Url settings
Quote:
|
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 |
Re: Clean Url settings
Quote:
|
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. |
All times are GMT -8. The time now is 04:22 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.