TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

April 18, 2024, 03:48:35 AM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,164
  • Total Topics: 21,219
  • Online today: 190
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 124
  • Total: 124

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.

Dragooon

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 implement
Step 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/errors
Please use this thread for error reporting or feedbacks.

Thank you :)

Peregrinus

Great snippet, will definitely use this in the future on my site,

VIELEN DANK!


bluedevil

will this snippet show the last article made in a block?

say....a linked title perhaps?

Dragooon


bluedevil


Dragooon


bluedevil

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

Dragooon


G6Cad