Main
Index
Search
Posts
Who's
Online
Log
In

Home: Discontinued/Classic Products: Article Manager 2:
Tutorial: Number or articles in each category

 

 


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 Smile.

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 Smile.

Update Category Template

Next, download your copy of /categoryMenus/categoryMenu.html

In this template, you'll be looking for this bit of code:


Code
  <a href="$published.categoryIndex.url$">$category.name$</a>


Change that to read:


Code
  <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 Smile.
-----------------------------------------------------------
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)
Attachments: numberOfArticles.html (0.15 KB)
  numberofarticles.gif (2.35 KB)


civilizednation
User

Apr 9, 2007, 2:04 PM

Post #2 of 5 (6870 views)
Shortcut
Re: [ross] Tutorial: Number or articles in each category [In reply to] Can't Post

People who use php should use this include:


Code
<? include("$published.numberOfArticles.filepath$") ?>



fmg
User

Dec 12, 2007, 6:01 AM

Post #3 of 5 (6436 views)
Shortcut
Re: [ross] Tutorial: Number or articles in each category [In reply to] Can't Post

This is great!


(This post was edited by fmg on Dec 12, 2007, 7:19 AM)


ibis70
User

Apr 9, 2009, 1:08 AM

Post #4 of 5 (4338 views)
Shortcut
Re: [ross] Tutorial: Number or articles in each category [In reply to] Can't Post

Dear Ross,
This is a great feature however I am having a problem with publishing. The rules run into an error at one point and publishing times out.

The error I am getting is:
Error: categoryNums does not contain any categories! at /home/users/web/b1083/ipw.dolcevia/public_html/cgi-bin/artman2/modules//IT/ArtMan/CustomMenus/Publish/ArticleLists.pm line 249.

How do you suppose I should try and fix this. I included all categories in which I would show numbers. There is only one rule such as this.


Donna
Staff / Moderator


Apr 10, 2009, 11:49 AM

Post #5 of 5 (4263 views)
Shortcut
Re: [ibis70] Tutorial: Number or articles in each category [In reply to] Can't Post

Hi there,

Make sure all of your publish rules have at least one category selected. That error is caused when a publish rule tries to publish, but has nothing assigned to it to publish. :)

Donna

--
support@interactivetools.com