View Full Version : Why do my var doesn't display in its template (sidebar) ?
Bastien
06-27-2015, 04:24 AM
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 :
$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 {vb:raw output}
and declared the output var at then end of forum.php
$templater->register('output',$output);
I need help plizzz :D
I think your problem is this:
$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 ...
I'm not exacly sure what you're trying to do. Where does $output get set?
Bastien
06-28-2015, 12:16 PM
//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
output template {vb:raw output} $output
Only displays : output template $output
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
$output='$output';
return $output;
and this bloc displays this template chatboxtoutcourt whichs contains :
<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&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;over flow-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 !
OK, I think what you could do is to change the output part of the template to this:
<td>{vb:raw content}</td>
Then in the bloc code, do this:
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
Thank you it works great ! :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.