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

Reply
 
Thread Tools Display Modes
  #1  
Old 08-28-2012, 09:19 PM
ChiNa ChiNa is offline
 
Join Date: Jul 2012
Posts: 457
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default XML - Failing to use $replace on vB4?

Hi everyone, I am slowly moving to vB 4.x and I dont know much about how to use the replace and find variable, by making an XML PRODUCT... And I have only learned on here is to REPLACE, and only about and for vB3.8 versions.

I have done a few products using the replace for vB3.8 with help of an amazing member named "Scanu". And today I used the code he helped me with for vB4.x, It did the replace perfectly and added my code but after refreshing my forum,

But I got this error below:

Code:
Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: my_bar in [path]/includes/functions.php on line 4734

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in [path]/includes/class_bootstrap.php(1419) : eval()'d code on line 3
::::::::::::::::::::::::::::::::::

Below is the replace code i used on my vB3.8 which gave me the error on a vB 4.2 version, but it did replace, and it did work!

Code:
        $replace = '<div class="above_body">';
      $vbulletin->templatecache['header'] = str_replace('<div class="above_body">',fetch_template('my_bar'),$vbulletin->templatecache['header']); 
::::::::::::::::::::::::::::::::::

And below is yet another code I use in my xml products, Now this code does the Installing, but nothing showes up.

Code:
<template name="My_Bar" templatetype="template" date="1516171819" username="ChiNaMan" version="1.0"><![CDATA[        
<style type="text/css">
#SideBar li{
margin:9px 0 0 0;
line-height:0
}
#SideBar li:first-child{
margin-top:0
}
#SideBar a{
display:block;
width:24px;
}
#SideBar a span{
position:absolute;
top:-999em
}
</style>
<div class="above_body">
]]></template>
    </templates>
    <plugins>
        <plugin active="1" executionorder="5">
            <title>My Bar</title>
            <hookname>global_start</hookname>
            <phpcode><![CDATA[if ($vbulletin->options['my_bar_on'])
        {
      $replace = '<div class="above_body">';
     $vbulletin->templatecache['header'] = str_replace($replace,$replace.'<div class="above_body">',$vbulletin->templatecache['header']);
            }
        ]]></phpcode>

What am I doing wrong.. If someone could please explain short how to ADD a simple code inside a vB4.x template, or simply tell how to use the $replace which I did. So the vB3.8 code did work, but with the FETCH error, and the code below did the Install, but notthing is showing up!

My modification is a SIDEBAR with only 1 Button that should show up on my frontpage, RIGHT SIDE.. I think its about 15 to 20 lines of CSS and HTML!Thank you very much in advance,,

And a big thanks to Scanu for all his help this week!
Reply With Quote
  #2  
Old 08-29-2012, 10:10 PM
Scanu's Avatar
Scanu Scanu is offline
 
Join Date: Nov 2010
Posts: 829
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is because in vb4 you can't use fetch_template to use a template you must use oop. Here's a great article about this: https://vborg.vbsupport.ru/showthread.php?t=228078
Btw Try this code

PHP Code:
$templater vB_Template::create('my_bar');
      
$vbulletin->templatecache['header'] = str_replace('<div class="above_body">',$templater->render,$vbulletin->templatecache['header']); 
And about this error
Quote:
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in [path]/includes/class_bootstrap.php(1419) : eval()'d code on line 3
Can you show me the code you usef to cache templates?
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 07:41 PM.


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.03525 seconds
  • Memory Usage 2,173KB
  • 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
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete