Featured Article from existing Articles section

12 posts by 2 authors in: Forums > CMS Builder
Last Post: January 14, 2010   (RSS)

[font "Verdana"]Hello,
I have an article section with articles that are feeding into various categories (Pregnancy, Elementary Years, Preschoolers, etc.) On each main category page, I feed the articles for that topic on a page by using a where statement. I need to have a featured article section on the page that will be a section that shows 3 featured articles that shows the thumbnail photo, title and summary. This information pulls from the articles section in my backend that I have already built. I am trying to figure out a way to get the featured articles to pull in on the page.


[font "Verdana"]The issue is how to feed in a selected article from my articles section into the featured section. I need to feed in the photo, title and summary from a specific article. I don't know the best way to get in a specific article or article id number that the user can update or change out when they want a new article to appear in that section. That is where I am stumped.


Here is an example of the main page design: the featured area in the middle with the 3 photos, title and summary text and the articles that pull in are at the bottom (this area is working/has php coding).
http://www.carolinaparent.com/test/elementary.php

Thank you,
April

Re: [apdance9] Featured Article from existing Articles section

By Chris - December 10, 2009

Hi April,

I think the easiest way to get this working is to add a field called "featured" (make it a checkbox field), then add some code to list articles with the following restrictions:

'where' => 'featured = 1',
'limit' => 3,

That way, you'll be displaying the latest 3 featured articles in that list.

If you need some help setting that up, please post the full PHP source code for your existing main category page.
All the best,
Chris

Re: [chris] Featured Article from existing Articles section

By design9 - December 11, 2009 - edited: December 11, 2009

Hi Chris,
The only issue is that I already have a where clause on the page that feeds in my full list of articles for a specific topic/category. Can I have 2 where clauses on a page? I didn't think I could but I am not sure.

I had originally set up a featured checkbox in the articles section but we realized that would not work as it pulled the featured article to every page of all the categories that where selected (pregnancy, elementary, teens instead of it only pulling on pregnancy page) which we did not want. They want the featured coding to be on the main page so they can pick a specific article to be on that page only (by id number?) and can change it out whenever they want a new article to appear (within the article section they would have to go back in and find the article to remove the coding when ready).

The issue may be that the articles that are selected in the featured article section will not always be the latest featured articles. The editors/users want to be able to put in any article from the articles section. That is why I was thinking I would need some type of coding so they can insert the id number of the article in a backend field that will pull in the title, summary and link. Any suggestions?

Thanks!
April

Re: [apdance9] Featured Article from existing Articles section

By Chris - December 11, 2009

Hi April,

You can combine where clauses with AND or OR, for example:

'where' => "featured = 1 AND category = 12",

Using this, you can place featured articles on category pages, only displaying the features articles within that category.

If you have another page which needs to display certain articles from all categories, you could add another checkbox field (e.g. main_page_featured).

Hardcoding record numbers can come back to bite you, so if you can accomplish something with checkbox fields, you'll be much better off in the long run.

I hope this helps. Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Featured Article from existing Articles section

Thanks Chris,

This can work but this takes me back to my original set-up issue where I check the featured article box to have a certain featured article pull in. The issue is that under the article, the user can select multiple categories to have the articles feed onto the page. The issue is if I check the featured box for a specific article and that article has pregnancy and elementary as a category so the article feeds onto both of those topic pages, is there any way to control having the featured article section only appear on the pregnancy page and not the elementary page? Also, if I use this set-up, I would need a way to make the featured article section expire without making the entire article expire. Is that possible?

Also, can you give me a brief explanation of why it is not good to hard code with the id numbers? This way I can explain it further to the editors because they want it set it up that way, which I don't agree.

Thanks!

April

Re: [chris] Featured Article from existing Articles section

Thanks so much Chris,

I will give this a try! What I am doing with the articles section, is in the backend I have my category multi-select dropdown and when an user puts in a new article, they can select that article to appear on as many of the category pages that they selected. Then I have a where statement on each category page that feeds in all the articles that have been tagged for that category.

One last question: Can I still combine this where clause (one you highlighted in red in last post) with my other where clause that I already have on the page? this is my page that I already have up: http://www.carolinaparent.com/test/elementary.php[/#000000]

Here is that code:[/#000000]

<?php
require_once "d:/hosting/member/acraig/site1/cmsadmin/lib/viewer_functions.php";

list($articlesRecords, $articlesMetaData) = getRecords(array(
'tableName' => 'articles',
'where' => " category LIKE '%\tElementary\t%' ",
));

?>

Thanks for all your help!

April

Re: [apdance9] Featured Article from existing Articles section

By Chris - December 17, 2009

Hi April,

If you want to display two lists (i.e. all the articles for a category and only the featured articles for a category) you'll need to use two getRecords() calls with two separate where clauses.
All the best,
Chris

Re: [chris] Featured Article from existing Articles section

By design9 - January 13, 2010

Chris,

I tried this and just need some help on the coding that I place lower on the page where the featured articles will appear. Can you guide me of what that should be? I have the coding at the top that you gave me but can't figure what coding I place to get the featured article to appear from the article id number. Right now, it just displays the id numbers that I entered into the field. I can't figure out what I am missing. My brain is not working.

Thanks!

April

Re: [apdance9] Featured Article from existing Articles section

By Chris - January 13, 2010

Hi April,

Can you please attach your full PHP source code for the page in question?
All the best,
Chris