X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Passing Category Clean URL (https://forum.x-cart.com/showthread.php?t=65961)

deepblue_tiano 01-27-2013 01:34 AM

Passing Category Clean URL
 
Hello, I am having trouble getting the clean url of product category then pass it to a variable template.

here's my sample code in bread_crumbs.tpl:
Code:

<span itemprop="url" url="{$http_location}/{$l.1}" title="{$l.0}">{$l.0}</span>

I am getting
Code:

<span itemprop="url" url="http://localhost/home.php?cat=12" title=Category name>Category name</span>

instead of
Code:

<span itemprop="url" url="http://localhost/category-name/" title=Category name>Category name</span>

clean url are working if you use that in href tags

totaltec 01-27-2013 03:36 AM

Re: Passing Category Clean URL
 
I see several ways to get the clean URL, not sure which to advise you to use. For instance, on a category page we have:
{$php_url} - returns the whole string "http://yourdomain.com/this-category-url/"

{$canonical_url} - returns just "this-category-url/"

{$current_category.clean_url} - returns "this-category-url/" as well

On the product page {$canonical_url} returns "this-product.html" and {$php_url} gives "http://yourdomain.com/this-product.html"

Hope that helps.

deepblue_tiano 01-27-2013 04:07 AM

Re: Passing Category Clean URL
 
Those solution might work if I am on the category page, But since I am on the product page it would return the product clean url. What I want is get the clean URL on the bread_crumbs.tpl on which the product categories are located.

totaltec 01-27-2013 05:25 AM

Re: Passing Category Clean URL
 
Okay. Now I understand. That is going to be difficult, I'm afraid.

You are going to have to query the DB, and assign the product's category's clean URL to an array. I think I can put you on the right track. On the product page, it looks like the $location array is being built near line 292, with this snippet of code:
Code:

// Get category location
if (
    $cat > 0
    && $current_category = func_get_category_data($cat)
) {
   
    if (is_array($current_category['category_location'])) {
        foreach ($current_category['category_location'] as $k => $v) {

            $location[] = $v;

        }
    }

}

Recursively search your files for that function "func_get_category_data", hopefully you can understand it's operation enough to add the Clean URL to the array, rather than the home.php?cat=123 that is currently being passed.

deepblue_tiano 01-28-2013 01:12 AM

Re: Passing Category Clean URL
 
I was able to get the clean url of categories by using func_clean_url_get function on my product page and then add an entry to my location array.

totaltec 01-28-2013 05:28 AM

Re: Passing Category Clean URL
 
Chistian, thanks for providing your final solution. It would be even better if you shared the completed code.


All times are GMT -8. The time now is 02:52 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.