Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Dispaly Category And Sub Category And Sub-Subcategory Rate Topic   - - - - -

 

Posted 21 July 2019 - 06:49 AM #1

hi,

please help me for show category tree....

i want show category and subcategory and sub-subcategory

for example:

cat 1

cat 2

    sub cat 1

    sub cat 2

cat 3

    sub cat 1

    sub cat 2

        sub-sub cat 1

        sub-sub cat 2

cat 4

 

i want show in <ul><li> and design is over. But I don't know what code should take to display it:

With the following code, I could only display the category without its subcategories:

{assign var="all_categories" value=0|fn_get_plain_categories_tree:false}
<div class="cat-menu">
    <span href="" class="cat-menu-span"><img src="..."></span>
    <div class="content">
        <ul>
            <li><a><span class="img"><img src="..."></span><span rel="{$cat.category_id}" class="text" >{__("all_categories")}</span></a></li>
            <li><a>{$cat.category}</a></li>

please help me.



 

Posted 21 July 2019 - 07:03 AM #2


{assign var="all_categories" value=0|fn_get_plain_categories_tree:false}
<div class="cat-menu">
    <span href="" class="cat-menu-span"><img src="..."></span>
    <div class="content">
        <ul>
            <li><a><span class="img"><img src="..."></span><span rel="{$cat.category_id}" class="text" >{__("all_categories")}</span></a></li>
            <li><a>{$cat.category}</a></li>

excuse me a right code:

{assign var="all_categories" value=0|fn_get_plain_categories_tree:false}
<div class="cat-menu">
    <span href="" class="cat-menu-span"><img src="..."></span>
    <div class="content">
        <ul>
            <li><a><span class="img"><img src="..."></span><span rel="{$cat.category_id}" class="text" >{__("all_categories")}</span></a></li>
            
            {foreach from=$all_categories item="cat"}
                <li><a>{$cat.category}</a></li>
            {/foreach}


 

Posted 23 July 2019 - 07:08 AM #3

 

excuse me a right code:

{assign var="all_categories" value=0|fn_get_plain_categories_tree:false}
<div class="cat-menu">
    <span href="" class="cat-menu-span"><img src="..."></span>
    <div class="content">
        <ul>
            <li><a><span class="img"><img src="..."></span><span rel="{$cat.category_id}" class="text" >{__("all_categories")}</span></a></li>
            
            {foreach from=$all_categories item="cat"}
                <li><a>{$cat.category}</a></li>
            {/foreach}

please help meeee.... pleaseeeeee



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19848 posts

Posted 23 July 2019 - 12:36 PM #4

I think, you should not use plain tree here if you want to put subcategories to individual ul containers


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 

Posted 27 July 2019 - 05:46 AM #5

I think, you should not use plain tree here if you want to put subcategories to individual ul containers

 

Can you please guide me what can I use instead? thank you


 

Posted 27 July 2019 - 06:46 AM #6

 

Can you please guide me what can I use instead? thank you

 

I want to show the categories as follows:

<ul>
    <li>All category</li>
    <li>cat 1</li>
    <li>cat 2
        <ul>
        <li>sub 1</li>
        <li>sub 2</li>
        </ul>
    </li>
    <li>cat 3
        <ul>
        <li>sub 1
            <ul>
                <li>sub sub 1</li>
                <li>sub sub 2</li>
            </ul>
        </li>
        <li>sub 2</li>
        </ul>
    </li>
</ul>


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19848 posts

Posted 29 July 2019 - 06:48 AM #7

Try something like

{$categories = []|fn_get_categories_tree}
<ul>
{foreach from=$categories item=cat1}
    <li>
        {$cat1.category}
        {if $cat1.subcategories}
        <ul>
            {foreach from=$cat1.subcategories item=cat2}
            <li>
                {$cat2.category}
                {if $cat2.subcategories}
                <ul>
                {foreach from=$cat2.subcategories item=cat3}
                <li>
                    {$cat3.category}
                </li>
                {foreach}
                </ul>
                {/if}
            </li>
            {foreach}
        </ul>
        {/if}
    </li>
{/foreach}
</ul>

(!) Not tested


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 

Posted 30 July 2019 - 01:25 AM #8

Try something like

{$categories = []|fn_get_categories_tree}
<ul>
{foreach from=$categories item=cat1}
    <li>
        {$cat1.category}
        {if $cat1.subcategories}
        <ul>
            {foreach from=$cat1.subcategories item=cat2}
            <li>
                {$cat2.category}
                {if $cat2.subcategories}
                <ul>
                {foreach from=$cat2.subcategories item=cat3}
                <li>
                    {$cat3.category}
                </li>
                {foreach}
                </ul>
                {/if}
            </li>
            {foreach}
        </ul>
        {/if}
    </li>
{/foreach}
</ul>

(!) Not tested

 

Hello. I really reallyyy thank you. I don't know how to appreciate you!

 

Please answer another question, thank you.

I find the code for the category ID:

{$cat1.category_id}

But I don't know what code to use to get the category link!
I also used the following code to display categories images but it didn't work!
 

{include file="common/image.tpl"
    show_detailed_link=false
    images=$cat1.category_id
    no_ids=true
    image_id="category_image"
    image_width=32
    image_height=28
}


 

Posted 30 July 2019 - 05:52 AM #9

 

Hello. I really reallyyy thank you. I don't know how to appreciate you!

 

Please answer another question, thank you.

I find the code for the category ID:

{$cat1.category_id}

But I don't know what code to use to get the category link!
I also used the following code to display categories images but it didn't work!
 

{include file="common/image.tpl"
    show_detailed_link=false
    images=$cat1.category_id
    no_ids=true
    image_id="category_image"
    image_width=32
    image_height=28
}

my friends for display category image i use code:

{$main_pair = $cat1.category_id|fn_get_image_pairs:'category':'M':true:true}

{include file="common/image.tpl"
    show_detailed_link=false
    images=$main_pair
    no_ids=true
    image_id=$cat1.category_id
    image_width=32
}

but not found code for category url



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19848 posts

Posted 30 July 2019 - 06:34 AM #10

Try

<a href="{"categories.view?category_id=`$cat1.category_id`"|fn_url}">{$cat1.category}</a>

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 

Posted 30 July 2019 - 02:17 PM #11

 

Try

<a href="{"categories.view?category_id=`$cat1.category_id`"|fn_url}">{$cat1.category}</a>

tanks for help me my dear friend... :wub: :wub: :wub: :wub:



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19848 posts

Posted 31 July 2019 - 05:31 AM #12

You are welcome! :)


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.