Jump to content

cableguy1115

Members
  • Posts

    11
  • Joined

  • Last visited

Profile Information

  • First Name
    Cable
  • Last Name
    Guy

Recent Profile Visitors

342 profile views

cableguy1115's Achievements

Newbie

Newbie (1/14)

2

Reputation

  1. Hi, I'm trying to add a piece of code to my homepage to display a list of all the categories and under each category it's subcategories with a number at side with the amount of products in it. Something like this: - Category 1 - - Sub category (42) - - Sub category (13) - Category 3 - - Sub category (17) - - Sub category (33) Although it may be simple for some, I've been searching for 2 ways for a way to do it, but without result. Tried modifying the CategoryController.php override but without success (no result in homepage, but then I realized the Category page was actually crashing). The code I have now shows the main categories, but not the sub categories. {foreach from=$categories item=subcategory name=homeCategories} <li> <div class="subcategory-image"> <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'html':'UTF-8'}" title="{$subcategory.name|escape:'html':'UTF-8'}" class="img"> {if $subcategory.id_image} <img class="replace-2x" src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium_default')|escape:'html':'UTF-8'}" alt="" width="{$mediumSize.width|escape:'htmlall':'UTF-8'}" height="{$mediumSize.height|escape:'htmlall':'UTF-8'}"/> {else} <img class="replace-2x" src="{$img_cat_dir|escape:'htmlall':'UTF-8'}{$lang_iso|escape:'htmlall':'UTF-8'}-default-medium_default.jpg" alt="" width="{$mediumSize.width|escape:'htmlall':'UTF-8'}" height="{$mediumSize.height|escape:'htmlall':'UTF-8'}"/> {/if} </a> </div> <h5> <a class="subcategory-name" href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'html':'UTF-8'}">{$subcategory.name|truncate:25:'...'|escape:'html':'UTF-8'}</a> </h5> <ul class="sub-menu"> <!-- It loops with a foreach --> <li><a href="#">Sub-category <span class="sub-counter">60 (number of products in this subcategory)</span></a></li> </ul> </li> {/foreach} Any kind sould to help me out, pretty please? Thanks in advance. Prestashop 1.6.1.14
  2. Outstanding. Hope other people will find it usefull too. Thank you a lot
  3. Hello, Is there a way to disable new customer registration, aswell disable guest buy? My clients are limited and I only want to create accounts myself for them. I've seen some posts from 1 year ago but I get "page not working" and stuff like that when I touch the .tpl's. I saw a module that does that, but I was wondering if Prestashop had an option to do it. Thank you.
  4. I tried that, but it doesn't export my modules configuration too, the position, etc.
  5. Hello, I'm trying to export a theme (created in a v1.6 Prestashop) and install it on a different Prestashop, which was 1.5 and newly updated to 1.6 (to support the new theme). Anyone knows what tables are exactly the ones in the MySQL database that I need to export that contain all the theme configuration and modules? What about categories and products? Exporting those tables would suffice or is there any other settings saved in disk files (ini's, cfg's, etc). Thank you.
  6. [sOLVED] My final code to be able to get the grandfather category ID (parent parent ID): In Category.tpl : Notice $parents[1] array. $parents[0] would give the parent ID, [1] grandparent, [2] great grand parent, and so on.... <ul> <li><span>Models</span> <ul> {assign var=gf value=$parents[1].id_parent} // <-- THIS LINE stores grandparent ID (delete this comment) {assign var='all_categories' value=Category::getCategories(Context::getContext()->language->id)} {foreach from=$all_categories name=outer item=pagecat key=key1} {foreach from=$pagecat name=mid item=subcat key=key2} {foreach from=$subcat name=inner item=innercat key=key3} {assign var="idca" value=$innercat.id_category} {assign var="idpa" value=$innercat.id_parent} {assign var="name" value=$innercat.name} {assign var="lirw" value=$innercat.link_rewrite} {assign var="lvdp" value=$innercat.level_depth} {if ($idpa == $id_category && $idpa != $idca) || ($idpa == $id_category_parent && $idpa != $id_category && $lvdp > 2) || ($idpa == $gf && $lvdp == '3')} {if $lirw neq 'man' && $lirw neq 'woman'} <li><a href="/{$lang_iso}/{$idca}-{$lirw}"><span>{$name}</span></a></li> {/if} {/if} {/foreach} {/foreach} {/foreach} </ul> </li> </ul> In CategoryController.php, modify the initContent() function and add the lines: $array_parent = $this->category->getParentsCategories(); // <-- THIS LINE (delete this comment) $this->context->smarty->assign(array( 'category' => $this->category, 'description_short' => Tools::truncateString($this->category->description, 350), 'products' => (isset($this->cat_products) && $this->cat_products) ? $this->cat_products : null, 'id_category' => (int)$this->category->id, 'id_category_parent' => (int)$this->category->id_parent, 'parents' => $array_parent, // <-- THIS LINE (delete this comment) 'return_category_name' => Tools::safeOutput($this->category->name), 'path' => Tools::getPath($this->category->id), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize(ImageType::getFormatedName('category')), 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), 'thumbSceneSize' => Image::getSize(ImageType::getFormatedName('m_scene')), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'allow_oosp' => (int)Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int)Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers(), 'body_classes' => array($this->php_self.'-'.$this->category->id, $this->php_self.'-'.$this->category->link_rewrite) ));
  7. Hello, I have this code: <ul> {assign var='all_categories' value=Category::getCategories(Context::getContext()->language->id)} {foreach from=$all_categories name=outer item=pagecat key=key1} {foreach from=$pagecat name=mid item=subcat key=key2} {foreach from=$subcat name=inner item=innercat key=key3} {assign var="idca" value=$innercat.id_category} {assign var="idpa" value=$innercat.id_parent} {assign var="name" value=$innercat.name} {assign var="lirw" value=$innercat.link_rewrite} {assign var="lvdp" value=$innercat.level_depth} {if ($idpa == $id_category && $idpa != $idca) || ($idpa == $id_category_parent && $idpa != $id_category && $lvdp > 2)} {if $lirw neq 'man' && $lirw neq 'woman'} <li><a href="/{$lang_iso}/{$idca}-{$lirw}"><span>{$name}</span></a></li> {/if} {else} {/if} {/foreach} {/foreach} {/foreach}</ul> It's supposed to explode the "all_categories" array: Array( [0] => Array ( [1] => Array ( [infos] => Array ( [id_category] => 1 [id_parent] => 0 [id_shop_default] => 1 [level_depth] => 0 [nleft] => 1 [nright] => 58 [active] => 1 [date_add] => 2015-10-21 16:51:55 [date_upd] => 2015-10-21 16:51:55 [position] => 0 [is_root_category] => 0 [id_shop] => 1 [id_lang] => 1 [name] => Raíz [description] => [link_rewrite] => raiz [meta_title] => [meta_keywords] => [meta_description] => ) ) )) It works perfectly until you get to the page that displays the 3rd subcategory, then it goes blank. Sample: http://www.bustomshoes.com/es/12-modelos HINT: Select the model on the left, then on the right select the gender. I've been trying for two days now to create a third condition, something like "OR IF the SECOND parent of THIS category is the same same, display all categories, etc.". Basically, what I've been trying is to find a way to get the second parent (grandfather) of the curent category, then I could just simply echo all the entries that fulfill that condition. Helpppp! (
  8. Indeed seems the best aproach anyone could have come up with. I'm starting right away with a local shop to see if everything would work accordingly and gonna start doing it on the online one as soon as everything checks out. You saved my life lad, Thanks!!!
  9. Okay, after your message I had to go deeper into the problem and see what's really happening. Upon further investigation, I hope I can depict the problem a bit better and where all these problems come from. The Prestashop is a online shoe shop. We have 5 main categories (for the 5 main pages): Models. Summer collection. ... Next, inside Models and each of the main category we have the next categories: Nike. Puma. ... Man. (as for the sex) Woman. (as for the sex) Next, a third level category, inside NIke, Puma, etc., we hace again only two categories: man and woman. As the first person who built that told me, they do this two level sex categories so you can choose all models of a certain sex without the need to choose a model or particular shoemaker, and to also filter it by sex when you choose a shoemaker or a model. So, basically, the idea was to have a page with all the shoe models, and to be able to choose from there if it's man or woman made, but without the need to enter a certain model and select "man / woman". I highly doubt this is the best approach to solve this situation, with so many nested categories, and probably we could have used tags too, but we don't have much knowledge on Prestashop's programming particularities or envinroment variables, nor it's already existing premade functions, etc.. I'm all ears if anyone can suggest a better structure for this, and as always, a million thanks.
  10. A million thanks, Rocky! I overrid the function assignSubcategories() and now it's half-way done! My problem now is that if I don't select any big category, the sub-category menu shows all of them together For example: Category 1: Food; Subcategories 2, 3: Spicy, Sweet. When I go to the page and I click on "Spicy", instead of first selecting "Food" (on the other filter), the sub-category menu will show [ food / drink / etc / Spicy / Sweet ]. Would there be any way to avoid that, either with a conditional or just hiding the stuff with css? Again, a million thanks!
  11. Hello, I've been trying for some days now to modify the "category.tpl" and "CategoryController.php", so the subcategory menu show me the sibling categories when reaching the last bottom subcategories. For example, if I have a category tree of [1] -> [2] -> [3]. When you click on 1 you get 2, when on 2 you get 3, but when you click on 3 the subcategory menu should show me all the categories at the same level with 3 (since it's the bottom category). I imagine thinking we can do it by getting the parent category, then listing with a foreach all the children of the parent. Problem is I'm always getting problems en errors, can someone help me? I have for now in my category.tpl modified the next function: {if isset($subcategories)} {if (isset($display_subcategories) && $display_subcategories eq 1) || !isset($display_subcategories) } <div id="subcategories"> <ul class="clearfix"> {foreach from=$subcategories item=subcategory} <li> <h5><a class="subcategory-name" href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'html':'UTF-8'}">{$subcategory.name|truncate:25:'...'|escape:'html':'UTF-8'}</a></h5> {if $subcategory.description} <div class="cat_desc">{$subcategory.description}</div> {/if} </li> {/foreach} </ul> </div> {/if} {else} <!-- HERE IS WHERE IT SHOULD START --> <!-- No subcategory is found, I should list all the sibling categories of the curent one Here. --> {/if} AND a function in CategoryController.php public function getSiblings() { $_parent = new Category($this->category->id_parent, self::$cookie->id_lang); $_siblings = getChildren($parent_category,self::$cookie->id_lang,true); $_allsiblings = ""; foreach ($_siblings as $sib) { $_allsiblings .= "<li><h5>". $sib ."</h5></li> | "; } } A very big thank you to anyone able to help me, in advance thanks!!
×
×
  • Create New...