Hi All,
I'm still working on my modification using xthreads. I am adding a new button to the postbit.
The new button template is called 'cheese_postbit_A' and looks like this:
Code:
<a href="#" title="{$lang->cheese_postbit_A}" class="cheese_postbit_A"><span>{$lang->cheese_postbit_button_A}</span></a>
|
All of those lang entries are in global.lang.php, the same as the other "button_" entries.
I have a plugin which populates the post member. It executes the following via the postbit hook:
Code:
eval("\$post['button_cheese_A'] = \"".$templates->get("cheese_postbit_A")."\";");
|
$post['button_cheese_A'] is then used in the parent 'postbit_classic' template to show the button.
The problem is: the button shows, but the text is blank. If I manually change the <span> to contain "TEST", then it shows the text "TEST". So the lang member is not being read.
What am I missing?
Cheers!
The title and the span are not the same string. Was that intentional? do either show?
(10-10-2015 09:27 PM)leefish Wrote: [ -> ]The title and the span are not the same string. Was that intentional? do either show?
No neither show. Title seems to be the tag that shows on mouseover. I just copied the way the 'quote' button works.
Code:
<a href="newreply.php?tid={$tid}&replyto={$post['pid']}" title="{$lang->postbit_quote}" class="postbit_quote"><span>{$lang->postbit_button_quote}</span></a>
|
Sorry if I still don't understand what you did.
The custom language strings also not displayed in the default postbit/_classic template?
Yes, so what I'm basically doing is trying to copy exactly how the 'quote' button is implemented, except for what that button does.
In the postbit_classic template:
Code:
{$ignore_bit}
<a name="pid{$post['pid']}" id="pid{$post['pid']}"></a>
<div class="post classic {$unapproved_shade}" style="{$post_visibility}" id="post_{$post['pid']}">
<div class="post_author scaleimages">
{$post['useravatar']}
<div class="author_information">
<strong><span class="largetext">{$post['profilelink']}</span></strong> {$post['onlinestatus']}<br />
<span class="smalltext">
{$post['usertitle']}<br />
{$post['userstars']}
{$post['groupimage']}
</span>
</div>
<div class="author_statistics">
{$post['user_details']}
</div>
</div>
<div class="post_content">
<div class="post_head">
{$post['posturl']}
{$post['icon']}
<span class="post_date">{$post['postdate']} <span class="post_edit" id="edited_by_{$post['pid']}">{$post['editedmsg']}</span></span>
{$post['subject_extra']}
</div>
<div class="post_body scaleimages" id="pid_{$post['pid']}">
{$post['customrep']}{$post['message']}
</div>
{$post['attachments']}
{$post['signature']}
<div class="post_meta" id="post_meta_{$post['pid']}">
{$post['iplogged']}{$post['ratemf']}
</div>
</div>
<div style="{$post['tyl_display']}" id="tyl_{$post['pid']}">{$post['thankyoulike_data']}</div>
<div class="post_controls">
<div class="postbit_buttons author_buttons float_left">
{$post['button_email']}{$post['button_pm']}{$post['button_www']}{$post['button_find']}{$post['button_rep']}
</div>
<div class="postbit_buttons post_management_buttons float_right">
{$post['button_tyl']}{$post['button_edit']}{$post['button_quickdelete']}{$post['button_quickrestore']}{$post['button_quote']}{$post['button_multiquote']}{$post['button_report']}{$post['button_warn']}{$post['button_purgespammer']}{$post['button_reply_pm']}{$post['button_replyall_pm']}{$post['button_forward_pm']}{$post['button_delete_pm']}
</div>
</div>
</div>
|
Example sub-template, postbit_quote :
Code:
<a href="newreply.php?tid={$tid}&replyto={$post['pid']}" title="{$lang->postbit_quote}" class="postbit_quote"><span>{$lang->postbit_button_quote}</span></a>
|
So it's using these members of $post, such as $post['button_quote']. They are in turn populated by "eval"ing templates in functions_post.php.
E.g.:
Code:
if($forum['open'] != 0 && ($thread['closed'] != 1 || is_moderator($forum['fid'], "canpostclosedthreads")) && ($thread['uid'] == $mybb->user['uid'] || $forumpermissions['canonlyreplyownthreads'] != 1))
{
eval("\$post['button_quote'] = \"".$templates->get("postbit_quote")."\";");
}
|
So I'm populating my $post['button_cheese_A'] with
Code:
eval("\$post['button_cheese_A'] = \"".$templates->get("cheese_postbit_A")."\";");
|
, in a function added with add_hook("postbit"...
That "cheese_postbit_A" template is being evaluated OK if I hard-code the text. If I try to use my lang-> variables, which are in global.lang.php just the same as the 'button_quote' ones, it just goes blank.
Did you global the $lang variable in your plugin?
OK thanks that fixed it.
I thought something 'above' the plugin would already be loading the $lang. Still getting the hang of this.