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,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 206
  • Total: 206

[Discussion] Simple Article Index

Started by freddy888, October 08, 2009, 02:53:53 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

saks

#30
The block which I have specified, works well. It shows last five articles from the chosen categories and it is convenient for using in the left or right panel on the main page of a site. I didn't have a question, I only wanted to show to its everything, that is possible it to whom it will appear useful.

lurkalot

saks, as it states it's a simple article index.  I don't think it has any permissions to adjust.  Freddy might be able to mod it for you. 

I suppose you could set the whole block to groups that should see it, as a workaround.

Or try this block. Not sure what it's like as I haven't tried it, but I believe it has permission settings.  http://www.tinyportal.net/index.php?topic=33195.0

Freddy

Yes, just a simple block - you could use block permissions as Lurkalot suggests.

saks

After update for last TP version this block is not work in my site, and show error:
Fatal error: Call to undefined function tpdb_query() in /usr/local/www/data-dist/saks/Themes/default/TPsubs.template.php(114) : eval()'d code on line 13

How can I fix it ?

lurkalot

saks,   SMF 2.x ?

If so, TP uses the new and improved $smcFunc['db_query'] for TP + SMF2 that's probably why it stopped working.  Your snippet will need updating to work.  I'm not sure if Freddy updated the snippet yet, but I have the updated version running on my site, if you need it.

saks

Yes! I use SMF 2.01. I will be very grateful for this updating

Freddy

Thanks Lurkalot that saves me some work :)

If you want to post it here I will add it to the snippets board.

I don't suppose you can get a screen shot of it in action if you get a minute ?

lurkalot

No problem, this should be the one. Don't forget to make a note of your categories array before you swap the code ;) 

@Freddy, this is also in the team board, it was updated by Brad for me when I upgraded.  I don't have many articles to be honest, but I'll try and get a screengrab shortly.


// Configuration

// Specify your categories, comma separated if more than one category.
$categories = array(1,3,10);

// The heading area.

echo '
<div style="text-align: center; border: 1px solid #242526; ">   
   <h3>Articles Index</h3>
   <p>This is a list of articles, submitted by our members.</p>
</div>
<br />';

// Now for the code...
global $scripturl, $db_prefix, $smcFunc;

$request = $smcFunc['db_query']('', '
SELECT id, date, subject, views, shortname
FROM {db_prefix}tp_articles
WHERE category IN ({array_int:cats})
AND off = 0
ORDER BY date DESC',
array('cats' => $categories)
);

echo '
<table class="tborder" width="100%">
   <tr class="titlebg">
      <td>Subject</td>
      <td>Date</td>
      <td align="center">Views</td>
   </tr>';

while ($row = $smcFunc['db_fetch_assoc']($request))
{
   if ($row['shortname'])
   {
      $pageid = $row['shortname'];
   }
   else
   {
      $pageid = $row['id'];
   }

   echo '
   <tr class="windowbg">
      <td style="padding: 3px 0px 3px 10px"><strong><a href="' , $scripturl, '?page=' , $pageid , '">' , $row['subject'] , '</a></strong></td>
      <td style="padding: 3px 0px 3px 10px">' , date('jS, F Y', $row['date']) , '</td>
      <td align="center" style="padding: 3px 0px 3px 15px">' , $row['views'] , '</td>
   </tr>
';
}

echo '
</table>';

$smcFunc['db_free_result']($request);

lurkalot

This might be a bit small.  I'll update it if you like.

Freddy


This website is proudly hosted on Crocweb Cloud Website Hosting.