MyBB Hacks

Full Version: Using XThreads Parser
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Basic usage of XThreads Biggrin
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:
  1. 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>

  2. 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 Biggrin
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
Shocked  You've totally gone beyond the idea of simple threads with that example there.
Amazing work!
Biggrin
Thanks, Yumi Smile
I think we can use it for many purposes.
Amazing example of what you can do with XThreads! Thanks for sharing
This is amazing. I will have to think of a use for this.
Hmm, I was plodding along as usual and I have been trying to make a TABS field, so in a thread certain users can apply tabs to separate content in a thread into tabs. Im not sure if I am posting in the right place, but as I want this to be restricted and I think its HTML, maybe this is the right place. Any tips?
Maybe something like this will work as basic (using the jquery tabs):
Tabs Title -> Text Box
Tabs Contents -> Multiline Textbox
Repeat it.
Play with the display format.
Put the variable in template_prefix_showthread or template_prefix_postbit_first / classic.
Hmmm, weird thing, I was using this to show some custom stuff on the forum - and I realised that it has "stopped working" ....

I have some posts that used to have embedded videos - now there are no videos. I checked my settings - all seems ok.  I have no idea when this happened, but it does make my posts look a bit odd, pointing to a video which is not there....

EXAMPLE POST :  http://www.leefish.nl/mybb/thread-804.html
I don't know what stuff/change/edit you did for the forum. What it should be if it is "working"?
(11-30-2010 05:15 AM)RateU Wrote: [ -> ]I don't know what stuff/change/edit you did for the forum. What it should be if it is "working"?

(11-30-2010 05:03 AM)leefish Wrote: [ -> ]I have some posts that used to have embedded videos - now there are no videos. I checked my settings - all seems ok.  I have no idea when this happened, but it does make my posts look a bit odd, pointing to a video which is not there....
EXAMPLE POST :  http://www.leefish.nl/mybb/thread-804.html

I'm not sure what else to say. I embedded videos - using this method - it worked - now the videos are no longer visible when I view the post. The data is still there if I edit post. The ONLY thing I did was add the variable to the first post - there are no other custom templates etc in that particular forum.
Pages: 1 2
Reference URL's