Thread Rating:
  • 2 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Using XThreads Custom Thread Fields For Plugin Settings
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #1
Using XThreads Custom Thread Fields For Plugin Settings
Requirement: XThreads
Last Update: 18 October 2011

I have an idea using XThreads custom thread fields as plugin settings. This is a simple example plugin that uses XThreads as its setting (attached).

This plugin will display thread title and its preview form selected thread. We need Thread Tooltip Preview plugin to display the preview, and put this variable in portal template:

Code:
{$xtdispportal_threads}


Create a custom thread fields with this setting:

  • Title: Display To Portal?
  • Key: xtdispportal
  • Applicable Forums: select some forums
  • Input Field Type: Listbox
  • Field Input Height: 1
  • Values List :

    Code:
    Yes

  • Editable by / Required Field? : Administrators
  • Allow Filtering: Yes

That is our plugin setting. Basically, we need a setting that we can choose Yes in a thread that want be displayed in portal. We can set it when creating a new thread or editing an existing threads.

Because this is not a required fields, we will get two option in new thread or edit post page:

Code:
(Not set)
Yes


The (Not set) is the "default value". So, when a regular user create a new thread or edit their thread, this value will be set automatically. Of course they can't change the setting because we already set this custom thread fields permission to Administrators only. And we can give the "power" to some user group like Super Moderator or Moderator to be able to set a thread to be displayed in portal, if there is a good thread from member to display (by editing the thread, select Yes in the setting).

Optional Setting
Do this only if we are allowing Moderators to set a thread to be displayed in portal.

Create Moderator Tools:
Admin CP -> Configuration -> Moderator Tools -> Add New Thread Tool

  • Name: Display In Portal
  • Name: Display this thread in portal
  • Available in forums: Select in which forum we apply the xtdispportal custom thread field. Related to Applicable Forums setting of the custom thread field.
  • Modify Custom Thread Field(s):
    • Field: xtdispportal
    • Value: Yes

    Code:
    xtdispportal=Yes

With this custom Moderator Tools, we can set a thread to be displayed in portal directly without needed to full edit the thread.

Of course this is for example only. We need to create different settings depends on what settings needed for our plugin.

Update Logs: 19 March 2011


Attached File(s)
.7z  xtdispportal.7z (Size: 2.09 KB / Downloads: 712)

(This post was last modified: 10-18-2011 05:56 AM by RateU.)
09-20-2010 06:12 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: Using XThreads Custom Thread Fields For Plugin Settings
That's a damn good idea RateU - I like it! Smile

Looking through your plugin quickly, in the xtdispportal_run function, just seems like you forgot to global $mybb Tongue
Otherwise, looks like it's coded pretty damn well!

My Blog
09-20-2010 08:34 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #3
RE: Using XThreads Custom Thread Fields For Plugin Settings
Wow RateU - this is an awesome idea and JUST what I have wanted for a while - it would be great to be able to define a thread as visible on the portal page. I am downloading the plugin to have a look.

Thank you

EDIT
I had a look at the plugin, fixed the non globalling on the run function and I tested on LeeFish (I hope its ok) and yea, guess what? I was wondering if a thumbnail image could be added......

I was trying to add it in myself, but I got a bit lost in all the post parsing Frown

Code:
1
2
3
4
5
6
7
8
9
10
11
12
	$xtdispportal_icon_cache = $GLOBALS['cache']->read('posticons');
	$query = $db->query('
		SELECT t.*, t.username AS tusername, u.username, u.avatar, u.usergroup, u.displaygroup, a.aid, f.name
		FROM '.TABLE_PREFIX.'threads t
		LEFT JOIN '.TABLE_PREFIX.'users u ON (u.uid=t.uid)
		LEFT JOIN '.TABLE_PREFIX.'xtattachments a ON (a.tid=t.tid)		
		LEFT JOIN '.TABLE_PREFIX.'threadfields_data td ON (td.tid=t.tid)
		LEFT JOIN '.TABLE_PREFIX.'forums f ON (f.fid=t.fid)
		WHERE t.visible=1 AND td.xtdispportal="Yes" AND t.closed NOT LIKE "moved|%" AND a.thumbs!=""'.$xtdispportal_unviewwhere.'
		GROUP BY a.tid
		ORDER BY t.dateline desc
	');


I tried the above code in the query and it does not crash, but also no pic...

so I added this extra line:

Code:
			$xtdispportal_replies = my_number_format($xtdispportal['replies']);
			$xtdispportal_att_thumb = xthreads_get_xta_url($xtdispportal).'/thumb240x180';
			$xtdispportal_views = my_number_format($xtdispportal['views']);


and I added to the template

Code:
{$xtdispportal_att_thumb} 

But still no thumb.

I hope its ok for me to do this - I look at/alter other peoples plugins to try and learn.

EDIT
And I am back again... After several hours of banging my head on the wall I realised that the ICON (as coded by RateU in the original plugin) also does not show in the portal - so it seems like its something to do with images. I have attached my file.

Also, I don't want to seem like a whiner or to overshadow the great work RateU has done here, I really appreciate this plugin and all the work he does to help us all with implementing XThreads.



Attached File(s)
.php  xtdispportal_leefish_edit.php (Size: 5.19 KB / Downloads: 616)


[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 09-21-2010 04:15 AM by leefish.)
09-20-2010 09:29 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #4
RE: Using XThreads Custom Thread Fields For Plugin Settings
@Yumi: Thank you very much, Yumi. Yeah, I've missed that $mybb Oops

(09-20-2010 09:29 AM)leefish Wrote:  I realised that the ICON (as coded by RateU in the original plugin) also does not show in the portal

Krrrk... I'm really sorry for the mistake, Lee Oops I've fixed the problem. You can download it again from the first post. Or, if you want to do it manually, find this code:

PHP Code:
				$xtdispportal_thread_icon = '<img src="'.$xtdispportal['path'].'" alt="" title="" />';


Replace it with this:

PHP Code:
				$xtdispportal_thread_icon = '<img src="'.$xtdispportal_thread_icon['path'].'" alt="" title="" />';
			}else{
				$xtdispportal_thread_icon = '';


You can put an image URL as a "default" thread icon there if you want.

(09-20-2010 09:29 AM)leefish Wrote:  I was wondering if a thumbnail image could be added......

Do you want to make it "general"? I mean, not all thread have an attachment?

09-21-2010 06:17 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #5
RE: Using XThreads Custom Thread Fields For Plugin Settings
Well, not all threads do - but I was planning to make a variant of the plugin and only use it for my downloads forums. And they DO all have at least one image attachment as its a required field.  Ideally to have either random or latest.


[Image: leelink.gif]
MYBB1.6 & XThreads
09-21-2010 06:23 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #6
RE: Using XThreads Custom Thread Fields For Plugin Settings
If you look at the query in your modified latest images in profile, you can make it like that. But unfortunately, only accepting a thread with has an image.

09-21-2010 06:40 AM
Find all posts by this user Quote this message in a reply
Imran Offline
Member
***
Posts: 204
Joined: Apr 2010
Post: #7
RE: Using XThreads Custom Thread Fields For Plugin Settings
Great idea RateU Smile

[Image: logo.png]

[Image: twitter.png]
09-21-2010 06:48 AM
Visit this user's website Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #8
RE: Using XThreads Custom Thread Fields For Plugin Settings
(09-21-2010 06:40 AM)RateU Wrote:  If you look at the query in your modified latest images in profile, you can make it like that. But unfortunately, only accepting a thread with has an image.

Hi Rateu, well that is what I did - thats in the updated file attached to my post but I cannot get it to show, and I know these threads I have chosen have images.

I am not sure what I am doing wrong :/

The first link is the link I get in the select source when i view the plug in on the portal:

Code:
xthreads_attach.php/164__2caa1de4/e0210197d8a7a6b545d61767de41f3e4/MidCentury-recolours.jpg/thumb160x120


This is the link Iget when viewing the same image from the profile page

Code:
xthreads_attach.php/164_1281553459_2caa1de4/e0210197d8a7a6b545d61767de41f3e4/MidCentury-recolours.jpg/thumb160x120


there is a chain of numbers missing  1281553459  - any idea what may be causing that?



[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 09-21-2010 08:10 AM by leefish.)
09-21-2010 07:04 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #9
RE: Using XThreads Custom Thread Fields For Plugin Settings
Look at the attached file bellow. This will get all thread with setting Yes and has a thumbnail.

Unfortunately, I don't know how to "activate" the threadfields variable with image. I can activate it only with other input field type.


Attached File(s)
.php  xtdispportal.php (Size: 5.29 KB / Downloads: 696)

09-21-2010 07:40 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #10
RE: Using XThreads Custom Thread Fields For Plugin Settings
(09-21-2010 07:40 AM)RateU Wrote:  Look at the attached file bellow. This will get all thread with setting Yes and has a thumbnail.

Unfortunately, I don't know how to "activate" the threadfields variable with image. I can activate it only with other input field type.


Thank you RateU - I shall spend some time comparing the two plugins - I have no idea where I was going wrong.

The method of assigning a field is great - I dont see the need of making it an image - I did have a go at making it a hidden field and the using php templates to make it only visible to admin so I could do it straight from showthread but no luck. I seem to be having a fail day today Frown


[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 09-21-2010 08:43 AM by leefish.)
09-21-2010 08:40 AM
Visit this user's website Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: