PDA

View Full Version : Please help me convert this code to vbb4


Easy5s.net
04-28-2012, 01:40 AM
Please help me convert this code to vbb4
Thanks a lot.


if ($vbulletin->options['on_off'] AND (THIS_SCRIPT=='showthread' OR THIS_SCRIPT=='showpost')){
$location = '$template_hook[postbit_userinfo_right_after_posts]';
$vbulletin->templatecache['postbit_legacy'] = str_replace($location,$location.fetch_template('po stbit_point'),$vbulletin->templatecache['postbit_legacy']);
$vbulletin->templatecache['postbit_first'] = str_replace($location,$location.fetch_template('po stbit_point'),$vbulletin->templatecache['postbit_first']);
$vbulletin->templatecache['postbit'] = str_replace($location,$location.fetch_template('po stbit_point'),$vbulletin->templatecache['postbit']);
}


--------------- Added 1335605202 at 1335605202 ---------------

bump.

--------------- Added 1335614520 at 1335614520 ---------------

bump.

kh99
04-28-2012, 11:46 AM
There's not enough information there. You might be able to do it by rendering the postbit_point template, but if it uses any varibles they would have to be registered to the template before rendering. Also, it's strange that a str_replace is used instead of just using the template hook, but it could be that the template couldn't be rendered at that point because some variables hadn't been set yet.

Easy5s.net
04-28-2012, 12:03 PM
Hook Location: parse_templates

Plugin PHP Code:

if ($vbulletin->options['mod_on_off'] AND (THIS_SCRIPT=='showthread' OR THIS_SCRIPT=='showpost')){
$location = '$template_hook[postbit_userinfo_right_after_posts]';
$vbulletin->templatecache['postbit_legacy'] = str_replace($location,$location.fetch_template('po stbit_credits'),$vbulletin->templatecache['postbit_legacy']);
$vbulletin->templatecache['postbit_first'] = str_replace($location,$location.fetch_template('po stbit_credits'),$vbulletin->templatecache['postbit_first']);
$vbulletin->templatecache['postbit'] = str_replace($location,$location.fetch_template('po stbit_credits'),$vbulletin->templatecache['postbit']);
}


Temp:

postbit_credits:


<if condition="$bbuserinfo[userid]">
<div class="postbit_field">
<span class="postbit_text">Credits:</span>
$post[credits] (<a href="credit_system.php?$session[sessionurl]do=maincreditsystem"><span class="postbit_text">$vbphrase[credit_tranfer]
<span></a>)
</div>
</if>


i want show temp postbit_credits in showthread

kh99
04-28-2012, 01:04 PM
Try this: First change template postbit_credits to:

<vb:if condition="$bbuserinfo[userid]">
<div class="postbit_field">
<span class="postbit_text">Credits:</span>
{vb:raw post.credits} (<a href="credit_system.php?{vb:raw session.sessionurl}do=maincreditsystem"><span class="postbit_text">{vb:rawphrase credit_tranfer}
<span></a>)
</div>
</vb:if>


Then, use hook location postbit_display_complete instead of parse_templates, and change the code to this:

if ($vbulletin->options['mod_on_off'] AND (THIS_SCRIPT=='showthread' OR THIS_SCRIPT=='showpost'))
{
$template = vB_Template::create('postbit_credits');
$template->register('post', $post);
$template_hook[postbit_userinfo_right_after_posts] .= $template->render();
unset($template);
}

Easy5s.net
04-28-2012, 01:43 PM
i'm try it but not work :(

{vb:raw post.credits} not show

kh99
04-28-2012, 02:05 PM
Hmm...I tested it and it works for me. I didn't get any actual number for credits because I don't have the rest of the mod installed, but I got "Credits: ( )" added to my postbit.

How did you make the changes, did you edit the xml file?

Easy5s.net
04-28-2012, 03:47 PM
ok because at least one field in the user table :)

and i want add {vb:raw post.credits} to header?

thank advanced.

kh99
04-28-2012, 03:55 PM
ok because at least one field in the user table :)

I don't understand.


and i want add {vb:raw post.credits} to header?

thank advanced.

I don't know how to do that. Some part of the mod is putting the value in $post[credits], but there is no $post available in the header.