Need help pulling database info into a list

7 posts by 2 authors in: Forums > CMS Builder
Last Post: June 5, 2008   (RSS)

By TonyRC65 - June 3, 2008 - edited: June 4, 2008

Ok, this is a little confusing even for me and I'm the one that knows what I'm trying to do so stick with me here!

On the front page of the site I'm building, there is a box for featured writers. The space will have a small photo of the writer along with their name that will link to a bio page. That part I can figure out. Where I'm stuck is I also want to display a short list, maybe 2 or 3, of their most recent articles next to their name on the front page. The information is gathered by the database when they type the original articles into other sections of the site. I just don't know how to extract it and make it display on the front page.

To add another twist to the whole thing... I have more writers than will fit on the main page. I only want to display about 4 or 5. I need the list of photos, names, and articles (all grouped together by person) to change dynamically based on whoever wrote the most recent article.

I think I'm in over my head on this one but I'm betting someone here might be able to help me out.

Thanks!

Tony

Re: [TonyRC65] Need help pulling database info into a list

By Dave - June 4, 2008

Hi Tony, welcome to the CMS Builder forum! :)

So let me just make sure I'm clear on your setup. You have section editors setup for writers and articles. Is that right?

And on the frontpage you want to show the 3 writers who have most recently created an article? And beside their name you want a list of the 5 most recent articles (sorted by created date) that they have created?

Let me know if that's right and I'll give you some code for that. Also, if you have an url with a mockup that would be helpful.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Need help pulling database info into a list

By TonyRC65 - June 4, 2008 - edited: July 7, 2008

Yup, sounds good! I probably only need to display the titles of each person's 3 most recent articles, not 5, but otherwise that sounds right.

I'm not sure which database field to use to guarantee that each article they type is matched to the author. The articles they will each write are going to be under the section editor labeled "Staff Contributors" while their photo and biography information is located in the standard CMS section "Staff Bios".

Here's a link to what will be the main page of the site where I need this to display. You can see the Staff Contributors area in the bottom right.

http://www . rescue cuts . com

I'll also need the same type of thing for the staff bios list page which will include ALL of the articles each contributor has written listed next to their name as seen here: http://www . rescue cuts . com /bio_list.php

If you need access to the CMSAdmin area, I'll setup an account for you to look around. Just let me know.

Thanks!

Re: [TonyRC65] Need help pulling database info into a list

By Dave - June 4, 2008

Hi Tony,

Yea, if you could email me CMS login details to dave@interactivetools.com (email, don't post login details to the forum) that would help. Then I'll post some code back here and make sure I have your fields right.

I don't think it's possible to get the "latest posters" through CMS Builder directly, but we should be able to do it with a short MySQL query.

Email me some login details for your CMS Builder and I'll write something up.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [TonyRC65] Need help pulling database info into a list

By Dave - June 5, 2008

Hi Tony,

Let's start with the bio list because that will be simpler and then we can build up from there.

There's multiple writers on the bio page right now. What articles do you want listed along the side? Or do you want the articles listed under the persons bio?
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Need help pulling database info into a list

By TonyRC65 - June 5, 2008 - edited: June 5, 2008

The bio page is essentially the way I want it now minus the articles list for each person who writes articles.

I'm not sure what the best way to attack the article list is. If necessary, I can create a user account for each person who will be submitting articles. If I do that, the database should be able to pull the correct articles into the list simply by searching for all articles written by a particular user ID right?

Is there a better way that wouldn't require creating accounts for them? If I do create accounts for them, can I have the articles they write go to a pending state before being visible on the site like in the old article manager?

Currently, there are no articles on the site by any of the featured writers. I'm holding off posting any until I figure out the best method of doing so.

Essentially, the home page, the bio list page, and the individual bio pages will all have someone's name, photo, title, and a list of the articles they've written.