Ecshop Commodity Sub-categories Click Dropdown, sub-category empty, direct jump function

Source: Internet
Author: User

The template file loops through the product classifications and assigns a URL attribute to the large category. Then in JS to determine whether there are sub-categories. There are categories to click the drop-down effect, no sub-classification to jump to the URL property link.

Themes/**/library/category_tree.lbi:

<Divclass= "NavBar">  <DivID= "Cate">  <!--{foreach from= $categories _pro item=cat Name=categories_pro} -        <H1class= "H1">        <DT> <ahref= "javascript:;"URL= "{$cat. URL}">{$cat. name|escape:html}<spanclass= "Searchleft"></span></a> </DT>        </H1>        <ul{if $cat. ID eq $parent _id_show}style= "Display:block"{/if}>         <!--{foreach from= $cat. cat_id Item=child} -        <Li><ahref= "{$child. URL}"{if $child. ID eq $category}class= "Current"{/if}>{$child. name|escape:html}</a></Li>        <!--{/foreach} -        </ul>        <Divstyle= "Clear:both"></Div>        <!--{/foreach} - </Div></Div>

/js/common.js:

//List page product category left navigation click Toggle$ ("#cate H1"). Click (function(){        if($( This). Next ("UL"). Find ("Li"). Length = = 0) {Location.href= $( This). Find ("a"). attr ("url");//Location.href Implementing a jump to a client page        }        Else {             if($( This). Next ("UL"). Is (": Visible"))            {                $( This). Next ("UL"). Hide (); }            Else            {                $("#cate ul"). Hide (); $( This). Next ("UL"). Show (); }        }    })

Ecshop Commodity Sub-categories Click Dropdown, sub-category empty, direct jump function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.