Blog style listing of pages

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
Jonny
Forum Members
Forum Members
Posts: 77
Joined: Sun Sep 24, 2006 10:49 am

Blog style listing of pages

Post by Jonny »

Is this easily achievable with CMSMS...

A page containing a list of a defined number of links to CMSMS pages which are under certain parents in the site heirarchy, sorted by most recent first, with a short extract and/or description from each page and the name of it's parent.

In other words, a blog-style article list.

Important: the linked pages must be basic CMSMS pages that can be presented with clean URLs rather than the long type generated by News or Blog Made Simple.
Jonny
Forum Members
Forum Members
Posts: 77
Joined: Sun Sep 24, 2006 10:49 am

Re: Blog style listing of pages

Post by Jonny »

Taking a different tack... though a blog type list with excerpts would be ideal I'm considering settling for a list of recently created pages. For this I've been modifying Elijah's "recently_updated" plugin.

This works OK but I'd also like to identify the parent of each page, which will act as a category heading, alongside.

Here's what I'm working with:

Code: Select all

function smarty_cms_function_recently_created($params, &$smarty)
{
  if(empty($params['number']))
    {
      $number = 10;
    }
  else
    {
      $number = $params['number'];
    }
    
  if(empty($params['leadin']))
    {
      $leadin = "Created: ";
    }
  else
    {
      $leadin = $params['leadin'];
    }
    
  if(empty($params['showtitle']))
    {
      $showtitle='true';
    }
  else
    {
      $showtitle = $params['showtitle'];
    }    
    
// added extra parameter for specifying start and end pages

	if(empty($params['start_page']))
	{
	  $start_page = 1;
	}
	else
	{
	  $start_page = $params['start_page'];
	}

	if(empty($params['end_page']))
	{
	  $end_page = 100;
	}
	else
	{
	  $end_page = $params['end_page'];
	}  

	$dateformat = isset($params['dateformat']) ? $params['dateformat'] : "d.m.y" ;    
	$css_class = isset($params['css_class']) ? $params['css_class'] : "" ;    
    
if (isset($params['css_class'])){
	$output = '<div class="'.$css_class.'"><ul>';
	}
else {
	$output = '<ul>';
}

global $gCms;
$hm =& $gCms->GetHierarchyManager();
$db = &$gCms->db;
// Get list of most recently created pages excluding the home page
$q = "SELECT * FROM ".cms_db_prefix()."content 
WHERE (type='content' OR type='link')
AND default_content != 1 
AND active = 1 
AND show_in_menu = 1 
AND hierarchy 
BETWEEN $start_page AND $end_page
ORDER BY create_date DESC LIMIT ".((int)$number);
$dbresult = $db->Execute( $q );
if( !$dbresult )
{
    echo 'DB error: '. $db->ErrorMsg()."<br/>";
}
while ($dbresult && $created_page = $dbresult->FetchRow())
{
    $curnode =& $hm->getNodeById($created_page['content_id']);
    $curcontent =& $curnode->GetContent();
    $output .= '<li>';
    $output .= '<a href="'.$curcontent->GetURL().'">'.$created_page['content_name'].'</a>';
    if ((FALSE == empty($created_page['titleattribute'])) && ($showtitle=='true'))
      {
	$output .= '<br />';
	$output .= $created_page['titleattribute'];
      }
    $output .= '<br />';
    
    $output .= $leadin;
    $output .= date($dateformat,strtotime($created_page['create_date']));

//  here's where I'd like the listed page's parent to be added 

    $output .= '</li>';
}

$output .= '</ul>';
if (isset($params['css_class'])){
		$output .= '</div>';
		}
		
return $output;
}
streever

Re: Blog style listing of pages

Post by streever »

jonny, here is what I imagine?

Let's say you have a normal site (about page, contact, etc) and the blog listings under categories.

I see you doing it like this:
1st level of pages: Home, Contact, Blog
2nd level: Categories
3rd level: Blog posts

in the BLOG section, the sub-pages are all the categories. So you simply have a call to menu that is for, "number_of_levels" 2 and the start_page is blog. So, it will auto show all the blog entries, under their parent, as you add them.

Does that make sense? You can also have "recently updated" in the side bar as a list of recently changed blog posts, I guess.  For the main category listing you'd just specify that they appear in "reverse" order, so the latest (which is automatically at the end of the pages in the page manager) will appear first.
Post Reply

Return to “CMSMS Core”