skateme
02-19-2012, 08:41 PM
I want to apply the "substr()" function to one of the custom profile fields. I will display the modified field in my postbit. I am trying to display the last two characters of the college graduation year in the postbit as follows: College 'YR.
I know I have to create a plugin calling in the field4 (college graduation year) variable, apply the substr() function, and create a new variable to echo in my template.
My plugin is as follows:
$vbulletin->profilefieldname[field4] = $collgrad;
$collgradtruncated = substr($collgrad, 2);
$mytemplater = vB_Template::create('mytemplate');
$mytemplater->register('my_str', $my_str);
$myrendervar = $mytemplater->render();
vB_Template::preRegister('postbit_legacy',array('m yrendervar ' => $myrendervar));
This is the relevant code in the postbit_legacy:
<vb:if condition="$post['field4']"><dt>{vb:rawphrase college}</dt> <dd>{vb:raw post.field4} '{vb:raw collgradtruncated}</dd></vb:if>
Obviously, it does not work. I was hoping someone could tell me the following:
1) how to call profile field values in my plugin
2) setup a variable in my plugin that I can use in my template
3) tell me what is wrong with my code
4) fix the code for me
Thank you so much!
I know I have to create a plugin calling in the field4 (college graduation year) variable, apply the substr() function, and create a new variable to echo in my template.
My plugin is as follows:
$vbulletin->profilefieldname[field4] = $collgrad;
$collgradtruncated = substr($collgrad, 2);
$mytemplater = vB_Template::create('mytemplate');
$mytemplater->register('my_str', $my_str);
$myrendervar = $mytemplater->render();
vB_Template::preRegister('postbit_legacy',array('m yrendervar ' => $myrendervar));
This is the relevant code in the postbit_legacy:
<vb:if condition="$post['field4']"><dt>{vb:rawphrase college}</dt> <dd>{vb:raw post.field4} '{vb:raw collgradtruncated}</dd></vb:if>
Obviously, it does not work. I was hoping someone could tell me the following:
1) how to call profile field values in my plugin
2) setup a variable in my plugin that I can use in my template
3) tell me what is wrong with my code
4) fix the code for me
Thank you so much!