vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   XML - Failing to use $replace on vB4? (https://vborg.vbsupport.ru/showthread.php?t=287216)

ChiNa 08-28-2012 09:19 PM

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!

Scanu 08-29-2012 10:10 PM

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?


All times are GMT. The time now is 08:20 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.01101 seconds
  • Memory Usage 1,725KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete