It appears you have not yet registered with our community. To register please click here...

vbulletin-skins-forum
| Discussions: 2,375 | Messages: 7,054 | Members: 5,722 | Online: 30 | Newest : yukimura1231 (Welcome!)
Logo
All times are GMT -5. The time now is 08:25 PM.

Go Back   Forums Help - vBulletin, IPB, phpBB, SMF skins and community > Forum Areas > Forums In Depth > Forums Articles

Forums Articles Articles related to forums

Tags: , , , ,

Comment
 
LinkBack Article Tools Search this Article Display Modes
<!-- google_ad_section_start -->vBulletin - [How-To]Include a code without editing<!-- google_ad_section_end -->
vBulletin - [How-To]Include a code without editing
Published by Ziki
01-11-2007
vBulletin - [How-To]Include a code without editing

So you want a product hack and do not want to do any template editing?Read this and find out how.

I will use my right click disabled hack as example.
I guess I don't need to explain what a product is , if yes read other tuts.



Firstly take your code and put it into a template.(Can't be PHP!If is php simply use plugins and hooks!)

Code:
           <templates>
        <template name="zh_nrc" templatetype="template" date="1148052896" username="Ziki" version="3.5.4"><![CDATA[
        <script language=JavaScript>

var message="$zhnrctext";
function clickIE() {if (document.all) {alert(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {alert(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

</script>
]]></template>
    </templates>
So we have a template that containst a js code.Now what we do we cache the template.We have to create a plugin under the hook location cache_templates


Code:
          <plugins>
            <plugin active="1">
            <title>ZH_NRC_CACHE</title>
            <hookname>cache_templates</hookname>
            <phpcode><![CDATA[
                    
            $globaltemplates  = array_merge($globaltemplates, array('zh_nrc'));
            
            
            ]]></phpcode>
        </plugin>
</plugins>
So our template/code is cached.Now we need to look up the hook location and template where the code will be shown/executed.I will use global_start and headinclude so it will be executed on every page.(headinclude acts like the <head> tags in HTML)


Code:
              <plugin active="1">
            <title>JS_PLACEMENT</title>
            <hookname>global_start</hookname>
            <phpcode><![CDATA[        
                
            $ara = '<!-- / CSS Stylesheet -->';
$vbulletin->templatecache['headinclude'] = str_replace($ara,$ara.fetch_template('zh_nrc'),$vbulletin->templatecache['headinclude'])
;]]>
</phpcode>
        </plugin>
</plugins>
Now $ara represents a piece of code in the chosen template ['headinclude'].The rest of the code fetches the template (('zh_nrc')) and replaces $ara in headinclude with the zh_nrc template.

I suggest you pick a comment not a code for that!

Hopefully you understand it and like it
Article Tools

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Comment



Article Tools Search this Article
Search this Article:

Advanced Search
Display Modes

Posting Rules
You may not post new articles
You may not post comments
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 1
Points Per Thread: 15
Points Per Reply: 5



Links: Babyforum.com | Deejayforum.com | Hometalkcafe.com | Equineboard.com | Evboard.com


Forums Help: Forum Skin Design and Professional Services RSS Feeds



Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
Forums Help - All Rights Reserved
Article powered by GARS 2.1.6b ©2005-2006