Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 09-30-2014, 10:04 AM
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Jul 2009
Location: USA
Posts: 10,929
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Best thing to do is to study a mod from here that does something similar.
Reply With Quote
  #12  
Old 09-30-2014, 10:51 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try this: create a plugin using hook location forumhome_start and code like this:

Code:
ob_start();
// insert code here without <?php or ?>
$backlinks = ob_get_contents();
ob_end_clean();
vB_Template::preRegister('FORUMHOME', array('backlinks' => $backlinks));
as the comment says, insert the code you posted above, but remove the <?php from the beginning and the ?> from the end.

Next, edit the FORUMHOME template and insert {vb:raw backlinks} where you want it to appear.

Edit: if you want step by step instructions for creating a plugin, see the vbulletin manual here: http://www.vbulletin.com/en/manual/ . First select your vb version from the dropdown menu, then search for "plugin" and select "Adding or Editing a Plugin" from the results. It's pretty easy, you just have to paste the code I posted, then paste yours in at the comment and remove the <?php and ?>, then fill in the other form fields as needed (see the manual page for that). If you don't know what to put for something, you can probably leave the default.
Reply With Quote
Благодарность от:
Black Snow
  #13  
Old 10-01-2014, 09:39 AM
postcd postcd is offline
 
Join Date: Feb 2012
Posts: 319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
if you want step by step instructions for creating a plugin, see the vbulletin manual here: http://www.vbulletin.com/en/manual/ .
good post, but cant find the page where it is described, google also no help, would be good if you update your post to link to manual or better paste it into the post.
Reply With Quote
  #14  
Old 10-01-2014, 09:42 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, sorry, it's just that the manual pages show in a frame so the browser url just goes to the manual home page. But I think this will work: http://www.vbulletin.com/docs/html/main/add_plugin
Reply With Quote
  #15  
Old 10-01-2014, 10:13 AM
TheAdminMarket's Avatar
TheAdminMarket TheAdminMarket is offline
 
Join Date: Jun 2013
Location: Thessaloniki, Greece
Posts: 511
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

As most of other users said, you can't add PHP code to the template. But you can easily add templates in a PHP file. The results will be exactly what you want.

1.- Create 2 templates. One for header and one for footer:

a] For Header (is just as example):
HTML Code:
<template name="php_header" templatetype="template" date="" username="" version="">
<![CDATA[
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
<head>
    <title>Your Title</title>
    {vb:raw headinclude}
     <vb:if condition="$vboptions['storecssasfile']">
        {vb:cssfile forumhome.css, options.css, vbcms.css, widgets.css, sidebar.css, forumhome-rollup.css, usercp.css, additional.css}
    <vb:else />
        {vb:cssfile forumhome.css, options.css, vbcms.css, widgets.css, sidebar.css, forumhome-rollup.css, usercp.css, additional.css}
    </vb:if>    
    <script type="text/javascript">
    <!--
        document.write('<script type="text/javascript" src="' + yuipath + '/animation/animation-min.js?v={vb:raw vboptions.simpleversion}"></script>');
        var sidebar_align = 'right';
        var content_container_margin = parseInt('{vb:math {vb:stylevar forum_sidebar_width}+{vb:math {vb:stylevar padding}*2}}');
        var sidebar_width = parseInt('{vb:stylevar forum_sidebar_width}');
    //-->
    </script>    
    <script type="text/javascript" src="{vb:raw vboptions.bburl}/clientscript/vbulletin-sidebar.js?v={vb:raw vboptions.simpleversion}"></script> 
</head>
<body>
{vb:raw header}
{vb:raw navbar}
<div class="blockbody">
]]></template>
a] For Footer (is just as example):
HTML Code:
<template name="php_footer" templatetype="template" date="" username="" version="">
<![CDATA[
</div>
{vb:raw footer}
</body>
</html>
]]></template>
2.- In your PHP file (assuming that is a file which loads all vB functions that you need, add (again is an example):
Code:
// Header Block
$templater = vB_Template::create('php_header');
$templater->register_page_templates();
$navbits = construct_navbits(array("torget.php?" . $vbulletin->session->vars['sessionurl'] . ""=> "My Page"));
$navbar = render_navbar_template($navbits);
$templater->register('navbar', $navbar);
$header_block = $templater->render();
echo $header_block;
............Hera you can add any PHP code that you like..............
Code:
// Footer Block
$templater = vB_Template::create(php_footer');
$templater->register_page_templates();
$footer_block = $templater->render();
echo $footer_block;
Simple thing and works 100%. I build a complicated Ajax search form using this trick. And is 100% compatible with vBulletin meaning that you can use vboptions, vbphrase, datamanager etc.

Nick
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:37 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03999 seconds
  • Memory Usage 2,216KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (2)bbcode_html
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (5)post_thanks_box
  • (1)post_thanks_box_bit
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete