Step 3: The Sub Category Page Web Template

  1. Create a new Web Template and call it “Category – Sub Categories Groups”
  2. Paste into the source the following:
{% assign categoryguid = categoryguid %}
{% assign limit = limit | default: 5 %}

{% assign category_url = sitemarkers['Category'].url %}

{% if categoryguid %}
  {% assign relatedcategories = knowledge.categories | related: categoryguid, limit %}
  {% if relatedcategories.size > 0 %}
    <div class="row">
      {% for category in relatedcategories %}
        <div class="col-md-4 col-xs-12">
          <div class="panel panel-default">
            <div class="panel-heading"><a href="{{ category_url | add_query: 'id', category.categorynumber | escape }}" class="title">{{ category.title | escape }}</a></div>        
                <div class="panel-body">
                    <p class="description">{{ category.description | escape }}</p>
                    {% include 'Knowledge Management - Most Popular Articles By Category' categoryguid: category.categoryid %}
                </div>
          </div>
        </div>
      {% endfor%}
    </div>
  {% endif %}
{% endif %}

This code will create one Bootstrap Panel for each subcategory that was set up.  Notice that we are using the current entity’s id as the related parameter to grab categories.  Also, take note that we are including a web template called “Knowledge Management – Most Popular Articles By Category” where we pass the category id in for for each sub-category.  Let’s create that template now.

Step 4: Most Popular Articles for a Category

  1. Create a new Web Template called “Knowledge Management – Most Popular Articles By Category”
  2. Copy the following liquid template into the source:
{% assign categoryguid = categoryguid %}
{% assign showdescription = showdescription | default: false %}
{% assign count = count | default: 5 %}
{% assign languagecode = website.selected_language.code %}
  {% fetchxml knowledgearticlecategory_query %}
      <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
        <entity name="knowledgearticle">
          <attribute name="articlepublicnumber" />
          <attribute name="knowledgearticleid" />
          <attribute name="title" />
          <attribute name="description" />
          <order attribute="articlepublicnumber" descending="false" />
          <filter type="and">
            <condition attribute="statuscode" operator="eq" value="7" />
            <condition attribute="isrootarticle" operator="eq" value="0" />
            <condition attribute="isinternal" operator="eq" value="0" />
          </filter>
          <link-entity name="knowledgearticlescategories" from="knowledgearticleid" to="knowledgearticleid" visible="false" intersect="true">         
              <filter type="and">
                <condition attribute="categoryid" operator="eq" value="{{ categoryguid }}" />
              </filter>         
          </link-entity>
          {% if portallanguagecode %}
          <link-entity name="languagelocale" from="languagelocaleid" to="languagelocaleid" alias="ad">
              <filter type="and">
                <condition attribute="code" operator="eq" value="{{ portallanguagecode}}" />
              </filter>
            </link-entity>
          {% endif %}
        </entity>
      </fetch>
    {% endfetchxml %}
  {% assign articles = knowledgearticlecategory_query.results.entities %}
  {% if articles.size > 0 %}
    <div class="list-group">
    {% for article in articles %}
      <div class="list-group-item clearfix" style="border:0">
        <a class="title" style="color:rgb(102, 102, 102) !important" href="{{ article.url | escape }}">{{ article.title | escape }}</a>
        {% if showdescription %}<p class="description">{{ article.description | escape }}</p>{% endif %}
      </div>
    {% endfor %}
    </div>
  {% endif %}

This template is reuses the fetchXML and general styles from the Category Details Web Template that comes with Dynamics Portals.

Step 5: Update Category Details Web Template

Speaking of the Category Details template, we will want to update it to include our grouping boxes.  Modify this web template with the following line where you would like the category boxes to appear:

{% include ‘Category – Sub Categories Groups’ categoryguid: categoryguid %}
 

Summary

The end result of this tutorial should be a nice looking and different experience for your end users that really only starts to take advantage of the customizations that can be accomplished with Dynamics 365 Portals.
Hopefully, this has provided you with a little insight into how to start to make the OOTB experience unique and custom for your own users.
 
Sound off in the comments as needed, and thank you for reading.
Images compliments of Pep Rally Inc artwork