-4

I have a customer who updates his site categories regularly, according to customer requests, and also adds a single level of subcategories to each category. He uses Categories section under Site Settings on BC admin to add these categories and subcategories.

I want a Category Accordion Menu on the left side of the home page that updates when the site categories are updated at a single location.

When you select a particular subcategory on the Category menu, I want a list of webapp items displayed that are identified with that subcategory.

I do not want to use drop down lists.

Is this possible? I am finding it difficult to find a solution.

Edit - Additional Information

The category menu works, thank you.

I now need to display a selectable list of subcategories in center column of page with the following process:

  1. Category is selected on left side column menu with link to category html page (for example - category.html) variable is passed to category page identifying category selected and 2 column subcategory list to display. Only subcategories related to Press releases are listed. Single category page for all categories - dynamic.

  2. Select subcategory from 2 column list in center column.

  3. Subcategory page is displayed (for example subcategory.html) and related Press Releases are displayed in a summary list under 2 column subcategory list in center column according to variable passed from selection of subcategory. Single subcategory page - dynamic.

  4. Press Release page is displayed (for example press-release.html) when a specific Press release is selected from Press Release summary list. A variable is passed from subcategory.html Press Release selection. Single Press Release page - dynamic.

3 variables: What category? What subcategory? What Press Release?

Question: What is the code to display a 2 column subcategory list that have related Press Releases? Category ID variable should be passed to category HTML page. Category, Subcategory and Press Release pages are dynamic, displaying according to variable passed to page.

The categories and Subcategories are created in BC admin under Site settings > categories.

If somebody else understands a solution, please feel free to add your answer.

4

1 回答 1

2

你的问题需要分解成几个部分:

  • 让 BC 呈现合适的 HTML
  • 从该 HTML 创建一个嵌套的“手风琴”
  • 根据所选分类更改页面内容

我将介绍第一部分。下面是一些示例代码,它们将生成嵌套ul标签以匹配分类结构:

{module_categorylist id="-1" template="" collection="allCats"}  
{% assign oCount = 0 -%}
{% assign thisCatId = "-1" -%}
{% assign parentCatId_L0 = "-1" -%}

<ul>
    {% for cat_L0 in allCats.items -%}
        {% assign oCount = oCount | plus: 1 -%}
        {% if cat_L0.parentId == parentCatId_L0 -%}
            <li>
                <a href="#{{ cat_L0.id }}">
                    {{ cat_L0.name }}
                </a>
                {% assign countedChildren = 0 -%}
                {% for catCounter in allCats.items -%}
                    {% assign oCount = oCount | plus: 1 -%}
                    {% if catCounter.parentId == cat_L0.id -%}
                        {% assign countedChildren = countedChildren | plus: 1 -%}
                    {% endif -%}
                {% endfor -%}

                {% if countedChildren > 0 -%}
                    <span>(+)</span>
                    {% assign parentCatId_L1 = cat_L0.id -%}

                    {% comment -%} Recursion starts here ... {% endcomment -%}

                    <ul>
                        {% for cat_L1 in allCats.items -%}
                            {% assign oCount = oCount | plus: 1 -%}
                            {% if cat_L1.parentId == parentCatId_L1 -%}
                                <li>
                                    <a href="#{{ cat_L1.id }}">
                                        {{ cat_L1.name }}
                                    </a>
                                    {% assign countedChildren = 0 -%}
                                    {% for catCounter in allCats.items -%}
                                        {% assign oCount = oCount | plus: 1 -%}
                                        {% if catCounter.parentId == cat_L1.id -%}
                                            {% assign countedChildren = countedChildren | plus: 1 -%}
                                        {% endif -%}
                                    {% endfor -%}

                                    {% if countedChildren > 0 -%}

                                        <span>(+)</span>
                                        {% assign parentCatId_L2 = cat_L1.id -%}

                                        {% comment -%} Recursion starts here ... {% endcomment -%}

                                        <ul>
                                            {% for cat_L2 in allCats.items -%}
                                                {% assign oCount = oCount | plus: 1 -%}
                                                {% if cat_L2.parentId == parentCatId_L2 -%}
                                                    <li>
                                                        <a href="#{{ cat_L2.id }}">
                                                            {{ cat_L2.name }}
                                                        </a>

                                                        {% comment -%} Recursion ends here ... {% endcomment -%}
                                                    </li>
                                                {% endif -%}
                                            {% endfor -%}
                                        </ul>

                                    {% endif -%}
                                </li>
                            {% endif -%}
                        {% endfor -%}
                    </ul>

                {% endif -%}
            </li>
        {% endif -%}
    {% endfor -%}
</ul>

<p># of classifications: {{ allCats.items | size }}</p>
<p>"operation" count: {{ oCount }}</p>

(我曾希望这可以在 BC 中干净利落地完成,但由于不支持自定义模板的module_categorylist标签for以及嵌套include语句中循环的不当行为,我的正确递归尝试被挫败了。)

这是一个输出示例:

<ul>
    <li>
        <a href="#14606">Company</a>

        <ul>
            <li>
                <a href="#45412">sub Company</a>

                <ul>
                    <li><a href="#45413">Sub Sub Company</a></li>
                </ul>
            </li>
        </ul>
    </li>

    <li><a href="#14744">Customers</a></li>

    <li>
        <a href="#45414">Foo</a>

        <ul>
            <li>
                <a href="#45415">Bar</a>

                <ul>
                    <li><a href="#45416">Baz</a></li>
                </ul>
            </li>
        </ul>
    </li>

    <li>
        <a href="#14609">Products</a>

        <ul>
            <li>
                <a href="#22634">Sub Products</a>

                <ul>
                    <li><a href="#45418">More Third Level Products</a></li>

                    <li><a href="#45409">Third Level Products</a></li>
                </ul>
            </li>
        </ul>
    </li>

    <li><a href="#14075">Root</a></li>

    <li><a href="#14610">Solutions</a></li>
</ul>

<p># of classifications: 14</p>

<p>"operation" count: 224</p>

至于您问题的其他部分,我会推荐嵌套手风琴问题的现有解决方案,并注意您可以将module_url标签GET请求结合使用,以检索标有给定分类的项目。

于 2015-03-08T04:44:42.300 回答