Here is a Multi function Article Snippet which can be used as various purposes.
Features# Have 6 modes
- Recent Article
- Top Commented
- Top Viewed
- Top Rated
- Recent Comments
- Random Articles
# You have the ability to choose either all the categories to show the article/comments from, A Single category to show them from, or multiple categories to show them from
# Ability to set the max. no. of articles to show
# Have 7 options on weather to show 7 different attributes or not, Like rating, no. of Comments, no. of views, posting time/date, author, category it is posted in, and if you are using recent comments, ability to show the articles it is in.
# Ability to make the array return for further customizations(Mainly for the ones with coding skills)
How to implementStep 1 : Download the Attached file(ArticleSnippet.php) and as it is, upload it to your Sources Directory
Step 2 : In a PHP Block Add
// Multi Function Article Snippet
// By Dragooon
// www.gforumx.com
// Version 1.1
// Declare the globals to call the main file
global $sourcedir;
// And Call the file
require_once($sourcedir . '/ArticleSnippet.php');
// Declare it, No Need to edit this!
$cats = array();
/************************************
* About
************************************/
# Here is the way You can use it. Please keep reading this before using this snippet so that you will be able to take the full advantage of this snippet.
# There is a set of variables used later(In the function part) which are used to customize. Here is how to use them. Do Not edit the variables in this About, as it will Simply wont work :P
# $mode : This Controls the Mode. You can set it 1,2,3,4,5 or 6. Here is what each mode refers to.
# 1 : Recent Article Posted
# 2 : Top Commented
# 3 : Top Viewed
# 4 : Top rated
# 5 : Recent Comments
# 6 : Random Articles
# $limit : This controls the maximum no. of articles(Or comments if you have mode as 5) to show
# $cats : This is a array which can be specified to show articles(Or Comments if you have mode set to 5) from specific category or multiple categories. Leave blank to show from all categories or use 0 for the uncategorized ones, And use comma ( , ) as a separator. You have to enter the Category's ID not Name
# Now I'll be telling the 7 variables used for showing/not showing some stats/attributes of the article(Or Comment). Set to true if you want to show and false if don't
# $show_comments : Weather to show the no. of comments or not(Doesn't works if Mode is the 5th one).
# $show_views : Weather to show the no. of views or not(Doesn't works if Mode is the 5th one).
# $show_rating : Weather to show the rating of article and no. of voters or not(Doesn't works if Mode is the 5th one).
# $show_time : Weather to show the time the article/comment was posted on or not.
# $show_category : Weather to show the category it was posted in or not(Doesn't works if Mode is the 5th one).
# $show_author : Weather to show the articles/comments' author or not.
# $show_articleComment : Weather to show the article the comment was posted in(Only applies of Mode is the 5th one)
# $output_method : This is a tricky variable which I just included for the ones who have even Basic PHP/HTML Knowledge to customize the whole thing according to there wish. If Set as "array", this will stop showing anything but will return the variables but if set as "echo" it will show the default layout(Which is made mainly for using it in a Block). # If you are using the array method All the $show_ variable will get useless(you can use the variables returned to customize then ;) ). See the File to know what all the variables are.
# If you are using this, Make sure to set something like $item = *The rest of the function*, not just function and use a foreach loop later.
# This is the same way the SSI's $output_method behaves so if you are confused on how to use it, use it like the SSI's variable are used.
# If you don't know coding or don't want to change its looks, I recommend using it as the default "echo" method as IMO it is the best.
// This was the whole *How to* type of part. If you have questions/comments please use the Snippets Topic(From where you got it).
/************************************
* End About
************************************/
/************************************
* The Main Function
************************************/
articles(
$mode = 1,
$limit = 5,
$cats = array(),
$show_comments = true,
$show_views = true,
$show_rating = true,
$show_time = true,
$show_category = true,
$show_author = true,
$show_articleComment = true,
$output_method = 'echo'
);
/************************************
* And here it ends
************************************/
// Thank you for using this snippet :).Customization and How to customize is in the Block Code.
Version 1.1 Out : New mode! Random Articles
This can be used in multiple blocks/article for various purposes. The default layout is meant for blocks.
A Special thanks to StormLrd for giving me a big testing ground to test this
Change Log :
Version 1.0# Did the first initial release.
Version 1.0.1# Fixed the bug in which the limit wasn't affecting Recent Comments
Version 1.1# Added a mode 6 in which random articles will show
This has Been Tested but chances still remain of bugs/errorsPlease use this thread for error reporting or feedbacks.
Thank you :)
Great snippet, will definitely use this in the future on my site,
VIELEN DANK!
Thanks :)
will this snippet show the last article made in a block?
say....a linked title perhaps?
Ahhhhh Yes.......
Interesting. Im trying it now.
Hope you'll like it :)
Excellent. I love it. Although im using very minimal features. Is only set to 3.
This is great Dragoon. You should package this.
Top right block:
http://www.midwestavalancheclub.com/index.php
Glad you liked it :)
Way to go Dragooon :) :up: :D
Already told ya this on msn Dragooon but nice job on this one. I think a lot of people will find this very useful. Nice work. Keep em coming. :)
i have this error
Fatal error: Call to undefined function articles() in /home/myforum/public_html/v10/Sources/Load.php(1764) : eval()'d code(35) : eval()'d code on line 50
Are you sure you uploaded the file in your /Sources directory?
i have make triple check...
You are doing something wrong....Make sure it is in Sources directory of forum and its size on the server is 8-9 Kb
Good JOOOOB...
TQ...
:up:
ok... its run now...
hope... there is a option to put article intro for each article..
tq
There is no option for that.
Because if I trim down the body of it, Many times the HTML is unfinished causing problem in the whole page.
ok... tq..
how can i make bold text for article topic?
if I select mode 5, then I get ALL the comments, and I filled in:
$mode = 5,
$limit = 5,
What you mean by *all*?
EDIT : OK My Bad, This is a Bug.
I'll Fix it ASAP
Alright Updated!
thanks, but now the block doesn't display the ratings, if I select mode 5...
Thats because it is clearly stated in the "About"
I simply don't find a purpose why you want to show a rating of a comment because there is no rating for comments Lol :P
I said it before and here it is again...Excellent work man! :up:
imho this is what deafult modules should be out-of-box.
Thank you, Glad you liked it :)
Very nice snippet. I really like it. Thanks a lot Dragoon for developing it. Really great. ;)
Glad you liked it :)
I have question, if I want to display only article in a certain category I just change this x
$cats = array(x); to article id right.
No, Change the x to category ID.
Updated! :)
Alright, thanks again, I also like your new random articles. :d:.
Thanks Lol. It was based on your request only :P
is there a demo to see how it looks ?
Sorry but No. Since I made this on my local PC.
You can always try. And if you don't like its look, you can change them,.
ok thnx
Make sure to leave me a feedback(No matter weather good or Bad).
As a newbie could you tell me which PHP box to add in? You said any but with my limited knowlege I'd like specific info please. Thanks so much.
Also where do I get it? thanks.
There is only 1 PHP Block and what do you mean with your second post?
I simply could not see where to download it.
There is a attachment in the first post of this thread. Do as the steps of the implementation part say,
Hey Dragoon!
I liked this snip very much that I edited it so it displayes in table format using theme elements. Again, this is just the candy on top of your hard work. Let me know what you think here is the screenshot.
Thanks again for making this!
Thats cool!
Very good lil snippet!... Dragoon, I have a question... is it possible to add font size and font color to the script? I'd like to make the links more visible with a bold font or change the color...
You can always edit the file, See the foreach loop in it.
how can this Article Snippet be adding the intro of article?...
i think this is a good choice..
I wont add even the intro because even its HTML can break the whole page.
Quote from: Dragooon on December 12, 2007, 09:25:48 AM
Make sure to leave me a feedback(No matter weather good or Bad).
works like a charm ! thnx !
awesome snippet! I love it.
How can you turn $show_comments to a link so that it goes to the comments section of an article? I;m using the snippet to show the top rated (mode 4)
Very nice Dragooon :)
At the moment, I have no use for it, but it's sitting there waiting to be switched on.
Nice work aswell lebisol.:)
Great snippet! Thanks! One question though...
For the top rated option, is there a way to display it from highest to lowest of the top 5? It's showing the top 5 which is great, but it shows an article rated in this order:
1 - Rated 9
2 - Rated 8
3 - Rated 9
4 - Rated 7
5 - Rated 10
When I think it should be...
1 - Rated 10
2 - Rated 9
3 - Rated 9
4 - Rated 8
5 - Rated 7
I use the top rated option too and the same thing happens to me. It displays it as:
1 - Rated 5
2 - Rated 4
3 - Rated 5
I thought it would do something like that, I'll try to find a solution.
Quote from: Dragooon on March 14, 2008, 07:31:25 AM
I thought it would do something like that, I'll try to find a solution.
Great, thanks for considering!
Meh, No luck so far. I am still trying what I can do lol.
Quote from: Dragooon on March 16, 2008, 04:01:05 AM
Meh, No luck so far. I am still trying what I can do lol.
Yea, it's weird because now a different article came up, rated 7 (first rate) and replaced the one that was a 10 :)...
Great Snippet!
Is there a way to include the intro text with the article?
What I would really like to do (and I'm not sure this is the right snippet to be doing it in) is to post the intro to a random article from a single catagory (so one intro displayed at a time).
Thanks.
would it be possible to use this in an article?
What I have is a table of all the articles and i would like to the post info (# of comments, rating, views) for each article beside it.
I tried it in a php article and it didn't work. I just pasted the code from the first post (block code) and got some errors. I tried to solve it by removing what was causing an error but it never resolved.
You might post the code you used and we could see if we could help find the problems with it.
I tried out the code used for the block hoping it might work in a php article. Mind you, i don't know much in coding php.
// Multi Function Article Snippet
// By Dragooon
// www.gforumx.com
// Version 1.1
// Declare the globals to call the main file
global $sourcedir;
// And Call the file
require_once($sourcedir . '/Artclestats.php');
// Declare it, No Need to edit this!
$cats = array();
/************************************
* About
************************************/
# Here is the way You can use it. Please keep reading this before using this snippet so that you will be able to take the full advantage of this snippet.
# There is a set of variables used later(In the function part) which are used to customize. Here is how to use them. Do Not edit the variables in this About, as it will Simply wont work :P
# $mode : This Controls the Mode. You can set it 1,2,3,4,5 or 6. Here is what each mode refers to.
# 1 : Recent Article Posted
# 2 : Top Commented
# 3 : Top Viewed
# 4 : Top rated
# 5 : Recent Comments
# 6 : Random Articles
# $limit : This controls the maximum no. of articles(Or comments if you have mode as 5) to show
# $cats : This is a array which can be specified to show articles(Or Comments if you have mode set to 5) from specific category or multiple categories. Leave blank to show from all categories or use 0 for the uncategorized ones, And use comma ( , ) as a separator. You have to enter the Category's ID not Name
# Now I'll be telling the 7 variables used for showing/not showing some stats/attributes of the article(Or Comment). Set to true if you want to show and false if don't
# $show_comments : Weather to show the no. of comments or not(Doesn't works if Mode is the 5th one).
# $show_views : Weather to show the no. of views or not(Doesn't works if Mode is the 5th one).
# $show_rating : Weather to show the rating of article and no. of voters or not(Doesn't works if Mode is the 5th one).
# $show_time : Weather to show the time the article/comment was posted on or not.
# $show_category : Weather to show the category it was posted in or not(Doesn't works if Mode is the 5th one).
# $show_author : Weather to show the articles/comments' author or not.
# $show_articleComment : Weather to show the article the comment was posted in(Only applies of Mode is the 5th one)
# $output_method : This is a tricky variable which I just included for the ones who have even Basic PHP/HTML Knowledge to customize the whole thing according to there wish. If Set as "array", this will stop showing anything but will return the variables but if set as "echo" it will show the default layout(Which is made mainly for using it in a Block). # If you are using the array method All the $show_ variable will get useless(you can use the variables returned to customize then ;) ). See the File to know what all the variables are.
# If you are using this, Make sure to set something like $item = *The rest of the function*, not just function and use a foreach loop later.
# This is the same way the SSI's $output_method behaves so if you are confused on how to use it, use it like the SSI's variable are used.
# If you don't know coding or don't want to change its looks, I recommend using it as the default "echo" method as IMO it is the best.
// This was the whole *How to* type of part. If you have questions/comments please use the Snippets Topic(From where you got it).
/************************************
* End About
************************************/
/************************************
* The Main Function
************************************/
articles(
$mode = 1,
$limit = 5,
$cats = array(1),
$show_comments = true,
$show_views = true,
$show_rating = true,
$show_time = false,
$show_category = false,
$show_author = false,
$show_articleComment = false,
$output_method = 'echo'
);
/************************************
* And here it ends
************************************/
gfjfjfhj
gjygjgh';
Heres the error i got:
Parse error: syntax error, unexpected T_ECHO in /home/.eris/Sources/Load.php(1735) : eval()'d code(210) : eval()'d code on line 73
I can't figure out the original code, now that I look at it.
I'm pretty sure that you don't want this at the bottom of your code:
gfjfjfhj
gjygjgh';
But then I don't understand how the array works above it either.
Maybe Dragoon will be able to help.
can i use the two or three modes at a same time in one code. I want to have three columns there with different modes. One for top rated article, for random article and for most viewed article.
of course if will add this in the frontpage block.
Any one know how to do this? I will really appreciate any help. THanks in advance
Quote from: fangweile on June 05, 2008, 04:05:03 AM
can i use the two or three modes at a same time in one code. I want to have three columns there with different modes. One for top rated article, for random article and for most viewed article.
of course if will add this in the frontpage block.
Any one know how to do this? I will really appreciate any help. THanks in advance
Just add it in the 3 boxs
It will work.
Nope, I want to show the three modes in one block with three columns.
I have tried it and it works but it is rather show as vertical/row alignment.
I don't know what code to use and I already made a trial and error but there is no luck.
Any idea?
You can use
<table><tr><td>',first,'</td><td>',second,'</td><td>',third,'</td></tr></table>
And copy the variable/function 3 times and change the variable names
Am I being clear? :P
Congrats Dragoon this is a great snippet especially the Most Viewed ..
Will it be possible to get the "Most viewed" for the current month/ week /.. or anything other recent period of time.
In fact, after long time, oldest articles are obviously always on top because they have been seen from the begin.
Thanks!
I am not sure on how to get that, i'll see.
omg, thanks a lot Dragoon.
I already do that but it displays nothing
here is the code I used.
echo'<table><tr><td>'
articles(
$mode = 1,
$limit = 5,
$cats = array(1),
$show_comments = true,
$show_views = true,
$show_rating = true,
$show_time = false,
$show_category = false,
$show_author = false,
$show_articleComment = false,
$output_method = 'echo'
);
'</td><td>'articles(
$mode = 3,
$limit = 5,
$cats = array(3),
$show_comments = true,
$show_views = true,
$show_rating = true,
$show_time = false,
$show_category = false,
$show_author = false,
$show_articleComment = false,
$output_method = 'echo'
);'</td><td>'articles(
$mode = 5,
$limit = 5,
$cats = array(4),
$show_comments = true,
$show_views = true,
$show_rating = true,
$show_time = false,
$show_category = false,
$show_author = false,
$show_articleComment = false,
$output_method = 'echo'
);'</td></tr></table>';
I think my code is not that right.
Please pardon me for my PHP ignorance. :(
Try
echo'<table><tr><td>',
articles(
$mode = 1,
$limit = 5,
$cats = array(1),
$show_comments = true,
$show_views = true,
$show_rating = true,
$show_time = false,
$show_category = false,
$show_author = false,
$show_articleComment = false,
$output_method = 'echo'
),
'</td><td>'articles(
$mode = 3,
$limit = 5,
$cats = array(3),
$show_comments = true,
$show_views = true,
$show_rating = true,
$show_time = false,
$show_category = false,
$show_author = false,
$show_articleComment = false,
$output_method = 'echo'
),'</td><td>',articles(
$mode = 5,
$limit = 5,
$cats = array(4),
$show_comments = true,
$show_views = true,
$show_rating = true,
$show_time = false,
$show_category = false,
$show_author = false,
$show_articleComment = false,
$output_method = 'echo'
),'</td></tr></table>';
hello dragoon
I have tried your code but it doesnt show either.
[edit]
I have figured it out:
here is the code i used:
echo'<table><tr><td>';articles(
$mode = 1,
$limit = 5,
$cats = array(),
$show_comments = true,
$show_views = true,
$show_rating = true,
$show_time = true,
$show_category = true,
$show_author = true,
$show_articleComment = true,
$output_method = 'echo'
);
echo'</td><td>';articles(
$mode = 1,
$limit = 5,
$cats = array(),
$show_comments = true,
$show_views = true,
$show_rating = true,
$show_time = true,
$show_category = true,
$show_author = true,
$show_articleComment = true,
$output_method = 'echo'
);
echo'</td><td>';articles(
$mode = 1,
$limit = 5,
$cats = array(),
$show_comments = true,
$show_views = true,
$show_rating = true,
$show_time = true,
$show_category = true,
$show_author = true,
$show_articleComment = true,
$output_method = 'echo'
);
echo'</td></tr></table>';
I was having a trial and error and then luckily its perfectly works.
Thanks a lot Dragoon.
This article snippet is really great.
@koolad
maybe you just copy the wrong code there
require_once($sourcedir . '/Artclestats.php');
It must be
require_once($sourcedir . '/ArticleSnippet.php');
Quote@koolad
maybe you just copy the wrong code there
The filename is right. I changed how that php displays the info into this:
Comments: 1 | Views: 519
Rating: (5 Votes)
and renamed to Artclestats.php for articles since i use ArticleSnippet.php for the blocks. The code works fine in a block so i'm sure that the filename isn't the problem.
I'm trying to get it to work inside a php article because i have a list of articles with which i would like to display the above info beside each of them.
Dragoon is that possible?
It's a great block snippet -- which as was mentioned earlier should be one of the standard features :)
One thing I've been searching for, which I'm hoping this might be able to accomplish (or be modded to do): is there a way to have it output to an XML/RSS feed of the articles' titles? So far as I can find there's no one who's created such a thing for TP .98. (Does TP 1.0.5b include RSS?)
Any questions not related to the topic should be posted in their own topic in the appropriate board. Feature requests would be a good place to start your post after you search the board to make sure it hasn't been requested already.
Quote from: IchBinâ,,¢ on July 25, 2008, 07:20:27 PM
Any questions not related to the topic should be posted in their own topic in the appropriate board.
I *was* asking about this block and whether it can output to an XML format -- the question about 1.0.5 was ancillary, since if it already includes RSS, then it makes such a block less necessary.
Hi its a great mod. But how to set articles in horizontal position?
how can i put the background image? I have this
// echo '<div style="width: 100%; height: 135px; overflow: auto">';
echo '<table border="0" width="100%" cellspacing="1" cellpadding="1" id="RecentArticlesTBL" class="bordercolor">
<tr align="center" valign="middle" class="catbgcustom">
<td colspan="2"><span class="smalltext">Artikel Terbaru</span></td>';
// Show author column?
if($show_author)echo'
<td><span class="smalltext">Author:</span></td>';
// Show category column?
if($show_category)echo'
<td><span class="smalltext">Kategori</span></td>';
// Show the time its posted on column
if($show_time)echo'
<td><span class="smalltext">Published on:</span></td>';
// Show views column?
if($show_views)echo'
<td><span class="smalltext">Paparan</span></td>';
// Show comments column?
if($show_comments)echo'
<td><span class="smalltext">Ulasan</span></td>';
echo'</tr>';
foreach ($items as $i)
{
$counter++;
echo '<tr align="left" valign="middle">
<td class="windowbg2">
<img src="' . $settings['images_url']. '/topic/folder.png" width="16" height="16" border="0" alt="" /></td>
<td class="windowbg"><span class="smalltext">',$i['article']['artLink'],'</a></span>';
echo '';
echo '</div>';
// Show the author?
if($show_author)
echo '<td class="windowbg2"><span class="smalltext">',$i['author']['link'],'</span></td>';
// Show its category?
if($show_category && $i['article']['is_categorized'])
echo '<td class="windowbg"><span class="smalltext">',$i['cat']['link'],'</span></td>';
// Show the time its posted on
if($show_time)
echo '<td class="windowbg"><span class="smalltext">',$i['article']['time'],'</span></td>';
// Show there ratings?
if($show_rating)
{
// Is it rated?
if($i['article']['is_rated'])
{
echo '<td align="center" class="windowbg2"><span class="smalltext">',str_repeat('<img src="'.$settings['images_url'].'/tpblue.gif" style="width: .7em; height: .7em; margin-right: 2px;" alt="" />', $i['article']['rating']),' (',$i['article']['voters'],' rates)</span></td>';
}
// No?
else
{
}
// Show the no. of views?
if($show_views)
echo '<td align="center" class="windowbg"><span class="smalltext">',$i['article']['views'],' </span></td>';
// Show the no. of comments?
if($show_comments)
echo '<td align="center" class="windowbg"><span class="smalltext">',$i['article']['comments'],'</a></span></td>';
}
echo '</span></td>';
if($counter < $limit)
echo '';
}
echo '</table>';
}
i want to put only one background image for all table.
Let me google that for you! (http://letmegooglethatforyou.com/?q=css+background)
I have to admit I have never seen that Ichbin... too good...
I only use it for those types of things that can be learned about with a simple google search. :D
Hi, is it possible to display the poster avatar with this snippet ?
how can we make the post with two different background colour alternately?
Quote from: kopijun on February 16, 2009, 05:49:14 AM
Hi, is it possible to display the poster avatar with this snippet ?
just expecting someone could help... :-\
Quote from: kopijun on November 07, 2009, 07:01:01 PM
Quote from: kopijun on February 16, 2009, 05:49:14 AM
Hi, is it possible to display the poster avatar with this snippet ?
Did you read through the posts in this topic ? I think this have been discussed earlier in this very topic
just expecting someone could help... :-\
Quote from: G6 on November 08, 2009, 08:44:14 PM
Quote from: kopijun on November 07, 2009, 07:01:01 PM
Quote from: kopijun on February 16, 2009, 05:49:14 AM
Hi, is it possible to display the poster avatar with this snippet ?
Did you read through the posts in this topic ? I think this have been discussed earlier in this very topic
just expecting someone could help... :-\
I read through it G6, and I think I can't find anything about displaying avatar using this snippet..