PDA

View Full Version : Help with Template hook location


Power_user_EX
05-01-2012, 01:39 PM
Hi , I have created some custom profile fields (field5-7) and I have vb 4.1.11 installed on my forums.
I want to display the custom field data in the signature using templates.

1) I have made a template called "cuz_sig" which is as follows :


<vb:if condition="$post['field5']">
<dt>Field 5:</dt><dd>{vb:raw post.field5}</dd>
</vb:if>
<vb:if condition="$post['field6']">
<dt>Field6:</dt><dd>{vb:raw post.field6}</dd>
</vb:if>
<vb:if condition="$post['field7']">
<dt>Field7:</dt><dd>{vb:raw post.field7}</dd>
</vb:if>


2) Made a plugin called "custom_sig" as follows:

global $template_hook;
$newTemplate = vB_Template::create('cuz_sig');
$template_hook['postbit_signature_end'] .= $newTemplate->render();

Product : vBulletin
Hook Location : postbit_display_complete
Active : Yes

I've tried with other postbit hook locations that are available in the drop down , but still not working.

3) PROBLEM : The custom field data doesnt show up! The output is simply blank.

4) If remove the vbif condition tags then output is :

Field5:
Field6:
Field7:

5) Which template hook should I use so that it gets invoked correctly?. It seems that the code has no reference to $post[] or {vb:raw post} bcoz {vb:raw post.fieldx} is returning nothing.

Need some help asap!

-Thanks

kh99
05-01-2012, 01:44 PM
Are you sure that you didn't set the custom profile fields to be private?

Power_user_EX
05-01-2012, 02:08 PM
They aint private. My selection is

Private Field : No

kh99
05-01-2012, 02:13 PM
Edit: oh, I know - as you mentioned, you need to register $post to your template, like:

global $template_hook;
$newTemplate = vB_Template::create('cuz_sig');
$newTemplate->register('post', $post);
$template_hook['postbit_signature_end'] .= $newTemplate->render();

Power_user_EX
05-01-2012, 02:21 PM
@kh99 : Its working now :D , thanks a TON friend! I really appreciate getting your prompt help :)