Customization > Custom Coding

Articles List - for both SPortal & SMF Articles

(1/1)

nabilinux:
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.

nabilinux:
Okey! here it is:

This code will show the list of categories that you have if you are using SMF Articles

Add a PHP block with this code:

--- Code: ---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>';
--- End code ---

Note: This shows only top categories.

I hope this small work it helps someone!

Thanks SP team!

Navigation

[0] Message Index

Go to full version