Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display a list of sub-pages (listing of articles in a category)
#6
tazmandev Wrote:I need to create a simple website with a few main pages (top level pages) and subpages for them.

Something like Category (top level page) -> Products or Services (sub pages)

In the top level page I need to display a list of the subpages in a fashionable way, each list item having:

1. Thumbnail for the subpage (product or service)
2. Title of subpage
2. Excerpt of the subpage
3. Read more link

The subpage will be a regular second level page.

I think that is almost what I am doing on my site at this page:
http://www.cartocopia.com/portfolio/

I'm using Mike's Page Caching plugin: http://get-simple.info/extend/plugin/page-caching/65/

Then in that portfollio page I have the following (simplified for you) code in my template (for that page):
Code:
/* Uses Mike's page caching plugin http://get-simple.info/extend/plugin/page-caching/65/ */
  $childlist = getChildren(return_page_slug());

  $subpagelist = array();
  foreach($childlist as $child) {
    if (returnPageField($child, 'private') != 'Y')
      $subpagelist[] = array($child, returnPageField($child,'title'), returnPageField($child,'menuOrder'));
  }

   /* sort children my menuorder subval_sort is built in to GS2.1+ */
  $subpagelist = subval_sort($subpagelist ,2);

  foreach($subpagelist as $subpage) {
    $thumb = '/data/uploads/' . $subpage[0] . '_thumb.jpg';
    $link = $subpage[0] . '/';
    $title = $subpage[1];

    echo .....................;
  }

So by making the thumbnails <slug>_thumb.jpg you can grab their reference, then on the echo line just build your image, title and link.

Add on the page excerpt plugin (as suggested by Oleg) http://get-simple.info/extend/plugin/pages-excerpts/62/ and you can also grab an excerpt (200 chars, text format by default) in the loop with something like:
Code:
$snippet = page_excerpt($subpage[0]);

then also echo it out.

Good luck-

-Rob A>
Reply


Messages In This Thread
Display a list of sub-pages (listing of articles in a category) - by RobA - 2011-06-08, 11:54:39



Users browsing this thread: 1 Guest(s)