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,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,913
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 566
  • Total: 567
  • @rjen

Recent Articles For Center Block

Started by opschf, March 13, 2006, 03:48:35 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

opschf

I wanted a section for recent posts and I also wanted one for recent articles.  I am just getting my website up and running.  I could not figure out how to do it, so I gave up and wrote a phpbox to do this function as follows:


$articles=db_query("SELECT id,subject,intro,author FROM tportal_articles WHERE approved=1 AND off=0 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++;
}
If  ($cnt=0) {
    echo '<td>No Artcles to review.  Please submit articles.';
    }



[attachment deleted by admin]

Arkanthos

#1
Blimey, that's exactly what I was trying to do this afternoon. I have a list of about 80 articles I'm bringing over from phpNuke where I had the handy dandy universal module to keep them neat and pretty. Thanks bro, big help.

Just one note, you might want to put a header section on this .txt and alter it a little bit for those who are less adept at scanning for material that needs to be changed. I'll toss one up just to show ya what I'm talking about.

[attachment deleted by admin]

opschf

#2
I also added on the left hand side a block that lists the categories for articles.  Maybe you would find this useful as well...

$categories=db_query("SELECT * FROM tportal_variables", __FILE__, __LINE__);
While ($row=mysql_fetch_row($categories)) {
if ($row[4] == "category" && $row[0] != 46) {  // I exclude one category
echo '<a href=http://www.
mywebsite.com/SMF/index.php?cat=' . $row[0] . '>' . $row[1] . '</a><br>';
}
}
echo'
<br>
<br>
<i>More categories will be added as articles are received.<i>';


Let me know what you think of them...   ;D

Arkanthos

When I go to use the first one I'm getting

Table 'DBNAME.tportal_articles' doesn't exist
File: PATH/Sources/Load.php(1607) : eval()'d code(32) : eval()'d code
Line: 2


I've masked the path and DBname just for my own sense of security, can't be too careful

opschf

you need to check your database.  From the alarm, it cannot find the table "tportal_articles", which is the defaulted table name in program.  Go into phpmyadmin or similiar program and find where the table for tportal are listed.  Let me know if this helps.

Harro

#5
Thanks for this. Was looking for it!
Modified it a bit.
Better for one of the side blocks now. Only displays the title of the article.
Here's the code if anybody is interested.
Example can be seen on http://www.forumaffiliates.net on the left sidebar.
$articles=db_query("SELECT id,subject FROM smf_tp_articles WHERE approved=1 AND off=0 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 '<a href="http://www.forumaffiliates.net/index.php?page=' . $row[0] . '">' . $row[1] . '</a><br /><br />';
    }
   $cnt++;
}
If  ($cnt=0) {
echo '<td>No Artcles to review.  Please submit articles.';
}

datu

Hey guys this is a great piece of code. very useful for me. Keep up the great work. Thnx a bunch!

I was wondering how you could modify this just to show specific articles, and not the most recent?

Thanks again, cheers!

Harro

For specific articles you can just create an html block and put the url to the articles there.

datu

Yah thats what im doing now.. i just wanted to be lazy and have a script do it for me.. haha

Oh well..

Thnx for the reply

aglioeolio

thatÂÃ,´s exactly what I wanted

thanks a lot

This website is proudly hosted on Crocweb Cloud Website Hosting.