vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Why do my var doesn't display in its template (sidebar) ? (https://vborg.vbsupport.ru/showthread.php?t=319247)

Bastien 06-27-2015 04:24 AM

Why do my var doesn't display in its template (sidebar) ?
 
1 Attachment(s)
I'm trying to integrate my chatbox to the sidebar on the forum

My bloc forum calls my template (which displays well
Chatbox [Archives]
output_template : $output)

my bloc content is :
Code:

$output='$output';
return $output;

and calls my template

If I put an echo $output in the forum.php file, it displays well at the top of the forum
But not in my template (whereas I put
Code:

{vb:raw output}
and declared the output var at then end of forum.php
Code:

$templater->register('output',$output);
I need help plizzz :D

kh99 06-27-2015 10:50 AM

I think your problem is this:
PHP Code:

$output='$output'

Since variables aren't evaluated in single quotes, you're setting the string to a literal $output. I don't think you need that line at all, just use return $output;

Bastien 06-28-2015 09:02 AM

If I don t add it, the bloc disent display at all I think ...

kh99 06-28-2015 10:06 AM

I'm not exacly sure what you're trying to do. Where does $output get set?

Bastien 06-28-2015 12:16 PM

Code:

//affichage widget dans forum
// CHATBOX
// SIDE BOX POUR CHATBOX
        global $show;
        global $output;
       
        // Core
        require_once(DIR . '/mgc_cb_evo/classes/class_core.php');   
    $MGCCbEvoCore = new MGCCbEvo_core(vB::$vbulletin,vB::$vbulletin->userinfo['permissions']);
    $MGCCbEvoCore->unserialize_user_params();
   
    if ($MGCCbEvoCore->show_chatbox() && $MGCCbEvoCore->evo_permissions->can_view())
    {
                $show['mgc_cb_evo'] = 1;
               
                // Construct chatbox display
                require_once(DIR . '/mgc_cb_evo/classes/class_display.php');
                require_once(DIR . '/mgc_cb_evo/addons/cms/classes/class_display.php');
                $MGCCbEvoDisplay = new CMS_MGCCbEvo_display(vB::$vbulletin,$MGCCbEvoCore);

                // Display construction
                $output = $MGCCbEvoDisplay->construct_display(); 
//echo "output_fichier : $output";       
        }
        else
        {
                $show['mgc_cb_evo'] = 0;       
       
        }

The commented line //echo "output_fichier : $output"; if uncommented, displays the chatbox at the top of the page in my SC

whereas in my template, this

Code:

output template {vb:raw output} $output
Only displays : output template $output

kh99 06-28-2015 01:06 PM

The code you posted above, where so you have that? Is it in a plugin, in the forum block, or in forum.php?

You mentioned you template. What template is it, and where is the code that renders it? You said you added a call to $templater->register at the end of forum.php? Is hat where your template rendering code is, or are you adding it to the line for registering to FORUMHOME?

Bastien 06-28-2015 01:54 PM

This code is my forum.php

I m trying to do a "plugin" to add the chatbox in the side bar !

The content of my bloc is

Code:

$output='$output';
return $output;

and this bloc displays this template chatboxtoutcourt whichs contains :

Code:

<li>
    <div class="block smaller">
        <div class="blocksubhead">
            <a class="collapse" id="collapse_block_html_mgccbevo" href="{vb:raw relpath}#top"><img alt="" src="{vb:stylevar imgdir_button}/collapse_40b.png" id="collapseimg_html_mgccbevo"/></a>
            <span class="blocktitle">
                    Chatbox [<a href="{vb:raw vboptions.bburl}/{vb:raw vboptions.mgc_cb_evo_filename}.php?{vb:raw session.sessionurl}do=view_archives&amp;page=1">{vb:phrase mgc_cb_evo_archives}</a>]
            </span>
        </div>
        <div id="block_html_mgccbevo" class="blockbody floatcontainer">
            <div class="blockrow" align="center">
                                <div style="width:100%; height: {vb:raw vboptions.mgc_cb_evo_notifs_sidebar_height}px;overflow-y: auto;border: none; z-index: 1;" id="schats_container">
                                        <table width="100%" align="{vb:stylevar left}" cellspacing="0" cellpadding="0">
                                                <tbody id="schats">
                                                        <tr>
                                                                <td>output template {vb:raw output} $output</td>
                                                          </tr>
                                                  </tbody>                                 
                                        </table>                 
                                </div>                               
                        </div>
        </div>
    </div>
    <div class="underblock"></div>
</li>

But this fu**in' var doesn't display in my template, whereas with the echo it does !

kh99 06-28-2015 02:24 PM

OK, I think what you could do is to change the output part of the template to this:
Code:

<td>{vb:raw content}</td>
Then in the bloc code, do this:

PHP Code:

global $output;
return 
$output

(although it might be better to use a variable other than $output). Because the sidebar code will automatically take what is returned and register it to 'content' in the block template. You just need to make sure that $output is set before the sidebar is rendered.

You could also put all the code in the bloc content area, and return $output at the end, but maybe you're not doing that because you need $show['mgc_cb_evo'] set before it gets to the block code?

Bastien 06-29-2015 10:05 AM

1 Attachment(s)
Thank you it works great ! :)


All times are GMT. The time now is 12:27 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.01072 seconds
  • Memory Usage 1,742KB
  • 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
  • (8)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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