07-24-2010, 09:26 AM
Basic usage of XThreads
We will use XThreads to add our custom script like javascript and CSS style per thread basis. And, we will use it to add some HTML code in postbit.
Here is a simple example for it:
Custom Thread Fields Setting:
Now, we can use HTML in the first post, and we can use some custom javascript and / or CSS style per thread basis.
With this way we can create "unlimited" HTML page directly from our forum. And of course we can edit, approve / unapprove each "page", because it is threads.
Live Demo:
This demo uses stylesheet link in header, and HTML in body.
Yeah, I grab a free template and put it there for the demo
http://www.14.mynie.co.cc/showthread.php?tid=54
This demo uses javascript link and custom style in header. HTML in body.
Using Frogjs v1.1 for this demo.
http://www.14.mynie.co.cc/showthread.php?tid=55
We will use XThreads to add our custom script like javascript and CSS style per thread basis. And, we will use it to add some HTML code in postbit.
Here is a simple example for it:
Custom Thread Fields Setting:
- Multiline Textbox for Script For Header:
Create a Custom Thread Fields with this settings:- Title: Script For Header
- Key: cshscr
- Applicable Forums: 'select forum'
- Input Field Type: Multiline Textbox
- Editable by / Required Field?: Administrator
- Display Parsing: No parsing (dangerous!!)
Variable in template for displaying this field is: {$GLOBALS['threadfields']['cshscr']}.
Please remember that we need to set the Editable by / Required Field? setting to Administrator. So, only Admin can use this field.
We can use this field to put some custom script in our header tag <head>......</head> via the {$GLOBALS['threadfields']['cshscr']} variable, like javascript and custom CSS style. Put the {$GLOBALS['threadfields']['cshscr']} variable in our showthread template, inside the header tag <head>......</head>.
Example (based on MyBB default showthread template):
Line #10:
HTML Code<head> <title>{$thread['subject']}</title> {$headerinclude} <script type="text/javascript"> <!-- var quickdelete_confirm = "{$lang->quickdelete_confirm}"; // --> </script> <script type="text/javascript" src="jscripts/thread.js?ver=1400"></script> {$GLOBALS['threadfields']['cshscr']} </head>
- Multiline Textbox for Script For Body:
Create a Custom Thread Fields with this settings:- Title: Script For Body
- Key: csbscr
- Applicable Forums: 'select a forum above'
- Input Field Type: Multiline Textbox
- Editable by / Required Field?: Administrator
- Display Parsing: Use MyBB Parser
- MyBB Parser Options: Check All Options
Variable in template for displaying this field is: {$GLOBALS['threadfields']['csbscr']}.
We can use this field to put some HTML code inside postbit. Again, please remember that we need to set the Editable by / Required Field? setting to Administrator, so, only Admin can use this field - can add HTML code in the postbit. Just put the {$GLOBALS['threadfields']['csbscr']} variable in postbit and postbit_classic template.
Example:
HTML Code<div class="post_body" id="pid_{$post['pid']}"> {$post['message']} {$GLOBALS['threadfields']['csbscr']} </div>
Now, we can use HTML in the first post, and we can use some custom javascript and / or CSS style per thread basis.
With this way we can create "unlimited" HTML page directly from our forum. And of course we can edit, approve / unapprove each "page", because it is threads.
Live Demo:
This demo uses stylesheet link in header, and HTML in body.
Yeah, I grab a free template and put it there for the demo
http://www.14.mynie.co.cc/showthread.php?tid=54
This demo uses javascript link and custom style in header. HTML in body.
Using Frogjs v1.1 for this demo.
http://www.14.mynie.co.cc/showthread.php?tid=55