TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,973
  • Latest: NonStop
Stats
  • Total Posts: 196,225
  • Total Topics: 21,352
  • Online today: 633
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 405
  • Total: 405

Putting categorybox PHP code into an article?

Started by signal15, December 07, 2006, 06:32:07 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

signal15

How would I place the categorybox PHP code into an article in PHP mode?  I basically want to make a page which lists things from a bunch of different categories, but in an article format, not a block.

Here's the code I took from the TP stuff:

function TPortal_categorybox()
{
    global $context, $settings, $options, $txt, $scripturl;

        if(isset($context['TPortal']['blockarticle_titles'][$context['TPortal']['blocklisting']])){
                echo '<div class="smalltext" ', (sizeof($context['TPortal']['blockarticle_titles'][$context['TPortal']['blocklisting']])>$context['TPortal']['blocklisting_height'] && $context['TPortal']['blocklisting_height']!='0') ? ' style="overflow: auto; width: 100%; height: '.$context['TPortal']['blocklisting_height'].'em;"' : '' ,'>';
                foreach($context['TPortal']['blockarticle_titles'][$context['TPortal']['blocklisting']] as $listing){
                        if($listing['category']==$context['TPortal']['blocklisting'])
                                echo '<b><a href="'.$scripturl.'?page='.$listing['id'].'">'.$listing['subject'].'</a></b> '.$txt[525].' '.$listing['poster'].'<br />';
                }
                echo '</div>';
        }
}


I'm assuming I would just need this part of the code:

foreach($context['TPortal']['blockarticle_titles'][$context['TPortal']['blocklisting']] as $listing){
                        if($listing['category']==$context['TPortal']['blocklisting'])
                                echo '<b><a href="'.$scripturl.'?page='.$listing['id'].'">'.$listing['subject'].'</a></b> '.$txt[525].' '.$listing['poster'].'<br />';
                }


But I'm sure it needs to be modified somehow to work in an article.  Any ideas on this?

signal15

Awww yeah, found a bit of code elsewhere and added category= in the select query.  Works like a charm.  Now I just need to figure out how to get rid of the DIV tags and the boxes and such, just a listing.


$articles=db_query("SELECT id,subject,intro,author FROM smf_tp_articles WHERE approved=1 AND off=0 AND category=8 ORDER BY date DESC", __FILE__, __LINE__);
$cnt=0;
While ($row=mysql_fetch_row($articles)) {
   // The number of articles you want displayed
   if ($cnt < 3) {
    echo '<table cellspacing="0" cellpadding="0" width="100%" style="margin-top: 4px;
             margin-bottom: 4px;" border="0" class="tborder"><tr>';
    echo '<td width="100%"><div class="titlebg" style="padding: 6px;">
    <img src="http://www.mywebsite.com/SMF/Themes/default/images/TParticle.gif" alt="*" style="margin: 0px;" align="middle" />
    <a href="http://www.mywebsite.com/SMF/index.php?page=' . $row[0] . '"><b>' . $row[1] . '</b></a></div><div style="padding: 8px; padding-top: 0px;" class="windowbg2">
    <div style="padding-bottom: 4px; vertical-align: bottom;" class="smalltext"> By :
    <b>' . $row[3] . '</a></b></div>' . $row[2] . '<br></div>
    <div class="windowbg"style="padding: 6px;">
    <a href="http://www.mywebsite.com/SMF/index.php?page=' . $row[0] .'">Read more...</a></div></td>';
     echo '</tr></table>';
    }
   $cnt++;
}

This website is proudly hosted on Crocweb Cloud Website Hosting.