SimplePortal

Customization => Custom Coding => Topic started by: nabilinux on September 26, 2008, 05:29:00 AM

Title: Articles List - for both SPortal & SMF Articles
Post by: nabilinux on September 26, 2008, 05:29:00 AM
Hi,

First think, thank you guys for this great tool (SiNaN, ???1031...).

I just started to use SPortal and I like very much.

I would be nice if someone of the dev team created a custom block for showing a category list SPortal, and another one for showing a category list for the new mod SMF Article.

Why I said Sportal and SMF Article because someone may want to use SPortal as a homepage module only and SMF Article for and independant Article database (I'm thinking of a recipes website).

Thanks again for bringing SPortal to our world.
Title: Re: Articles List - for both SPortal & SMF Articles
Post by: nabilinux on September 26, 2008, 08:08:41 PM
Okey! here it is:

This code will show the list of categories that you have if you are using SMF Articles (http://custom.simplemachines.org/mods/index.php?mod=1354)

Add a PHP block with this code:
Code: [Select]
global $scripturl, $db_prefix;
$dbresult = db_query("
  SELECT a.ID_CAT, a.title
  FROM {$db_prefix}articles_cat as a
  WHERE ID_PARENT = 0
  ORDER BY roworder ASC", __FILE__, __LINE__);

$smf_articles_categories = array();

while($row = mysql_fetch_assoc($dbresult)){
  $smf_articles_categories[] = $row;
}

mysql_free_result($dbresult);

echo '<div>';
 
foreach($smf_articles_categories as $smf_articles_category){
  echo '<a href="' . $scripturl . '?action=articles;cat=' . $smf_articles_category['ID_CAT'] . '">' . $smf_articles_category['title'] . '</a><br />';
}
 
echo '</div>';

Note: This shows only top categories.

I hope this small work it helps someone!

Thanks SP team!
SimplePortal 2.3.8 © 2008-2024, SimplePortal