collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 1070
  • 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

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

If you're interested in helping other members with support requests, consider joining the Community Support Helpers group.

Author Topic: Listing Articles by category  (Read 4413 times)

0 Members and 1 Guest are viewing this topic.

Offline mack

  • Jr. Member
  • **
  • Posts: 57
    • Game-Bank
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Listing Articles by category
« on: October 13, 2009, 08:23:24 AM »
hey guys,

i'm fairly new to simpleportal and have a question about article categories .. i've been looking through simpleportal and can find an answer

what i want on my homepage is a block that allows you to click to view a list of articles under a category name. so for example when i click on a link to see game news the link takes me to the 'games news' category, listing all articles in that category.

my issue isn't about settings this block up .. it's about how i link to the category id, and how to display the articles for that category id on a separate page.

thanks in advance for any help
Jango

---------------------------

Game-Bank

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Listing Articles by category
« Reply #1 on: October 13, 2009, 04:48:10 PM »
My suggestion, would be that you make a Custom PHP Page, which you can add code to show the articles for a particular category

Ie. index.php?pageid=showarticles;cat=x

Then use $_REQUEST['cat'] to get the id, and show the articles. Refer to the 'sportal_articles' and 'sportal_articles_callback' functions from the Sources/PortalArticles.php file, for help on accessing and displaying articles. The Themes/default/PortalArticles.template.php file may also be useful.
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy 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 mack

  • Jr. Member
  • **
  • Posts: 57
    • Game-Bank
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Listing Articles by category
« Reply #2 on: October 13, 2009, 11:10:55 PM »
cheers nathaniel .. i'll look into it  ;D
Jango

---------------------------

Game-Bank

Offline mack

  • Jr. Member
  • **
  • Posts: 57
    • Game-Bank
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Listing Articles by category
« Reply #3 on: October 15, 2009, 12:03:44 PM »
wow ..

well since i wrote i've been trying a few different things to get it working, and failing .. hard (hehe)

i took your advice and tried to work with the sportal_articles and sportal_articles_callback functions in the file you mentioned, but it's led to all sorts of problems (which i've only just reset)

my php is very rusty .. can anyone be more definitive about the code i need in my custom php block?

thanks again for any help
Jango

---------------------------

Game-Bank

Offline mack

  • Jr. Member
  • **
  • Posts: 57
    • Game-Bank
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Listing Articles by category
« Reply #4 on: October 18, 2009, 05:26:44 PM »
 /polite bump
Jango

---------------------------

Game-Bank

Offline mack

  • Jr. Member
  • **
  • Posts: 57
    • Game-Bank
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Listing Articles by category
« Reply #5 on: October 19, 2009, 11:10:44 PM »
114 views and no replies? does no-one know? this must've come up before for someone?

help meh .. i'm staring at code and peeing myself a little bit  :'(
Jango

---------------------------

Game-Bank

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Listing Articles by category
« Reply #6 on: October 20, 2009, 06:55:19 AM »
As this is really a Customization request and we have just had a release, its a bit unreasonable to expect someone to code it for you within a day or two. ;)

