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

Passing Category Clean URL

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 01-27-2013, 01:34 AM
 
deepblue_tiano deepblue_tiano is offline
 

Advanced Member
  
Join Date: Nov 2010
Posts: 50
 

Default 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
__________________
christian
Reply With Quote
  #2  
Old 01-27-2013, 03:36 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default 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.
__________________
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.
Reply With Quote
  #3  
Old 01-27-2013, 04:07 AM
 
deepblue_tiano deepblue_tiano is offline
 

Advanced Member
  
Join Date: Nov 2010
Posts: 50
 

Default 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.
__________________
christian
Reply With Quote
  #4  
Old 01-27-2013, 05:25 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default 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.
__________________
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.
Reply With Quote
  #5  
Old 01-28-2013, 01:12 AM
 
deepblue_tiano deepblue_tiano is offline
 

Advanced Member
  
Join Date: Nov 2010
Posts: 50
 

Default 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.
__________________
christian
Reply With Quote

The following user thanks deepblue_tiano for this useful post:
totaltec (01-28-2013)
  #6  
Old 01-28-2013, 05:28 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Passing Category Clean URL

Chistian, thanks for providing your final solution. It would be even better if you shared the completed code.
__________________
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.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not 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 02:59 PM.

   

 
X-Cart forums © 2001-2020