collapse collapse

* User Info

 
 
Welcome, Guest. Please login or register.
Did you miss your activation email?

* Who's Online

  • Dot Guests: 111
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Re: How to Add signature in Simple Portal? by tocnaza
[July 06, 2019, 12:04:00 PM]


Re: Yeni Sürüm Çıkacak mı? by mkuru
[July 01, 2019, 03:05:44 AM]


Re: Yeni Sürüm Çıkacak mı? by akorkut
[June 28, 2019, 05:38:26 AM]


Re: Yeni Sürüm Çıkacak mı? by mkuru
[June 26, 2019, 12:09:02 PM]


Yeni Sürüm Çıkacak mı? by akorkut
[June 25, 2019, 04:53:54 AM]

Blocks speak! Do you have an interest in getting more blocks - or even making your own? The Blocks Board is for you!

Author Topic: A Better "SMF ARTICLES" Block  (Read 28450 times)

0 Members and 1 Guest are viewing this topic.

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
A Better "SMF ARTICLES" Block
« on: May 04, 2009, 09:02:08 AM »
There is a simple block somewhere in the "custom coding" forum related to SMF Articles. It's great but It's very simple.

To that code, I added some customization. Hope you like it :)

Code: (SMF 2.0) [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 RAND()
LIMIT 5
");

echo'
<div class="smalltext" style="text-align: center; color: #216095;">
   <strong>5 Random Articles</strong>
</div>
   <hr />';

echo'
<table>';
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
echo '
<tr>
<td align="center">', sp_embed_image('topic'), ' </td>
<td><span class="smalltext"><a href="' . $scripturl . '?action=articles;sa=view;article=' . $row['ID_ARTICLE'] . '">' . $row['title'] . '</a></span> </td>
</tr>';
}
$smcFunc['db_free_result']($dbresult);

echo'
</table><hr />
', sp_embed_image('dot'), ' <span class="smalltext"><b><a href="' . $scripturl . '?action=articles">Read ALL Articles</a></b></span>';

Code: (SMF 1.1.X) [Select]
global $scripturl, $db_prefix;
isAllowedTo('view_articles');
$dbresult = db_query("
SELECT a.ID_ARTICLE, a.title
FROM {$db_prefix}articles AS a
WHERE a.approved = 1
ORDER BY RAND()
LIMIT 5", __FILE__, __LINE__);

echo'
<div class="smalltext" style="text-align: center; color: #216095;">
   <strong>5 Random Articles</strong>
</div>
   <hr />';

echo'
<table>';
while ($row = mysql_fetch_assoc($dbresult))
{
echo '
<tr>
<td align="center">', sp_embed_image('topic'), ' </td>
<td><span class="smalltext"><a href="' . $scripturl . '?action=articles;sa=view;article=' . $row['ID_ARTICLE'] . '">' . $row['title'] . '</a></span></td>
</tr>';
}
mysql_free_result($dbresult);

echo'
</table><hr />
', sp_embed_image('dot'), ' <span class="smalltext"><b><a href="' . $scripturl . '?action=articles">Read ALL Articles</a></b></span>';

Edited: This document was successfully checked as XHTML 1.0 Transitional!
« Last Edit: July 05, 2011, 03:28:22 PM by Blue »
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: A Better "SMF ARTICLES" Block
« Reply #1 on: May 04, 2009, 11:52:56 AM »
Looks cool, good job!
And slowly, you come to realize... It's all as it should be...

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: A Better "SMF ARTICLES" Block
« Reply #2 on: May 04, 2009, 12:08:55 PM »
Thanks ;) Next block is going to be an Admin Block eheh ;D
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: A Better "SMF ARTICLES" Block
« Reply #3 on: May 04, 2009, 12:37:54 PM »
That sounds great. Looking forward to seeing that.
And slowly, you come to realize... It's all as it should be...

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: [BLOCK] A Better "SMF ARTICLES" Block
« Reply #4 on: May 04, 2009, 05:32:52 PM »
It's done eheh :P

See for yourself:
http://simpleportal.net/index.php?topic=2206.0
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: A Better "SMF ARTICLES" Block
« Reply #5 on: May 04, 2009, 05:49:25 PM »
Moved to the "Blocks and Modifications" board.

One thing that you could do, is use the 'sp_embed_image' function to put in the topic images. Like the code below:

Code: [Select]
', sp_embed_image('topic'), '
That function will load any images in the 'sp' image folder. :)
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: A Better "SMF ARTICLES" Block
« Reply #6 on: May 04, 2009, 06:05:42 PM »
That's a good suggestion but if I put:

Code: [Select]
', sp_embed_image('dot'), ' 

The "dot" will be a random dot right? I'm asking because I saw that code in your "Who's online block"

And I can't try by myself since I'm using SP 2.1.1 (I just need the php block :P)

Even though, I'll update the block and replace for that code ;) Thanks LHVWB
« Last Edit: May 04, 2009, 06:08:49 PM by Blue »
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline fotografo74

  • Jr. Member
  • **
  • Posts: 51
  • SMF Version: 2 RC1-1
  • SP Version: 2.3
Re: A Better "SMF ARTICLES" Block
« Reply #7 on: May 07, 2009, 07:04:51 AM »
Thanks for sharing this :-)
I have problem , i have this error:
Code: [Select]
Parse error: syntax error, unexpected '<' in /home/macrofor/public_html/Sources/SPortal2.php(3174) : eval()'d code on line 17

I have SMF2 RC1 and SP 2.2

My forum: www..macroforum.org

Thanks for help!
Antonio

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: A Better "SMF ARTICLES" Block
« Reply #8 on: May 07, 2009, 07:21:51 AM »
I forgot an "echo'", sorry about that :-[

I've updated the code in the first post. Try it now and tell me if it works :nervous-happy:
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline fotografo74

  • Jr. Member
  • **
  • Posts: 51
  • SMF Version: 2 RC1-1
  • SP Version: 2.3
Re: A Better "SMF ARTICLES" Block
« Reply #9 on: May 07, 2009, 10:02:54 AM »
I forgot an "echo'", sorry about that :-[

I've updated the code in the first post. Try it now and tell me if it works :nervous-happy:
Thanks, it works now!
Thanks!
Antonio

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: A Better "SMF ARTICLES" Block
« Reply #10 on: May 07, 2009, 10:59:52 PM »
I'm glad I helped you ;)
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline Hellan

  • Semi Newbie
  • *
  • Posts: 12
  • SMF Version: 1.1.10
  • SP Version: 2.2.2
Re: A Better "SMF ARTICLES" Block
« Reply #11 on: May 08, 2009, 03:04:28 PM »
Hi Blue,
Any chance of making this available for smf 1.1.8?
I would LOVE this mod on my portal
Thanks
Hellan

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: A Better "SMF ARTICLES" Block
« Reply #12 on: May 08, 2009, 08:01:45 PM »
Maybe :P I just need to see the things I need to change. 

hum... I'll try
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: A Better "SMF ARTICLES" Block
« Reply #13 on: May 08, 2009, 10:06:34 PM »
Try this:
Code: [Select]
global $scripturl, $db_prefix;
isAllowedTo('view_articles');
$dbresult = db_query("
SELECT a.ID_ARTICLE, a.title
FROM {$db_prefix}articles AS a
WHERE a.approved = 1
ORDER BY RAND()
LIMIT 5
");

echo'
<div class="smalltext" style="text-align: center; color: #216095;">
   <strong>5 Random Articles</strong>
</div>
   <hr />';

echo'
<table>';
while ($row = mysql_fetch_assoc($dbresult))
{
echo '
<tr>
<td align="center">', sp_embed_image('topic'), ' </td>
<td><span class="smalltext"><a href="' . $scripturl . '?action=articles;sa=view;article=' . $row['ID_ARTICLE'] . '">' . $row['title'] . '</a></span></td>
</tr>';
}
mysql_free_result($dbresult);

echo'
</table>
<hr>
', sp_embed_image('dot'), ' <span class="smalltext"><font color="#000000"><b><a href="' . $scripturl . '?action=articles">Read ALL Articles</a></b></span>';
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline Hellan

  • Semi Newbie
  • *
  • Posts: 12
  • SMF Version: 1.1.10
  • SP Version: 2.2.2
Re: A Better "SMF ARTICLES" Block
« Reply #14 on: May 09, 2009, 07:19:16 AM »
Thank you works great

techprince

  • Guest
Re: A Better "SMF ARTICLES" Block
« Reply #15 on: May 10, 2009, 05:29:28 PM »
i modified the code a little, but getting missing arguments 2 and 3 for db_query()

Code: [Select]
global $scripturl, $db_prefix;
isAllowedTo('view_articles');
$dbresult = db_query("
SELECT a.ID_ARTICLE, a.title, a.commenttotal
FROM {$db_prefix}articles AS a
WHERE a.approved = 1
ORDER BY a.date DESC
LIMIT 8
");

echo'
<table>';
while ($row = mysql_fetch_assoc($dbresult))
{
echo '
<tr>
<td align="center" style="padding:6px;">', sp_embed_image('topic'), ' </td>
<td><span class="smalltext"><a href="' . $scripturl . '?action=articles;sa=view;article=' . $row['ID_ARTICLE'] . '">' . $row['title'] . '  (' . $row['commenttotal'] . ')</a></span></td>
</tr>';
}
mysql_free_result($dbresult);

echo'
</table>
<hr>
', sp_embed_image('dot'), ' <span class="smalltext"><font color="#000000"><b><a href="' . $scripturl . '?action=articles">Read ALL Reviews</a></b></span>';
« Last Edit: May 10, 2009, 05:44:50 PM by techprince »

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: A Better "SMF ARTICLES" Block
« Reply #16 on: May 10, 2009, 05:50:46 PM »
Hum... The code seams correct.

What do you mean by: "getting missing arguments 2 and 3 for db_query()"? :0
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

techprince

  • Guest
Re: A Better "SMF ARTICLES" Block
« Reply #17 on: May 10, 2009, 06:02:14 PM »
I am getting these errors in Forum Log, though the output is clean.

2: Missing argument 2 for db_query(), called in /Sources/SPortal1-1.php(3244) : eval()'d code on line 9 and defined
File: /Sources/Subs.php
Line: 238

2: Missing argument 3 for db_query(), called in /Sources/SPortal1-1.php(3244) : eval()'d code on line 9 and defined
File: /Sources/Subs.php
Line: 238


These errors are from this block only. :(
« Last Edit: May 10, 2009, 06:05:22 PM by techprince »

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: A Better "SMF ARTICLES" Block
« Reply #18 on: May 10, 2009, 06:09:40 PM »
Hum.. This is very odd :'( I don't know what's wrong with the block. In smf 2.0 block i'm not getting any error.

Can you attach your Subs.php? Maybe the problem is from it
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

techprince

  • Guest
Re: A Better "SMF ARTICLES" Block
« Reply #19 on: May 10, 2009, 06:28:47 PM »
Sorry for the delay, and this is for 1.1.8 :)