Anyway try this code in a custom page.
Code: [Select]
    global $db_prefix, $context, $modSettings, $user_info, $article_request, $sourcedir, $scripturl, $txt;

    require_once($sourcedir . '/PortalArticles.php');
    require_once($sourcedir . '/Subs-Portal.php');

    $category = !empty($_REQUEST['cat']) ? $_REQUEST['cat'] : 1;
    $articleperpage = 5;

    loadLanguage('Stats');
    loadTemplate('PortalArticles');

    $request = db_query("
        SELECT COUNT(*)
        FROM {$db_prefix}sp_articles as a
            INNER JOIN {$db_prefix}sp_categories AS c ON (c.ID_CATEGORY = a.ID_CATEGORY)
            INNER JOIN {$db_prefix}messages AS m ON (m.ID_MSG = a.ID_MESSAGE)
            INNER JOIN {$db_prefix}boards AS b ON (b.ID_BOARD = m.ID_BOARD)
        WHERE $user_info[query_see_board]
            AND approved = 1
            AND publish = 1
            AND c.ID_CATEGORY = $category", __FILE__, __LINE__);
    list ($totalArticles) = mysql_fetch_row($request);
    mysql_free_result($request);

    $context['start'] = !empty($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0;
    $context['page_index'] = constructPageIndex($scripturl . '?page=' . $context['SPortal']['page']['page_id'] . ';cat=' . $category, $context['start'], $totalArticles, $articleperpage);

    if (empty($modSettings['sp_disableColor']))
    {
        $members_request = db_query("
            SELECT m.ID_MEMBER
            FROM {$db_prefix}sp_articles AS a
                INNER JOIN {$db_prefix}messages AS m ON (m.ID_MSG = a.ID_MESSAGE)
                INNER JOIN {$db_prefix}boards AS b ON (b.ID_BOARD = m.ID_BOARD)
                INNER JOIN {$db_prefix}sp_categories AS c ON (c.ID_CATEGORY = a.ID_CATEGORY)
            WHERE $user_info[query_see_board]
                AND approved = 1
                AND publish = 1
                AND m.ID_MEMBER != 0
            ORDER BY a.ID_MESSAGE DESC" . (empty($articleperpage) ? "" : "
            LIMIT $context[start], $articleperpage"), __FILE__, __LINE__);
        $colorids = array();
        while($row = mysql_fetch_assoc($members_request))
            $colorids[] = $row['ID_MEMBER'];
        mysql_free_result($members_request);

        if (!empty($colorids))
            sp_loadColors($colorids);
    }

    $article_request = db_query("
        SELECT
            a.ID_ARTICLE, a.ID_CATEGORY, a.ID_MESSAGE, a.approved, c.name as cname, c.picture, m.ID_MEMBER,
            IFNULL(mem.realName, m.posterName) AS posterName, m.icon, m.subject, m.body, m.posterTime,
            m.smileysEnabled, t.ID_TOPIC, t.numReplies, t.numViews, t.locked, b.ID_BOARD, b.name as bname,
            mem.avatar, at.ID_ATTACH, at.attachmentType, at.filename
        FROM {$db_prefix}sp_articles AS a
            INNER JOIN {$db_prefix}sp_categories AS c ON (c.ID_CATEGORY = a.ID_CATEGORY)
            INNER JOIN {$db_prefix}messages AS m ON (m.ID_MSG = a.ID_MESSAGE)
            INNER JOIN {$db_prefix}topics AS t ON (t.ID_FIRST_MSG = a.ID_MESSAGE)
            INNER JOIN {$db_prefix}boards AS b ON (b.ID_BOARD = m.ID_BOARD)
            LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
            LEFT JOIN {$db_prefix}attachments AS at ON (at.ID_MEMBER = mem.ID_MEMBER)
        WHERE $user_info[query_see_board]
            AND approved = 1
            AND publish = 1
            AND c.ID_CATEGORY = $category
        ORDER BY a.ID_MESSAGE DESC" . (empty($articleperpage) ? "" : "
        LIMIT $context[start], $articleperpage"), __FILE__, __LINE__);

    $cat_request = db_query("
        SELECT name, ID_CATEGORY
        FROM {$db_prefix}sp_categories", __FILE__, __LINE__);

    $cats = array();
    while ($row = mysql_fetch_assoc($cat_request))
        $cats[] = ($category == $row['ID_CATEGORY'] ? '<strong>[' : '') . '<a href="' . $scripturl . '?page=' . $context['SPortal']['page']['page_id'] . ';cat=' . $row['ID_CATEGORY'] . '">' . $row['name'] . '</a>' . ($category == $row['ID_CATEGORY'] ? ']</strong> ' : '');
    mysql_free_result($cat_request);

    echo '
                <div class="sp_regular_padding;">', implode($cats, ' | '), '</div><br />
                <div class="sp_regular_padding;">';

    while ($article = sportal_articles_callback())
    {
        echo '
                    <div class="tborder">
                        <table class="sp_block">
                            <tr class="catbg">
                                <td class="sp_middle">', $article['message']['icon'], '</td>
                                <td class="sp_middle sp_regular_padding sp_fullwidth">', $article['topic']['link'], ' | ', $article['message']['timeyear'], '</td>
                            </tr>
                            <tr class="windowbg">
                                <td class="sp_regular_padding" colspan="2">';

        if (!empty($modSettings['articleavatar']) && $article['poster']['avatar']['name'] !== null && !empty($article['poster']['avatar']['href']))
            echo '
                                    <img src="', $article['poster']['avatar']['href'], '" alt="', $article['poster']['name'], '" width="30" style="float: right;" />
                                    <div class="middletext">', $article['message']['timeday'], ' ', $txt[525], ' ', $article['poster']['link'], '<br />', $txt['sp-articlesViews'], ': ', $article['topic']['views'], ' | ', $txt['sp-articlesComments'], ': ', $article['topic']['replies'], '</div>';
        else
            echo '
                                    <div class="middletext">', $article['message']['timeday'], ' ', $txt[525], ' ', $article['poster']['link'], ' | ', $txt['sp-articlesViews'], ': ', $article['topic']['views'], ' | ', $txt['sp-articlesComments'], ': ', $article['topic']['replies'], '</div>';

        echo '
                                    <div class="post"><hr />', !empty($article['category']['picture']['href']) ? '<div><img src="' . $article['category']['picture']['href'] . '" alt="' . $article['category']['name'] . '" class="sp_article_image" align="right" /></div>' : '', $article['message']['body'], '<br/><br/>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td class="windowbg2" colspan="2">
                                    <div class="sp_right sp_regular_padding">', $article['article']['link'], ' ',  $article['article']['new_comment'], '</div>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <br />';
    }

    if (!empty($articleperpage))
        echo '
                    <div class="sp_page_index">', $txt['sp-articlesPages'], ': ', $context['page_index'], '</div>';

    echo '
                </div>';
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy 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 mack

  • Jr. Member
  • **
  • Posts: 57
    • Game-Bank
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Listing Articles by category
« Reply #7 on: October 20, 2009, 12:37:28 PM »
thanks for the reply .. sry if i came across as being unreasonable .. i just thought this would've come up before somewhere which is why i was a little surprised at the lack of response .. but np :)

thanks for the code tho, i'll give it a whirl
Jango

---------------------------

Game-Bank

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Listing Articles by category
« Reply #8 on: October 23, 2009, 01:40:33 AM »
Any luck with that code mack?
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy 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 mack

  • Jr. Member
  • **
  • Posts: 57
    • Game-Bank
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Listing Articles by category
« Reply #9 on: October 28, 2009, 05:22:09 AM »
Any luck with that code mack?

sorry for the delayed response

in short .. no. basically it showed all of the articles, from all categories. i might've misunderstood something in your post ofc.
Jango

---------------------------

Game-Bank

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Listing Articles by category
« Reply #10 on: October 29, 2009, 05:19:02 AM »
Doesn't it display a list of categories at the top of the page? If you select a specific category, then it will only show articles from that category.
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy 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 mack

  • Jr. Member
  • **
  • Posts: 57
    • Game-Bank
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Listing Articles by category
« Reply #11 on: October 29, 2009, 10:17:34 AM »
i'll set it up again later on and see .. can't say i noticed that the first time i tested it
Jango

---------------------------

Game-Bank

Offline mack

  • Jr. Member
  • **
  • Posts: 57
    • Game-Bank
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Listing Articles by category
« Reply #12 on: October 29, 2009, 06:38:45 PM »
i think i hadn't noticed it first time around because of the way my design restricts a certain amount of simpleportal's previews

but yes .. it works really well ..

for anyone interested in how i incoporated it:

all i needed to do was create a page in simpleportal with the php in it (making sure the page type was selected as 'php'). then i added some buttons from my home page to point to each category that the new page switches between ('cat=1', 'cat=2' etc) and that was that.

@nathaniel - hopefully by the time you read this i'll have added in the extra buttons so you can see it at work (clan4 web site .. links on the right to games news, hardware news, and odds 'n' ends). oh and nathaniel .. awesome mate .. thank you very much :)

« Last Edit: October 29, 2009, 07:01:18 PM by mack »
Jango

---------------------------

Game-Bank

Offline peteewheat

  • Newbie
  • Posts: 4
  • SMF Version: 2 RC1.2
  • SP Version: 2.3.1
Re: Listing Articles by category
« Reply #13 on: October 31, 2009, 03:43:23 PM »
I keep getting this error when I try to implement this:

Code: [Select]
Fatal error: Call to undefined function: db_query() in /home/xxxx/public_html/mysite/Sources/Subs-Portal.php(1333) : eval()'d code on line 12
Argh!

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Listing Articles by category
« Reply #14 on: October 31, 2009, 06:14:11 PM »
@peteewheat,
That code is for SMF 1.1.x, you are running SMF 2, so the code won't work properly.

I can convert the code for SMF 2 (when I find the time) if you want?
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy 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 peteewheat

  • Newbie
  • Posts: 4
  • SMF Version: 2 RC1.2
  • SP Version: 2.3.1
Re: Listing Articles by category
« Reply #15 on: October 31, 2009, 07:06:47 PM »
Yes! That would be awesome. I have a football league with news articles broken out by team (30'ish teams). Each team has their own page and I would love to break out the articles for each team.

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Listing Articles by category
« Reply #16 on: October 31, 2009, 09:23:00 PM »
The code below is the same as the code above, but adapted for SMF 2.

Code: [Select]
    global $db_prefix, $context, $modSettings, $user_info, $article_request, $sourcedir, $scripturl, $txt, $smcFunc;

    require_once($sourcedir . '/PortalArticles.php');
    require_once($sourcedir . '/Subs-Portal.php');

    $category = !empty($_REQUEST['cat']) ? $_REQUEST['cat'] : 1;
    $articleperpage = 5;

    loadLanguage('Stats');
    loadTemplate('PortalArticles');

$request = $smcFunc['db_query']('','
SELECT COUNT(*)
FROM {db_prefix}sp_articles as a
INNER JOIN {db_prefix}sp_categories AS c ON (c.id_category = a.id_category)
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_message)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
WHERE {query_see_board}
AND a.approved = {int:approved}
AND publish = {int:publish}
AND a.id_category = {int:id_category}',
array(
'approved' => 1,
'publish' => 1,
'id_category' => $category,
)
);
list ($totalArticles) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);

    $context['start'] = !empty($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0;
    $context['page_index'] = constructPageIndex($scripturl . '?page=' . $context['SPortal']['page']['page_id'] . ';cat=' . $category, $context['start'], $totalArticles, $articleperpage);

if (empty($modSettings['sp_disableColor']))
{
$members_request = $smcFunc['db_query']('','
SELECT m.id_member
FROM {db_prefix}sp_articles AS a
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_message)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
INNER JOIN {db_prefix}sp_categories AS c ON (c.id_category = a.id_category)
WHERE {query_see_board}
AND a.approved = {int:approved}
AND publish = {int:publish}
AND m.id_member != {int:guest}
ORDER BY a.id_message DESC' . (empty($modSettings['articleperpage']) ? '' : '
LIMIT {int:start}, {int:end}'),
array(
'approved' => 1,
'publish' => 1,
'start' => $context['start'],
'end' =>  $modSettings['articleperpage'],
'guest' => 0,
)
);
$colorids = array();
while($row = $smcFunc['db_fetch_assoc']($members_request))
$colorids[] = $row['id_member'];
$smcFunc['db_free_result']($members_request);

if (!empty($colorids))
sp_loadColors($colorids);
}

$article_request = $smcFunc['db_query']('','
SELECT
a.id_article, a.id_category, a.id_message, a.approved, c.name as cname, c.picture, m.id_member,
IFNULL(mem.real_name, m.poster_name) AS poster_name, m.icon, m.subject, m.body, m.poster_time,
m.smileys_enabled, t.id_topic, t.num_replies, t.num_views, t.locked, b.id_board, b.name as bname,
mem.avatar, at.id_attach, at.attachment_type, at.filename
FROM {db_prefix}sp_articles AS a
INNER JOIN {db_prefix}sp_categories AS c ON (c.id_category = a.id_category)
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_message)
INNER JOIN {db_prefix}topics AS t ON (t.id_first_msg = a.id_message)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
LEFT JOIN {db_prefix}attachments AS at ON (at.id_member = mem.id_member)
WHERE {query_see_board}
AND a.approved = {int:approved}
AND publish = {int:publish}
AND c.id_category = {int:id_category}
ORDER BY a.id_message DESC' . (empty($articleperpage) ? '' : '
LIMIT {int:start}, {int:end}'),
array(
'approved' => 1,
'publish' => 1,
'start' => $context['start'],
'end' => $articleperpage,
'id_category' => $category,
)
);

    $cat_request = $smcFunc['db_query']('','
        SELECT name, ID_CATEGORY
        FROM {db_prefix}sp_categories',
array()
);

    $cats = array();
    while ($row = $smcFunc['db_fetch_assoc']($cat_request))
        $cats[] = ($category == $row['ID_CATEGORY'] ? '<strong>[' : '') . '<a href="' . $scripturl . '?page=' . $context['SPortal']['page']['page_id'] . ';cat=' . $row['ID_CATEGORY'] . '">' . $row['name'] . '</a>' . ($category == $row['ID_CATEGORY'] ? ']</strong> ' : '');
    $smcFunc['db_free_result']($cat_request);

    echo '
                <div class="sp_regular_padding;">', implode($cats, ' | '), '</div><br />
                <div class="sp_regular_padding;">';

    while ($article = sportal_articles_callback())
    {
        echo '
                    <div class="tborder">
                        <table class="sp_block">
                            <tr class="catbg">
                                <td class="sp_middle">', $article['message']['icon'], '</td>
                                <td class="sp_middle sp_regular_padding sp_fullwidth">', $article['topic']['link'], ' | ', $article['message']['timeyear'], '</td>
                            </tr>
                            <tr class="windowbg">
                                <td class="sp_regular_padding" colspan="2">';

        if (!empty($modSettings['articleavatar']) && $article['poster']['avatar']['name'] !== null && !empty($article['poster']['avatar']['href']))
            echo '
                                    <img src="', $article['poster']['avatar']['href'], '" alt="', $article['poster']['name'], '" width="30" style="float: right;" />
                                    <div class="middletext">', $article['message']['timeday'], ' ', $txt[525], ' ', $article['poster']['link'], '<br />', $txt['sp-articlesViews'], ': ', $article['topic']['views'], ' | ', $txt['sp-articlesComments'], ': ', $article['topic']['replies'], '</div>';
        else
            echo '
                                    <div class="middletext">', $article['message']['timeday'], ' ', $txt[525], ' ', $article['poster']['link'], ' | ', $txt['sp-articlesViews'], ': ', $article['topic']['views'], ' | ', $txt['sp-articlesComments'], ': ', $article['topic']['replies'], '</div>';

        echo '
                                    <div class="post"><hr />', !empty($article['category']['picture']['href']) ? '<div><img src="' . $article['category']['picture']['href'] . '" alt="' . $article['category']['name'] . '" class="sp_article_image" align="right" /></div>' : '', $article['message']['body'], '<br/><br/>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td class="windowbg2" colspan="2">
                                    <div class="sp_right sp_regular_padding">', $article['article']['link'], ' ',  $article['article']['new_comment'], '</div>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <br />';
    }

    if (!empty($articleperpage))
        echo '
                    <div class="sp_page_index">', $txt['sp-articlesPages'], ': ', $context['page_index'], '</div>';

    echo '
                </div>';
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy 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 Pyccak

  • Just Registered
  • Posts: 1
  • SMF Version: 2 RC3
  • SP Version: 2.3.3
Re: Listing Articles by category
« Reply #17 on: December 25, 2010, 11:04:35 AM »
Can help me with this last script by Nathaniel
If user post $category = 0 , them show all Articles by date. :)