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

Multifunction Article Snippet [Version 1.1 out]

Started by Megaforum, November 24, 2007, 07:56:07 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

koolaid

#60
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

JPDeni

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.

fangweile

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

Dragooon

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.

fangweile

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?

Dragooon

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

bobzr

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!

Dragooon


fangweile

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.  :(

Dragooon

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>';

This website is proudly hosted on Crocweb Cloud Website Hosting.