MosModule: Show MosCom latest 5?

Pick Language to Auto Translate:
AR | BG | CA | CS | DA | DE | EL | ES | FI | FR | HI | HR | ID | IT | IW | JA | KO | LT | LV | NL | NO | PL | PT | RO | RU | SK | SR | SL | SV | TL | UK | VI | ZH | ZH-TW

It is very easy with MosModule, you just create an article to contain the snippet then another article to execute it.

Here are the steps:

First you create an article that contain this snippet code:

# Code snippet listing for MosCom latest 5, let say this is article ID=232
global $database;
$qry="SELECT name, entry, `date` FROM `mos_content_comments`";
$qry.="WHERE published='1' ORDER BY `id` DESC LIMIT 5 ";
$rows = $database->loadObjectList();
foreach ($rows as $row) {
echo nl2br($row->entry);
echo '';
echo '';
echo 'Posted by: '.$row->name;
echo ' on '.$row->date.'';
echo '';

Then in another article just enter this: {mosmodule snippet=232}

The above line will execute the snippet and show MosCom latest 5 comments

You can apply the principle of this sample code but replace with your own logic to make it do anything you want in Mambo. The beauty of this way of doing thing is you have access to all Mambo API, variables, etc. You don't have to develop a module and worry about xml, etc.

With this method you can quickly hack up something that tailor or extend the function that you want without needing to spend the time to develop a plugin, addons, etc.

Enjoy with MosModule snippet!

Here is the running sample: