SimplePortal

Customization => Custom Coding => Topic started by: fotografo74 on March 23, 2009, 10:42:17 AM

Title: Latest articles from SMF Articles Mod
Post 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.

Code: [Select]
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
Title: Re: Latest articles from SMF Articles Mod
Post by: techprince on March 26, 2009, 01:54:54 PM
Fatal error: Function name must be a string in /Sources/SPortal1-1.php
Title: Re: Latest articles from SMF Articles Mod
Post by: fotografo74 on March 27, 2009, 04:13:21 AM
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
Title: Re: Latest articles from SMF Articles Mod
Post by: 130860 on March 27, 2009, 01:41:46 PM
thank you for sharing ;)
Title: Re: Latest articles from SMF Articles Mod
Post by: Speed1ng Turtle on March 28, 2009, 06:15:59 PM
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
Title: Re: Latest articles from SMF Articles Mod
Post by: Nathaniel on March 28, 2009, 09:19:39 PM
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.
Title: Re: Latest articles from SMF Articles Mod
Post by: techprince on April 02, 2009, 10:42:05 AM
Article block is for its own articles only? Because its not for SMF Articles.....
Title: Re: Latest articles from SMF Articles Mod
Post by: [SiNaN] on April 02, 2009, 11:24:26 AM
Yes, Articles block in 2.2 is only for SimplePortal articles.
Title: Re: Latest articles from SMF Articles Mod
Post by: techprince on April 05, 2009, 12:32:51 PM
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
Title: Re: Latest articles from SMF Articles Mod
Post by: willerby on April 05, 2009, 06:12:32 PM
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
Title: Re: Latest articles from SMF Articles Mod
Post by: willerby on April 08, 2009, 12:00:47 PM
With a little bit of trial error, this seems to work for random articles from SMF Articles

Code: [Select]
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);
Title: Re: Latest articles from SMF Articles Mod
Post by: techprince on April 12, 2009, 02:12:55 PM
Any progress of a code snippet for 1.1.8 & 2.0 from customizer?
Title: Re: Latest articles from SMF Articles Mod
Post by: Eliana Tamerin on April 12, 2009, 03:21:27 PM
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.
SimplePortal 2.3.8 © 2008-2024, SimplePortal