Try our conversational search powered by Generative AI!

Jeff Wallace
Sep 26, 2011
  4034
(2 votes)

Category Listing Composer Block

Based on CMS 6 R2, Composer 4 R2, and Composer 4 R2 Blocks

Earlier this month I wrote a blog about a Category Listing Dynamic Content Module which allows content authors to create listings based on one-to-many categories.  I also referenced a blog by Allan Thraen and his blog regarding using Page Providers to display an alternate navigation based on categories.  Continuing down this same path Jacob Kahn and I co-authored a Composer Block which borrows code from the Dynamic Content module to yield a Composer Block with similar functionality.

 

How do you use the Category Listing Composer Block?

The basics of how to use this are as follows.  After entering “Composer – Edit on Page” mode…

 

1) Select “Category Listing” from the Composer Toolbox Content Blocks.

image

2) Optionally enter a “Heading” for the listing.

3) Select the “StartPoint” for the area of the tree structure where you want the module to begin searching categories.

4) Enter one-to-many category names that the listing will be based on.

a) If a category exists in the system as you type it will be presented for you. Simply select it.

image

b) If you enter a category that is not already present in the system, select the “+” button, and it will be added below the category control as well as to the category list in the backend.

5) Optionally enter a “Start” and “End” date to filter the items in the listing based on the “Start publish” date. This is useful if you only want to list items that were published within a certain timeframe.

6) Select a “Sorting” order.

7) Select “ShowDate” if you want a date to be included in the listing.

8) Select “ShowPreviewText” if you want the preview text to be included in the listing.

image

 

9) Select “Save” to Save the settings.

10) Save the page by your preferred method (“Save and View”, etc)

 

image

 

11) View the result:

 

image

 

How do you set up the Category Listing Composer Block?

Great question.  A lot of people are using NuGet or EPiServer module files to deploy add-on modules these days.   Since this is a Composer block, a sample project existing that’s easy to add to, and maybe because I’m writing this on a Monday I’m going to provide the manual approach for the time being.  I may rethink this later and provide an updated blog.  For now, the steps are below and are based on the assumption that you’ve already set up a site with EPiServer CMS, Composer, and the Composer Blocks.

1) Download the code and import file.

2) Decompress the downloaded zip file with your tool of choice (Windows Explorer, WinZip, WinRar, etc).

3) Locate the “ComposerSampleTemplates” project. This file is typically located at your site installation path (e.g. C:\EPiServer\Sites\<mySiteName>\ComposerSampleTemplates.csproj).

4) Open the ComposerSampleTemplates.csproj file in Visual Studio.

5) In “Windows Explorer”, locate the CategoryListing folder that was extracted in step 2 above.

6) Add the entire contents of this folder to the ComposerSampleTemplates project in Visual Studio under the Composer\Functions folder path.  The easiest way to do this is probably to simply drag-and-drop the CategoryListing folder that was extracted from the zip file onto the Functions folder in your project.

image

7) Build the project.  This should update the assembly in the bin directory with the new code.

8) Navigate to EPiServer CMS Admin Mode.

9) Navigate to the “Admin” tab.

10) Select “EPiServer Composer – Import/Export”

image

11) Use the “Browse” button to locate the ContentListingComposerData.xml folder that was extracted in step 2 above.

image

12) Select the “Begin Import” button.

image

13) Assuming all is successful, this should add the “Category Listing” block to your list of “Block Types” for Composer which you can configure as you would any other Composer blocks.  See the EPiServer Composer documentation for more information on configuring Rules, Access Rights, etc.

image

 

You should now be able to use the Category Listing Composer Block as noted in the “How do you use the Category Listing Composer Block?” section above.

 

Please note, this is intended as a starting point for you to customize for your project needs. The code is provided “as is” without warranty or guarantee of operation. Use at your own risk. Good luck and enjoy!

Sep 26, 2011

Comments

Sep 26, 2011 11:13 PM

Very nice! Thanks and always quality work.

Please login to comment.
Latest blogs
Microsoft announces Natural language to SQL

Finally, Microsoft launches "Natural language to SQL," after it has been available for several months in Optimizely CMS!

Tomas Hensrud Gulla | May 23, 2024 | Syndicated blog

Five easy ways to start personalizing your content right now

If you clicked on this article, you already know that getting the right message to the right person at the right time helps drive conversions and...

Kara Andersen | May 23, 2024

ExtendedCms.TinyMceEnhancements – serwer side webp support

Today I will introduce another small feature of TinyMceEnhancements plugin. The functionality is used to automatically detect whether a browser...

Grzegorz Wiecheć | May 22, 2024 | Syndicated blog

Azure AI Language– Detect Healthcare Content in Optimizely CMS

In this blog post, I showcase how the Azure AI Language service's Text Analytics for health feature can be used to detect healthcare content within...

Anil Patel | May 22, 2024 | Syndicated blog

Stott Security Version 2 So Far

In December 2023, I unveiled the initial version of Stott Security version 2. Although I typically announce each version I release on LinkedIn and...

Mark Stott | May 22, 2024

Optimizely Data Platform (ODP) Page Scroll Tracking

As with my last post, this isn’t a “getting started with ODP” — to get started with ODP, check out the developer docs,   “Implement the ODP...

Daniel Isaacs | May 22, 2024