Sorting News Articles in ALUI Publisher

Out of the box, WebCenter Interaction Publisher has a News portlet template that allows Content Managers to create News Articles, and display them in a summary portlet with a link to see the entire list of articles.  The articles themselves are:

  1. stored as Content Items under the -article_path-/ Articles folder,
  2. created based on the templates in /Portlet Templates/ _NEWS/ en/, and
  3. rendered by the “Main Page” (the portlet itself showing the top n articles) and “Index” (the list of all news articles when the user clicks “more”) Presentation Templates.

The problem is, the articles are listed based on when they were published, not when they were created or modified.  Which doesn’t make sense all the time – what if someone goes in and publishes the entire folder?  You’d end up with all news items showing up on the same day.  The fix here is to update the two Presentation Templates mentioned above to sort and display on when the “article” Content Items were modified, not published.

What you may not know is that when a user creates a portlet from a Publisher template (such as the one in /Portlet Templates/ _NEWS/ en/), Publisher creates a COPY of ALL OBJECTS into the new Publisher folder the Content Manager specifies when creating it.  The implication here is that you not only need to apply these fixes to the Content Item TEMPLATES in Publisher, but also each individual News Portlet independently.  (Or, you could use something like PublisherManager, but that’s another story entirely).

However you do it, the changes that need to be made can be found after the break.

“Main Page” Presentation Template:

Change:


<pcs:foreach var="item" expr="filter(list.items, 'filtered.published &amp;and; !filtered.hidden')"

><pcs:if expr="item_position &amp;le; maxitems">

       <tr>

              <td width="60%" height="30"><a href="#"pcs_id"></pcs:value>('<pcs:value expr='item.location'></pcs:value>'); return false;"><pcs:value expr="encode(item.headline)"></pcs:value></a><br>

                     <span><pcs:value expr="item.published" format="MM/dd/yyyy h:mma z"></pcs:value></span><br>

                     <span><pcs:value expr="encode(item.abstract)"></pcs:value></span>

              </td>

       </tr>

       <pcs:if expr="item_position == maxitems &amp;and; item_size &amp;gt; maxitems">

              <tr><td align="right"><a href="#">View All...</a></td></tr>

       </pcs:if>

</pcs:if

></pcs:foreach>

… To:


<pcs:foreach var="item" expr="sort(filter(list.items, 'filtered.published &amp;and; !filtered.hidden'),'modified',false)"

><pcs:if expr="item_position &amp;le; maxitems">

       <tr>

              <td width="60%" height="30"><a href="#"pcs_id"></pcs:value>('<pcs:value expr='item.location'></pcs:value>'); return false;"><pcs:value expr="encode(item.headline)"></pcs:value></a><br>

                     <span><pcs:value expr="item.modified" format="MM/dd/yyyy h:mma z"></pcs:value></span><br>

                     <span><pcs:value expr="encode(item.abstract)"></pcs:value></span>

              </td>

       </tr>

       <pcs:if expr="item_position == maxitems &amp;and; item_size &amp;gt; maxitems">

              <tr><td align="right"><a href="#">View All...</a></td></tr>

       </pcs:if>

</pcs:if

></pcs:foreach>

“Index” Presentation Template:

Change:


<!-- start Documents -->

<table width="100%" border="0" cellspacing="2" cellpadding="2">

<pcs:foreach var="item" expr="filter(items, 'filtered.published &amp;and; !filtered.hidden')"

> <tr>

              <td width="60%" height="30"><a href="#"pcs_id"></pcs:value>('<pcs:value expr='item.location'></pcs:value>'); return false;"><pcs:value expr="encode(item.headline)"></pcs:value></a><br>

                     <span><pcs:value expr="item.published" format="MM/dd/yyyy h:mma z"></pcs:value></span><br>

                     <span><pcs:value expr="encode(item.abstract)"></pcs:value></span>

              </td>

       </tr>

</pcs:foreach>

</table>

<!-- end Documents -->

… To:


<!-- start Documents -->

<table width="100%" border="0" cellspacing="2" cellpadding="2">

<pcs:foreach var="item" expr="sort(filter(items, 'filtered.published &amp;and; !filtered.hidden'),'modified',false)"

> <tr>

              <td width="60%" height="30"><a href="#"pcs_id"></pcs:value>('<pcs:value expr='item.location'></pcs:value>'); return false;"><pcs:value expr="encode(item.headline)"></pcs:value></a><br>

                     <span><pcs:value expr="item.modified" format="MM/dd/yyyy h:mma z"></pcs:value></span><br>

                     <span><pcs:value expr="encode(item.abstract)"></pcs:value></span>

              </td>

       </tr>

</pcs:foreach>

</table>

<!-- end Documents -->

Tags: , ,

2 Responses to “Sorting News Articles in ALUI Publisher”

  1. Geoff Garcia says:

    Correct me if I’m wrong, but doesn’t adding a sort prevent the ability to manipulate the order via the index content item?

    We use the approach you mentioned for the majority of our news portelts with the exception of our home page. There we use release and expire date fields (added to the DET) which allow content managers to schedule publishing which avoids the published/created/modified issues spoken of here.

  2. Matt Chiste says:

    Geoff, you’re right – Publisher does have the ability to ORDER articles in any way you want, but SORTING isn’t an option in that selection list. It’s easy to tell Content Managers to order the articles any way they want, but it is extra work after editing an old article to go to the “main” content item to change the order manually. This approach handles that automatically, performing a “sort” on date rather than respecting the specified “order”. Either one is perfectly valid.

Leave a Reply