Jump to content

add back button between categories and subcategories prestashop


abdamu

Recommended Posts

Hello, I have updated my prestashop from 1.5 to 1.7 and it had modifications made. It had a button to navigate back from one category or subcategory to another. But the code does not work for me now in version 1.7, and I wanted you to give me a hand to adapt it to work in that version. I attach the code that I had in "category.tpl"

Thanks in advance

<!-- Subcategories -->
                <div id="subcategories">
                    <h3>{l s='Subcategories'}</h3>
                        <script type="text/javascript" >
                            $(window).load(function() {
                                setHeight2('.grid_list_categories li');
                            });
                        </script>

                    <div class='divCentre'>
                        <ul class="grid_list_categories clearfix">
                            {if $category->id_parent!=2}
                                <li>
                                    <a href="{$link->getCategoryLink($category->id_parent)}" title="Ver Categor&iacute;a Superior" class="img">
                                        <img src="/img/imgSubCat/return.jpg" alt="return" />
                                    </a>
                                    <a href="{$link->getCategoryLink($category->id_parent)}" class="cat_name">Ver Categor&iacute;a Superior</a>
                                </li>
                            {/if}
                            {if isset($subcategories)}
                                {foreach from=$subcategories item=subcategory}
                                    <li>
                                        <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}" class="img">
                                            {if $subcategory.id_image}
                                                <img src="/img/imgSubCat/{$subcategory.link_rewrite|escape:'htmlall':'UTF-8'}.jpg" alt="{$subcategory.name|escape:'htmlall':'UTF-8'}" />
                                            {else}
                                                <img src="{$img_cat_dir}default-medium_default.jpg" alt=""   />
                                            {/if}
                                        </a>
                                        <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" class="cat_name">{$subcategory.name|escape:'htmlall':'UTF-8'|truncate:42:'...'}</a>
                                    
                                    </li>
                                {/foreach}
                            {/if}
                        </ul>
                    </div>
                    <br class="clear"/>
                </div>
        {/if}

imagen.png.7946003f5b881aec1a7ea200ae0bd8a5.png

Edited by abdamu (see edit history)
Link to comment
Share on other sites

  • 1 month later...
{if $category->id_parent!=2}
								<li>
									<a href="{$link->getCategoryLink($category->id_parent)}" title="Ver Categor&iacute;a Superior" class="img">
										<img src="/warehouse/img/imgSubCat/volver.jpg" alt="volver" />
									</a>
									<a href="{$link->getCategoryLink($category->id_parent)}" class="cat_name">Ver Categor&iacute;a Superior</a>
								</li>
							{/if}

Hello again, can anyone help me to adapt this code to work with PS 1.7? I had it in P.S 1.5 and when I was in a subcategory or category, pressing the button redirected me to a parent category. The error is thrown at me in the code  {$link->getCategoryLink($category->id_parent)}

Does anyone know how to make it compatible with PS 1.7? 🤨

Edited by abdamu (see edit history)
Link to comment
Share on other sites

hace 8 horas, 4you.software dijo:
{url entity='category' id=$id_category id_lang=$id_lang}

Change id_category to parent category id variable.

Thanks for your quick response. Friend, I am not looking for a specific category, it has to work on all subcategories. Like a navigation button, it returns to the parent or previous category. I don't know if you understand what I'm looking for ... {if $category->id_parent!=2}  I am assuming this is based as a reference on the category "HOME"🤨

Edited by abdamu (see edit history)
Link to comment
Share on other sites

{if $category.id_parent != '2'}
                <li>
		              <a href="{url entity='category' id=$category.id_parent id_lang=$language.id}" title="Ver Categor&iacute;a Superior" class="img">
			              <img src="./img/imgSubCat/volver.jpg" alt="volver" />
		              </a>
		              <a href="{url entity='category' id=$category.id_parent id_lang=$language.id}" class="cat_name">Ver Categor&iacute;a Superior</a>
                </li>
                {/if}

Tested 1.7.7.0 and work.

./themes/your-theme/templates/catalog/listing/product-list.tpl

 

Edited by 4you.software (see edit history)
  • Like 1
Link to comment
Share on other sites

hace 2 horas, 4you.software dijo:
{if $category.id_parent != '2'}
                <li>
		              <a href="{url entity='category' id=$category.id_parent id_lang=$language.id}" title="Ver Categor&iacute;a Superior" class="img">
			              <img src="https://www.mercanutri.com/themes/warehouse/img/imgSubCat/volver.jpg" alt="volver" />
		              </a>
		              <a href="{url entity='category' id=$category.id_parent id_lang=$language.id}" class="cat_name">Ver Categor&iacute;a Superior</a>
                </li>
                {/if}

Tested 1.7.7.0 and work.

./themes/your-theme/templates/catalog/listing/product-list.tpl

obrazek.thumb.png.c84b2d2f6153d4ab980b886cb89f08a6.png

ok thanks now work perfect.
PS: please delete domain of the post ;)

Thanks

Edited by abdamu (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...