SimplePortal
Customization => Custom Coding => Topic started by: fotografo74 on March 23, 2009, 10:42:17 AM
-
Hi:-)
I use in my forum www.macroforum.org, SP 2.1.1 this simple code in PHP block for retrieve latest 5 articles submitted by users.
The Php block is called "Ultimi articoli" ( latest articles) , below Paypal donation block. I have at this moment only 1 article submitted by user.
global $smcFunc, $scripturl;
isAllowedTo('view_articles');
$dbresult = $smcFunc['db_query']('', "
SELECT a.ID_ARTICLE, a.title
FROM {db_prefix}articles AS a
WHERE a.approved = 1
ORDER BY a.date DESC
LIMIT 5
");
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
echo '<a href="' . $scripturl . '?action=articles;sa=view;article=' . $row['ID_ARTICLE'] . '">' . $row['title'] . '</a><br />';
}
$smcFunc['db_free_result']($dbresult);
Antonio
-
Fatal error: Function name must be a string in /Sources/SPortal1-1.php
-
Fatal error: Function name must be a string in /Sources/SPortal1-1.php
I use SMF2 RC1 and SP 2.1.1
I'm not programmer...sorry...
Your forum is SMF 1.1.X ?
If yes, you must change the query :-)
Antonio
-
thank you for sharing ;)
-
is there any way to show the smf article summary or better yet the text by modding this code as I can only get a link at the moment and I would like to just show the whole article. Thanks
-
This topic has been noted, a customizer will create a mod that adds a SimplePortal block to display articles from the SMF articles mod. It should have options to display like normal SP articles as well as just with links.
It will have to wait until after SP 2.2 is released though.
-
Article block is for its own articles only? Because its not for SMF Articles.....
-
Yes, Articles block in 2.2 is only for SimplePortal articles.
-
This topic has been noted, a customizer will create a mod that adds a SimplePortal block to display articles from the SMF articles mod. It should have options to display like normal SP articles as well as just with links.
It will have to wait until after SP 2.2 is released though.
Hmm, SP 2.2 is released, no mod yet ? :P
-
This topic has been noted, a customizer will create a mod that adds a SimplePortal block to display articles from the SMF articles mod. It should have options to display like normal SP articles as well as just with links.
It will have to wait until after SP 2.2 is released though.
LHVWB, I've used fotografo74's code in my forum to pull the latest 5 articles from SMF Articles. If a coder is working on a block can I suggest a facility to pull x latest OR x random articles from same similar to options in SMF Gallery block?
Also worth noting that SMF Articles is permissions based unlike SMF Gallery-Lite which may make coding more complex if you only want to show articles available to certain membergroups within the block...
W
-
With a little bit of trial error, this seems to work for random articles from SMF Articles
global $smcFunc, $scripturl;
isAllowedTo('view_articles');
$dbresult = $smcFunc['db_query']('', "
SELECT a.ID_ARTICLE, a.title, a.views
FROM {db_prefix}articles AS a
ORDER BY RAND()
LIMIT 3
");
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
echo ' ', sp_embed_image('dot'), ' <a href="' . $scripturl . '?action=articles;sa=view;article=' . $row['ID_ARTICLE'] . '">' . $row['title'] . '</a> (' . $row['views'] . ' views)<br />';
}
$smcFunc['db_free_result']($dbresult);
-
Any progress of a code snippet for 1.1.8 & 2.0 from customizer?
-
L and Robbo are pretty busy at the moment, but I'm sure they'll get to it. It may just take a little while.