Last x articles from a number of sections

10 posts by 2 authors in: Forums > CMS Builder
Last Post: December 16, 2010   (RSS)

Hi -
I'm slowly and painfully moving my site from AM (version 1 if anyone is old enough to remember that...) to CMS Builder. Most of it's done now, but I'm a bit stuck on how to re-produce one thing.

I have a number of different article types, all using different section editors. On the front page of the website I have links to the last four articles published. So something needs to search each article type, and get the most recent four, regardless of which section(s) they came from.

Hope I've explained that properly. If you can let me know how to do this I can re-use the solution in a number of slightly different ways on different pages.

Regards, Steve.

Re: [steve_e] Last x articles from a number of sections

By Jason - December 14, 2010

Hi Steve,

Would it be possible to have all your articles in one section and give each of them a category? This would probably be the best solution.

If not, how many different sections do you need to select from? If you can give me some more details, I can try to get an example for you.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Last x articles from a number of sections

Oh crikey - I haven't even looked at categories, but that sounds like it should fit. Before I rip the whole thing apart and start again, the two things I need to think about are:

1 - I wanted to create each section so that I could, for example, have meta description tags separately for the list and detail pages.
2 - I wanted to be able to have each article type with its own list page, so that each could have their own menu item.

Just to save me a bit of experimenting and fishing around, is it possible to do both of those with categories, and are there any tutorials on how categories work?

Thanks for the suggestion Jason - wish I'd asked before I started! [:|]

Re: [steve_e] Last x articles from a number of sections

By Jason - December 14, 2010

Hi,

I think that categories would still be a good fit for what you're trying to do.

1)You can have different meta tags for a list page as compared to a detail page. To do this, you can add a meta tag field to your category menu and your article section. When you're on a list page, use the meta tags for that category. When you're on a detail page, use the meta tags associated with that article.

2) Are you referring to on the site or in the CMS? On your site, you can have a menu that is just a list of categories. Clicking on a category will take you to a list page that will display a list of articles that use that category.

For some good tutorial threads, take a look here:
http://www.interactivetools.com/forum/gforum.cgi?post=85036#85036

There are 2 under "Advanced Viewer Functions" dealing with categories. Give this a try and let us know if you run into any difficulties.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Last x articles from a number of sections

Thanks Jason - I'll get back to you if I need help.
Regards, Steve.

Re: [steve_e] Last x articles from a number of sections

OK, that all worked out great thanks. I just have one thing I can't seem to do. I want to have a link back to each category index page from the detailed article page, and I can't make it work. I'm not sure if it's because of the way the categories and articles sections work together, but the standard code supplied gives this line:

<p class="ref" align="right"><a href="<?php echo $articlesMetaData['_listPage']; ?>"> Back to index</a><br />

which just leaves the reader on the same detail page when clicked. I'm not clever enough with php to work out how the _listPage should be working, so if you could advise I'd be grateful!

Best wishes,
Steve.

Re: [steve_e] Last x articles from a number of sections

By Jason - December 16, 2010

Hi Steve,

What is the list page that you want to get to? Can you attach the .php page you're working with so I can see what's happening in the code?

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [steve_e] Last x articles from a number of sections

By Jason - December 16, 2010

Hi,

You could try something like this:

<p class="ref" align="right"><a href="article_index.php?category=<?php echo $articlesRecord['category']; ?>"> Back to index</a><br />

You will have to change the variable name $articlesRecord and the field name 'category' to match what you have in your section and on your page. 'category' is the field where you're storing a records category.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Last x articles from a number of sections

Thanks very much Jason. It's the end of a long three days and that worked perfectly, which means I owe you a pint if you ever come over to the UK!
Best wishes,
Steve