TinyPortal

Development => Support => Topic started by: domeen on September 28, 2007, 09:59:07 AM

Title: Related articles
Post by: domeen on September 28, 2007, 09:59:07 AM
Hi, I'am looking for a mod, that show related articles below an article.

So i have a article named PICTURE DUMP 10, and I want that below that article, the related articles are show, Picture dimp 1, picture 2....etc..
Title: Re: Related articles
Post by: Ken. on September 28, 2007, 03:26:51 PM
There is already a feature in your Article Options that will 'Show all articles in same category'

Give that a try to see if it's what you need.
Title: Re: Related articles
Post by: domeen on September 30, 2007, 11:03:04 AM
Ok ken, I saw that, but then I will get a list of the articles on the right of the article.. I want that a list of the articles below the article...so, above the comments....
Title: Re: Related articles
Post by: IchBin on September 30, 2007, 09:12:10 PM
You'll have to add some custom code for that. There's a block code snippet that I did (I think it was me), for listing article in a category. You can add that code to the bottom of your article. It will however have to be a php article.
Title: Re: Related articles
Post by: rockskullz on October 01, 2007, 11:37:27 PM
I would be interested in this mod as well. If anybody with the knowledge could take a few minutes to help out that would really appreciated.
Title: Re: Related articles
Post by: IchBin on October 02, 2007, 12:25:15 AM
If you're related articles are in a category then the mod (code snippet) is already there.
Title: Re: Related articles
Post by: rockskullz on October 02, 2007, 02:53:53 AM
Sorry kind of a newbie as far as finding what code to snip or what file to look in for that matter.
Title: Re: Related articles
Post by: IchBin on October 02, 2007, 03:46:01 AM
Here's the code for a category. Just change the category number variable to the category ID that you want to list the articles from.


global $db_prefix, $scripturl;

$category = 1;

$query = db_query(
    "SELECT id, subject
     FROM {$db_prefix}tp_articles
     WHERE category = $category
     AND off = 0
     AND approved = 1
     ORDER BY subject", __FILE__, __LINE__);
echo '<div style="overflow: auto; width: 100%;">';

$i = 0;

echo '<table cellspacing="0" cellpadding="0">
<tr>';
while ($row = mysql_fetch_assoc($query)){
  echo '<td style="padding-left: 20px;"><a href="' . $scripturl . '?page=' . $row['id'] . '">' . $row['subject'] . '</a></td>'; 
$i++;
if ($i > 2){
echo '</tr><tr>';
$i = 0;
}
}
echo '</tr></table>';
echo '</div>';
Title: Re: Related articles
Post by: rockskullz on October 02, 2007, 08:54:50 PM
Thanks IchBin, But I think i must be doing something wrong. It works but Its putting the 'recent articles' ontop of the 'set' catergory of article not at the bottom of each article itself... 
Title: Re: Related articles
Post by: IchBin on October 03, 2007, 03:01:14 AM
You're putting it in the block then. In TP 0.9.8 you don't have a bottom block option. You'll have to put it in the article or put it in the theme code manually. Its up to you.
Title: Re: Related articles
Post by: domeen on October 05, 2007, 07:23:00 AM
mmm, the article must be php...if I want to add that code to the article....that's a problem for me..
Title: Re: Related articles
Post by: rockskullz on October 05, 2007, 07:43:28 AM
me too.
Title: Re: Related articles
Post by: IchBin on October 05, 2007, 10:30:04 PM
Quote from: domeen on October 05, 2007, 07:23:00 AM
mmm, the article must be php...if I want to add that code to the article....that's a problem for me..
Not if you make a PHP article. :)