List All Titles in Section

9 posts by 3 authors in: Forums > CMS Builder
Last Post: January 19, 2010   (RSS)

Re: [invisions] List All Titles in Section

By Donna - January 18, 2010

Hi Invisions,

Sure, absolutely -- just create a "List" page, and remove all of the code save for the article titles. Your code may vary depending on your field names and such, but it will look something like this:

<?php foreach ($mainRecords as $record): ?>
<?php echo $record['title'] ?><br/>
<?php endforeach ?>


Is that the sort of thing you're looking for?
Donna

--
support@interactivetools.com

Re: [Donna] List All Titles in Section

I am trying to list all article titles in a given section, in this case the section is 'site_characterization_remediation'. I would like all page titles listed vertically, with 10 to a page.

I used the code you provided, but it only lists the title of the very first article in the section, and not all of them.

Not only do I want to list the titles, but also have each title selectable so that page will open if clicked.

Would you be able to help me with the above mentioned?

Thank you.
Daniel Pegues
invisionshosting.com

Re: [invisions] List All Titles in Section

By Donna - January 18, 2010

Hi Invisions,

You can get all of this code by default from the code generator -- have you taken a look at that? Under Admin, click Code Generator, and choose the section you want to create a list for. Make sure you've got "List Page" selected, then modify the viewer options to match what listings you want. For example, since you want 10 listings per page, click the "Show 10 records per page with prev & next page links" button.

Then click "Show Code" and this will give you the default code. You can remove any unnecessary bits (record number, etc) and just leave in the fields that you want to display.

Give that a try and let me know how it works for you. :) If you're still stuck, try attaching a copy of the file you've created to your response and we can see what you've got so far.
Donna

--
support@interactivetools.com

Re: [Donna] List All Titles in Section

Hey Donna,
Thanks so much for the reply. I forgot to change:

'perPage' => '1',

to

'perPage' => '10',

All the titles are listed now, but it is not possible to select one of the titles to open the full document. Also, how would I set the titles to be listed as an ordered list?
Daniel Pegues
invisionshosting.com

Re: [invisions] List All Titles in Section

By Chris - January 18, 2010

Hi invisions,

To make the titles link to your detail pages, change this:

<?php echo $record['title'] ?>

to this:

<a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a>

To use an ordered list, simply use this code:

<ol>
<?php foreach ($mainRecords as $record): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a></li>
<?php endforeach ?>
</ol>


Please note that you'll need to change the name of the records variable (in red above) to match your own.

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

Re: [chris] List All Titles in Section

Thank you Chris for the help. What you told me to do works, and works great. However, now, when I click a link, it tells me this:

Set Detail Page Url for this section in: Admin > Section Editors > Viewer Urls

-----------------------------

Also, there is something else I wanted to ask now. All my articles are organized in different sections, as is suppose to be. But, what I want to do is also have a subcategorization of my articles, such as subcategory 1, 2, 3 and so on, and when a button is clicked, those articles with the subcategorization will be displayed. Is it possible to do this?
Daniel Pegues
invisionshosting.com

Re: [invisions] List All Titles in Section

By Chris - January 18, 2010

Hi invisions,

I used the '_link' psuedo-field in the above example; this field is populated by CMS Builder based on what you've set for your section's Viewer Urls. You'll need to either set this up for your section (Admin > Section Editors > your section > Viewer Urls) or generate your URLs with custom PHP code any time you need to output them. The former is much simpler. :)

---

Subcategorization is definitely possible. The usual approach is to create a Category (Multi Record) section, populate it with your categories, then create a List field in your Article section called "category" which is set up with:

Display As: Pulldown
List Options: Get options from database (advanced)
Section tablename: Category
Use this field for option values: num
Use this field for option labels: title


Now you can create a list viewer for your Category section and change the from:

<a href="<?php echo $record['_link'] ?>">

to

<a href="article_list.php?category=<?php echo $record['num'] ?>">

Where "article_list.php" is the URL to your existing article list viewer. Voila!

Once you have this working, you can consider having one page show both your list of categories and your list of articles from that category. If you want help with this, please post both your list page viewers' full PHP sources (as attachments please).

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

Re: [chris] List All Titles in Section

Thanks so much for your reply Chris. I will definitely incorporate this into my site.

If I have any other questions, I will write back.

Thanks again.
Daniel Pegues
invisionshosting.com