Jump to content

How to show all subcategorories in smarty tpl file ?


Anant Thakur

Recommended Posts

I want to shwo the below output in the prestashop 1.7 tpl file, but I'am got some smarty error.

I used below code :-

<ul> 
    {foreach from=$all_sub_categories.children item=element} 
     <li><a href="{$element.link}">{$element.name}</a></li> 
     {if $element.children} 
     {$element.children|@print_r}
     <ul>{include file="test-recursion.tpl" test=$element.children}</ul>
     {/if} 
    {/foreach} 
    </ul> 

and
{foreach from=$element item=element} 
   <li>{$element.name}</li> 
   {if $element.children} 
   <ul>{include file="test-recursion.tpl" element=$element.children}</ul> 
   {/if} 
{/foreach}



But I got smarty error. Please help me.




Array
(
    [id] => 3
    [link] => http://localhost/prestashop1.7/en/3-women
    [name] => Women
    [desc] => You will find here all woman fashion collections.
This category includes all the basics of your wardrobe and much more:
shoes, accessories, printed t-shirts, feminine dresses, women's jeans!
    [children] => Array
        (
            [0] => Array
                (
                    [id] => 4
                    [link] => http://localhost/prestashop1.7/en/4-tops
                    [name] => Tops
                    [desc] => Choose from t-shirts, tops, blouses, short sleeves, long sleeves, tank tops, 3/4 sleeves and more.
Find the cut that suits you the best!
                    [children] => Array
                        (
                            [0] => Array
                                (
                                    [id] => 5
                                    [link] => http://localhost/prestashop1.7/en/5-tshirts
                                    [name] => T-shirts
                                    [desc] => The must have of your wardrobe, take a look at our different colors,
shapes and style of our collection!
                                    [children] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [id] => 15
                                                    [link] => http://localhost/prestashop1.7/en/15-tshirt-child
                                                    [name] => Tshirt child
                                                    [desc] => 
                                                    [children] => Array
                                                        (
                                                            [0] => Array
                                                                (
                                                                    [id] => 16
                                                                    [link] => http://localhost/prestashop1.7/en/16-tshirt-second-child
                                                                    [name] => Tshirt second child
                                                                    [desc] => 
                                                                    [children] => Array
                                                                        (
                                                                        )

                                                                )

                                                        )

                                                )

                                        )

                                )

                            [1] => Array
                                (
                                    [id] => 6
                                    [link] => http://localhost/prestashop1.7/en/6-top
                                    [name] => Tops
                                    [desc] => Choose the top that best suits you from the wide variety of tops we have. 
                                    [children] => Array
                                        (
                                        )

                                )

                            [2] => Array
                                (
                                    [id] => 7
                                    [link] => http://localhost/prestashop1.7/en/7-blouses
                                    [name] => Blouses
                                    [desc] => Match your favorites blouses with the right accessories for the perfect look.
                                    [children] => Array
                                        (
                                        )

                                )

                            [3] => Array
                                (
                                    [id] => 14
                                    [link] => http://localhost/prestashop1.7/en/14-top-child
                                    [name] => Top Child
                                    [desc] => Test 
                                    [children] => Array
                                        (
                                        )

                                )

                        )

                )

            [1] => Array
                (
                    [id] => 8
                    [link] => http://localhost/prestashop1.7/en/8-dresses
                    [name] => Dresses
                    [desc] => Find your favorites dresses from our wide choice of evening, casual or summer dresses!
We offer dresses for every day, every style and every occasion.
                    [children] => Array
                        (
                            [0] => Array
                                (
                                    [id] => 9
                                    [link] => http://localhost/prestashop1.7/en/9-casual-dresses
                                    [name] => Casual Dresses
                                    [desc] => You are looking for a dress for every day? Take a look at
our selection of dresses to find one that suits you.
                                    [children] => Array
                                        (
                                        )

                                )

                            [1] => Array
                                (
                                    [id] => 10
                                    [link] => http://localhost/prestashop1.7/en/10-evening-dresses
                                    [name] => Evening Dresses
                                    [desc] => Browse our different dresses to choose the perfect dress for an unforgettable evening!
                                    [children] => Array
                                        (
                                        )

                                )

                            [2] => Array
                                (
                                    [id] => 11
                                    [link] => http://localhost/prestashop1.7/en/11-summer-dresses
                                    [name] => Summer Dresses
                                    [desc] => Short dress, long dress, silk dress, printed dress, you will find the perfect dress for summer.
                                    [children] => Array
                                        (
                                        )

                                )

                        )

                )

        )

)
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...