latest articles plugin

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
gravityman

latest articles plugin

Post by gravityman »

I've been lurking and gaining knowledge for awhile, so I thought I'd contribute this bit of code that I use as a plugin to display the 5 newest pages on my site...perhaps it will be of use to someone.  Note that this uses ".shtml" extensions.  Copy this code into a user plugin and put the plugin reference in your template.
global $gCms;
$db = $gCms->db;

$result = array();

$query = "SELECT * FROM ".cms_db_prefix()."content
where type = 'content' ORDER BY create_date DESC limit 5";
$dbresult = $db->Execute($query);

if ($dbresult && $dbresult->RowCount() > 0)
{
while ($row = $dbresult->FetchRow())
{
#Make sure the type exists.  If so, instantiate and load
if (in_array($row['type'], array_keys(@ContentManager::ListContentTypes())))
{

                                  echo '• '.$row[menu_text].'';
                                     
}
}
}
Last edited by gravityman on Thu Apr 21, 2005 7:53 am, edited 1 time in total.
100rk

Re: latest articles plugin

Post by 100rk »

gravityman wrote: $db = $gCms->db;
I recommend to You use passing adodb connection by reference:

Code: Select all

$db = & $gCms->db;
Locked

Return to “Modules/Add-Ons”