List and Detail pages

6 posts by 2 authors in: Forums > CMS Builder
Last Post: September 27, 2008   (RSS)

Hello all.

I am a little confused about List and Detail pages.

I want to be able to create multiple pages per directory. So, for instance, if I make a section about dogs, I would like an index page and numerous other pages (like dog toys, leashes, dog food) in the same section. Then I would like to do a different page for, I dunno, Cats.

I have an html template setup. But I'm not sure what code to put on it. The List.php? The Details.php. I did the list and it put out all of the articles on that page and it was a mess. I did the Details code and I went to create new content and it overwrote the previous content.

So I'm just confused about how to create an index page and be able to easily create new content on the fly without having to keep going in and messing with the code.

Any help would be appreciated.

Dave

Re: [thedmp] List and Detail pages

By MisterJim - September 27, 2008 - edited: September 27, 2008

Dave,

Let's say that you want an index page-- a place where you're going to list the various articles that you have about dogs. To keep it simple, let's assume that all you're going to have on that page is the title of the article that, when clicked, will take you to the (detail) page that will display the full article.

First, make sure that the section you're using is a Multi Page type section. You can't get a List page on a Single Page type section.

Once that's done, select the section that you're working in within the Section Editor. Then click on the Viewer Urls tab up top and type in the names of a list page (let's call it dogIndex.php and a detail page ( dogDetail.php ). Then click on 'Save Details'.

Now, go back into that section and click on 'Viewer Code Generator'. Make sure the section that you're working on is selected in the drop down list, then select 'List Page' as the Viewer Type. Forget the rest for now and just click on the 'Show Code' button.

Copy all the code that's now showing into a page on your website called dogIndex.php.

If you browse this new page you should get a list of all the records that are in your database table that pertains to this section. You can edit the code that you pasted to remove things you probably don't need such as record number, content, etc., but for now just leave it alone.

Now you need to create the detail page that's going to display your articles.

In CMS Builder, go back into the 'Viewer Code Generator' area of the section in which you're working. This time, after making sure that the same section is showing up in the 'Select Section' drop down list, select 'Detail Page' as the 'Viewer Type'. Leave all the defaults, but notice that the Detail page is going to know what article to display because the record number of that article is going to be passed to it by the list page that you've created via the link url.

Click on the 'Show Code' button and copy all the generated code to a new page on your website called dogDetail.php. Save the file. It will be called from the dogIndex.php page when you click on a link.

That's it. Browse your dogIndex.php file, click a link, and you should see the full article load in dogDetail.php.

Hope this helps.

Jim
WebCamp One, LLC



Websites That Work

Re: [Mr Jim] List and Detail pages

Jim, thanks for the detailed explaination. I will give it a go.

Re: [thedmp] List and Detail pages

So now I have an index page that links to the details page, but those links are the url of that page and not the title of the page, so it makes a really long and ugly link. I don't suppose there is a way to have this link to the details page be the title of that page? Otherwise, I will need to go back in to the html and make a static link to the new page each time I create an article. Thanks again for the help.

Re: [thedmp] List and Detail pages

By MisterJim - September 27, 2008 - edited: September 27, 2008

On the dogIndex.php page, change:

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

to the following:

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

Jim
WebCamp One, LLC



Websites That Work