News: Welcome to the TinyPortal Support site.

Login  |  Register
HTML5 Icon HTML5 Icon
TP on Social Media
Welcome, Guest. Please login or register.
Did you miss your activation email?

September 17, 2019, 05:05:54 AM

Login with username, password and session length

Recent

Members
  • Total Members: 3752
  • Latest: Alizee
Stats
  • Total Posts: 188890
  • Total Topics: 20752
  • Online Today: 69
  • Online Ever: 629
  • (November 08, 2018, 01:36:54 PM)
Users Online
Users: 0
Guests: 50
Total: 50

Author Topic: Multifunction Article Snippet [Version 1.1 out]  (Read 29646 times)

0 Members and 1 Guest are viewing this topic.

Offline Dragooon

  • Hero Member
  • *****
  • Posts: 994
Multifunction Article Snippet [Version 1.1 out]
« on: November 24, 2007, 12:56:07 AM »
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
Code: [Select]
// 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 :)
« Last Edit: December 06, 2007, 12:38:31 AM by Dragooon »

Peregrinus

  • Guest
Re: Multifunction Article Snippet
« Reply #1 on: November 24, 2007, 04:56:43 AM »
Great snippet, will definitely use this in the future on my site,

VIELEN DANK!

Offline Dragooon

  • Hero Member
  • *****
  • Posts: 994
Re: Multifunction Article Snippet
« Reply #2 on: November 24, 2007, 05:48:26 AM »
Thanks :)

bluedevil

  • Guest
Re: Multifunction Article Snippet
« Reply #3 on: November 24, 2007, 07:06:47 AM »
will this snippet show the last article made in a block?

say....a linked title perhaps?

Offline Dragooon

  • Hero Member
  • *****
  • Posts: 994
Re: Multifunction Article Snippet
« Reply #4 on: November 24, 2007, 07:07:47 AM »
Ahhhhh Yes.......

bluedevil

  • Guest
Re: Multifunction Article Snippet
« Reply #5 on: November 24, 2007, 07:09:24 AM »
Interesting. Im trying it now.

Offline Dragooon

  • Hero Member
  • *****
  • Posts: 994
Re: Multifunction Article Snippet
« Reply #6 on: November 24, 2007, 07:12:02 AM »
Hope you'll like it :)

bluedevil

  • Guest
Re: Multifunction Article Snippet
« Reply #7 on: November 24, 2007, 07:25:10 AM »
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

Offline Dragooon

  • Hero Member
  • *****
  • Posts: 994
Re: Multifunction Article Snippet
« Reply #8 on: November 24, 2007, 07:29:27 AM »
Glad you liked it :)

Offline G6Cad

  • Friends
  • *
  • Posts: 12643
    • FamiljeGodis
Re: Multifunction Article Snippet
« Reply #9 on: November 24, 2007, 11:00:32 AM »
Way to go Dragooon :)   :up:  :D