thisishellow Posted July 26, 2010 Share Posted July 26, 2010 Hi everybody,I had no problems to get the id of the current category, in order to show a specific background on each category. But i would like to show the same background on each sub-product of these categories.That's why i need to get the id of the parent category on my products template.Hope this is clear enough.. Thanks in advance for your help ! Link to comment Share on other sites More sharing options...
rocky Posted July 26, 2010 Share Posted July 26, 2010 You can use {$product->id_category_default} to get the default category of the product or {$cookie->last_visited_category} to get the last category page that was visited. Link to comment Share on other sites More sharing options...
thisishellow Posted July 27, 2010 Author Share Posted July 27, 2010 Thanks rocky for your quick reply ! I definitely need {$product->id_category_default} because people might come to products from other pages than categories so {$cookie->last_visited_category} will no function very well.{$product->id_category_default} Works well in the product.tpl template but not in the header.tpl (I would like to add the id as a CSS class in the body). Is there any way to get the properties in the header ?Thanks a lot, Link to comment Share on other sites More sharing options...
rocky Posted July 27, 2010 Share Posted July 27, 2010 Unfortunately, I don't think there is any clean way to get it. The only way I can think of is to edit header.php and add the following code before the $smarty->display: if (isset($_GET['id_product'])) { $product = new Product($_GET['id_product']); $smarty->assign('id_category_default', $product->id_category_default); } Link to comment Share on other sites More sharing options...
thisishellow Posted July 27, 2010 Author Share Posted July 27, 2010 That's perfect rocky ! Thanks for your help Link to comment Share on other sites More sharing options...
rocky Posted July 27, 2010 Share Posted July 27, 2010 Glad it helped. Please edit your first post and add [sOLVED] to the front of the title. Link to comment Share on other sites More sharing options...
thisishellow Posted July 27, 2010 Author Share Posted July 27, 2010 Done ! Link to comment Share on other sites More sharing options...
Presta-TR Posted August 29, 2010 Share Posted August 29, 2010 hi i'm work of the categories block but i want to 1- if in a main category and sub category see -> main category links in the block. no see another categories. or sub categories.simplein the index.html(over made) have links at the main categories. and click another and in the category. block is displaying this categories->subcategories and clicks the subcategories displaying in the block again main categories -> subcategories. Sorry some english thx Link to comment Share on other sites More sharing options...
rocky Posted August 29, 2010 Share Posted August 29, 2010 So you want to display only the subcategories of the current category in the category block? It's possible to do that with my AJAX Sliding Categories module. Link to comment Share on other sites More sharing options...
Presta-TR Posted August 29, 2010 Share Posted August 29, 2010 no resolves. please help me? what is category.php?id_category=5 in this 5 ids categories id_paretnt variable ? i'm try to $id_parent no comes this 5's paretn id? please help Link to comment Share on other sites More sharing options...
rocky Posted August 29, 2010 Share Posted August 29, 2010 My post here might help. Link to comment Share on other sites More sharing options...
Presta-TR Posted August 30, 2010 Share Posted August 30, 2010 ok but i'm in blockcategories.php and ı'm tried this codes $id_parent, $id_category_parent, $category->parent, no setted up the parent id .. this variable.. please help Link to comment Share on other sites More sharing options...
rocky Posted August 30, 2010 Share Posted August 30, 2010 It should be $category->id_parent Link to comment Share on other sites More sharing options...
Presta-TR Posted August 30, 2010 Share Posted August 30, 2010 i'm tried.. i'm writtten it. no doing anything. this variable no settted up in blockcategories.php... Link to comment Share on other sites More sharing options...
Presta-TR Posted August 30, 2010 Share Posted August 30, 2010 if(isset($category->id_parent)){ //i'm tried too variable and no comes parent of the $_GET['id_category'] $id_c = $category->id_parent; // i'm tried too variable and no comes parent of the $_GET['id_category'] }else{ $id_c = 1; } $blockCategTree = $this->getTree($resultParents, $resultIds, Configuration::get('BLOCK_CATEG_MAX_DEPTH'), $id_c); i'm pasted the my editted blockcategories .php please help no comes parent id Link to comment Share on other sites More sharing options...
rocky Posted August 30, 2010 Share Posted August 30, 2010 Try: $id_parent = 1; if (isset($_GET['id_category'])) { $category = new Category($_GET['id_category']); if (Validate::isLoadedObject($category)) $id_parent = $category->id_parent; } $blockCategTree = $this->getTree($resultParents, $resultIds, Configuration::get('BLOCK_CATEG_MAX_DEPTH'), $id_parent); Link to comment Share on other sites More sharing options...
Presta-TR Posted August 30, 2010 Share Posted August 30, 2010 yes thx Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now