
ross
Staff
/ Moderator

Nov 4, 2006, 6:35 PM
Post #1 of 5
(7124 views)
Shortcut
|
|
Tutorial: Number or articles in each category
|
Can't Post
|
|
Hey everyone. I was working on a site the other day and noticed it was actually displaying how many articles were available in little brackets next to each category's link in the navigation. In this tutorial, I'll explain how you can recreate this exact same effect with your installation of Article Manager 2. This is a great tutorial for you if you're just starting out with customizing Article Manager 2, you'll be amazed at just how powerful the publish rules feature really is.
Basically, you'll be creating a new publish rule that just creates one file for each category and only display the total number of articles it has. You then have your category menu template include the appropriate file and that's about it. You'll probably skim through this and think there is a lot to do. Don't worry; I just went over thing in as much detail as possible. It's actually pretty easy to get going. Let's have a look at it all in some more detail . Create Publish Rule The first step here is your template. I have actually attached a copy for you to use. Just upload numberOfArticles.html to your /templates/articleLists folder and you are ready to move on. All this template will do is use the $articleList.totalResults$ placeholder that displays the total number of articles for the current category. After uploading the template, you can create your publish rule. I'll go step by step for that one: 1. Log into Article Manager and go to Admin 2. From Admin, click on Publishing and then create (a new publishing rule). 3. For this part, if I don't specifically mention a setting while you are creating your rule, just leave it with its default value(s). 4. Rule Name. This can be anything you like. I suggest something like 'Number Of Articles'. 5. Rule Description. This can be anything you like. I suggest something like 'displays the number of articles in each category'. 6. Rule Type. Choose 'a list of articles'. 7. Template. Choose 'articleLists/numberOfArticles.html'. 8. Placeholder Set Name. You can use anything you like. For the rest of the tutorial though, I'll assume you used 'numberOfArticles'. Make a note of whatever you use here because it will come back into play latter on. 9. Published Files. Choose 'Category lists' and enter 'numberOfArticles<catNum>' for filename. And that's it for the publish rule. Make sure to save it before moving on . Update Category Template Next, download your copy of /categoryMenus/categoryMenu.html In this template, you'll be looking for this bit of code: <a href="$published.categoryIndex.url$">$category.name$</a> Change that to read: <a href="$published.categoryIndex.url$">$category.name$ <!--#include virtual="$published.numberOfArticles.webpath$" --></a> And upload the template. The final step will be to go back to the Publishing page and publish the new publish rule you create as well as Global Menu (default menu) and Category Menus (current category highlighted). And that's it! Piece of cake eh? What is going to happen now is you'll have the number of articles in each category appear in brackets next to the category's name in your category list. Tips One thing I found is that by default, you'll find that parent categories actually include the articles from their children categories. So if News had 10 of its own articles, and News -> Business had 5, your News category would show up as 15. You can have it so that only articles directly in a category count towards the number. To do that, modify your new publish rule and uncheck 'Subcategory Articles'. Another thing I found to be useful for organization is if you actually have the new publish rule create all its files in a separate folder. That's also done when you modify the rule. This time, it's under 'Publish Dir'. How does that all sound? Have a go at it and let me know what you all think . ----------------------------------------------------------- Cheers, Ross Fairbairn - Product Specialist support@interactivetools.com Hire me! Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting: http://www.interactivetools.com/consulting/
(This post was edited by ross on Nov 8, 2006, 10:34 AM)
|