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

Recent

Welcome to TinyPortal. Please login or sign up.

March 28, 2024, 08:37:14 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,104
  • Total Topics: 21,212
  • Online today: 174
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 171
  • Total: 171

Multi-Functional Posts and Topics Snippet [Version 3.0 out!]

Started by Megaforum, October 14, 2007, 05:08:24 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dragooon

This was known as "Highly Customizable Recent Posts/Topics, Board News Block" but I renamed it because the previous one sounded to silly :P.
The version 3.0 introduces many new features and optimizations, so updated both, your block code and your File to take its advantage




Features in Version 3.0
# Have 4 modes

               
  • Recent Posts
  • Recent Topics
  • Top Viewed
  • Top Replied
# You have the ability to select weather to show from sticky topics only or from all topics
# Can be set to show topics/posts from a defined single board, all the boards, or multiple set of boards
# Can be set to show topics/posts from a defined category, all categories or multiple selected categores
# Easy customization, Every customization is at one place, and is greatly instructed with comments
# Ability to set a character limit to subject
# Ability to show some part of the posts/topics body and ability set its character limit
# Supports all 3 kinds of blocks(Left, Right and Center)
# Works with permission, A user sees what it can see.
# Amount of topics/post to output can be changed
# Supports scroll
# Supports Auto Scroll
# Parses BBC and there is a option weather to Parse Smiley or not
# Have various options to show various attributes of the topic/post.


Kindly Note : Enabling Auto Scrolling will break XHTML Validation. This only applies if you have Auto Scrolling enabled(which is not by default). Rest is XHTML Valid.


Implementation
Step 1 :
Download the PHP File I attached (PostsTopicsSnippet.php) and Upload it to your Sources(/Sources) Directory.
Step 2 :
In a PHP Block add this code
// Posts/Topics Snippet
// By Dragooon
// www.gforumx.com
// Version 3.0

//The instructions are posted in the thread of this snippet + they are quite here.

// Lets call the file
global $sourcedir;
require_once($sourcedir . '/PostsTopicsSnippet.php');

// Declare it. There is NO need to edit this part
$boards_id = array();
$cats_id = array();
/************************************
* How To Customize!
************************************/
# This is how to customize the block. To customize this please edit the variable given in the Below function call (postsTopicsSnippet). Do Not edit the variables given in this How To. This How to explains, what is the variable is and what does it do.
# How to Customize is given below.
# Make sure not to remove ANY comma
# Make sure not to remove "array()" part in the $boards_id and $cats_id variables.

# $mode : Mode of the Block
# 1 = Recent Topics
# 2 = Recent Posts
# 3 = Top Viewed
# 4 = Top Replied

# $boards_id : ID Of Boards to show the posts/topics from
# Do Not remove array() part, Insert the ID(s) of boards you want posts to show from.
# Use comma ( , ) as a separator
# Example : $boards_id = array(1, 2, 3)
# Leave empty to grab posts from all boards

# $cats_id : ID Of categories to show the posts/topics from
# Do Not remove array() part, Insert the ID(s) of categories you want posts to show from.
# Use comma ( , ) as a separator
# Example : $cats_id = array(1, 2, 3)
# Leave empty to grab posts from all categories

# $stickyOnly : Weather to get the topics which are sticky only or not
# true : yes
# false : no

# $limit : Maximum no. of topics/posts to show

# $subjectLength : Max characters the subject can have.

# $bodylength : Max characters the subject can have
# Setting it to 0 will result showing of no body.

# Below are some configuration variables
# For these, if set to true, it means Yes.
# If set to false, it means no.

# $parseSmileys : Weather to parse smileys or not

# $show_board : Weather to show the board the topic/post is posted in or not

# $show_views : Weather to show the no. of views or not

# $show_replies : Weather to show the no. of replies or not

# $show_category : Weather to show category or not

# $show_author : Weather to show the author who posted this or not

# $show_newIcon : If the post is unread, weather to show the New Icon or not

# $show_time : Weather to show the time the post/topic is posted on or not

# $scroll : If the height it longer than 40 pixels, weather to make it as a scroll or not

# $aScroll : Weather to make it auto scroll or not
# NOTE : If $scroll AND $aScroll are both true, $scroll turns back to false so that it doesn't clashes.
/************************************
* End How to Customize!
************************************/

/************************************
* The Function!
************************************/
postsTopicsSnippet(
$mode = 1,
$boards_id = array(),
$cats_id = array(),
$stickyOnly = false,
$limit = 5,
$subjectLength = 25,
$bodylength = 100,
$parseSmileys = true,
$show_board = true,
$show_views = true,
$show_replies = true,
$show_category = true,
$show_author = true,
$show_newIcon = true,
$show_time = true,
$scroll = true,
$aScroll = false
);

//Thank you for using this Code snippet.

And you are done :).



Made by Dragooon(me).
Version 3.0
Posts/Topics Snippet



Change log
# Version 3.0 :
# Renamed it to "Posts/Topics Snippet" from "Custom Recent Posts/Topics, Board News"
# Renamed the file to "PostsTopicsSnippet.php" from "RTP_BN2.3.php"
# Renamed the function from recent_post23 to postsTopicsSnippet
# Changed a lot of coding
# Made this snippet faster
# Added ability to choose categories from which only the posts will show
# Added ability to weather show there various attributes or not, each indivisually
# Added a option(stickyOnly) which if selected will show posts only from Sticky Topics, because of this addition Mode 3 and 4 are replaced by 2 New modes
# A new 3rd Mode : Top Viewed
# A new 4th Mode : Top Replied

Rest changelog can be found in the file



Please Note: This snippet is tested and no errors are found but still there is a chance of bugs, if so please post the bug/error here.

All Comments, Questions, Suggestions etc can be posted here

jacortina

Quote from: Dragooon on October 14, 2007, 05:08:24 PM
Why did I used a External File?
#1 - Its easier to edit and customize

I can't say that pressing the 'Save' button on a block or article is that difficult (compared to saving and FTPing a file), but if you were going to go this route, you could just make the values arguments of the function (with defaults) and not have to bother with changing them in code.

function recent_post20($board = 0, $limit = 5, $bodylength = 128, $mode = 1)

This would also allow different blocks/articles to call it in different ways (one block for topics and another for sticky posts, for example).

Dragooon

I thought of that way, But left it somehow.
Also If You read my 2nd reason, You'll get the true answer.
EDIT:
OK I might release a V 2.1 sooner or later, That will have what J.A. said


samo_zin123


tell me how to customizethe whole length of the block i want to make the scroller disappear


Dragooon

To Make the Scroller disappear Open up RTP_BN2.1.php find
     <div style="width: 100%; overflow: auto; height: 40ex;">';
And change to
     <div style="width: 100%;">';
Untested but should work.


Crip

I have become comfortably numb!

Cripzone | Crip's Free 2.0.2 Themes



Dragooon

I wasn't able to arrange one yet. It is quite same as TP's one (Layout wise).

jacortina

Couple of comments specifically on the query:

You call THAT query big and bad? ;)

I don't think you really need the criteria "AND b.memberGroups = b.memberGroups".

Also, you should allow for those who haven't enabled a recycle board:
AND b.ID_BOARD != $modSettings[recycle_board]
Should probably be replaced by:
(!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '')