PDA

View Full Version : Profile field in CMS


AndrewSimm
12-04-2014, 11:38 PM
So far I created a plugin for vbulletin CMS product and parse templates hook


$cistwitter = $userinfo["field{$vbulletin->options['cistwitterprofilefield']}"];

$templater = vB_Template::create('vbcms_twitter');
$templater->register('cistwitter', $cistwitter);
$templatevalues['cistwitterarray'] = $templater->render();
vB_Template::preRegister('vbcms_content_article_pa ge', $templatevalues);


Ultimately I would just like $cistwitter to show in the vbcms_content_article_page template but I am not sure how to just do that so I put that in this vbcms_twitter template via {vb:raw cistwitter} and tried to insert that template into vbcms_content_article_page via {vb:raw cistwitterarray}

What did I miss?

kh99
12-05-2014, 08:51 AM
Did you create a template in the Style Manager named vbcms_twitter, or does it exist? If not then when you render it, it will be blank.

AndrewSimm
12-05-2014, 03:27 PM
yes I did create it and put the word "test" in it to see if I could get that word to render.

kh99
12-05-2014, 04:07 PM
OK, sorry, if I had read your first post carefully I would have seen that. Anyway, I created a plugin using hook parse_templates and this code:
$templater = vB_Template::create('vbcms_twitter');
$templater->register('cistwitter', $cistwitter);
$templatevalues['cistwitterarray'] = $templater->render();
vB_Template::preRegister('vbcms_content_article_pa ge', $templatevalues);

Then I created a template named vbcms_twitter that had only the word 'test' in it. Then I edited the vbcms_content_article_page template and just under the css line at the top I added {vb:raw cistwitterarray}. Now when I view an article I get "test" at the top, so that seems to work.

When you want to use the user's actual twitter profile field, the $userinfo won't work. You could use $vbulletin->userinfo, but that would show each user their own profile field, and I have a feeling that's not what you want. If you want the article author's twitter field, I'm not sure how to do that offhand.

AndrewSimm
12-06-2014, 04:30 AM
OK, sorry, if I had read your first post carefully I would have seen that. Anyway, I created a plugin using hook parse_templates and this code:
$templater = vB_Template::create('vbcms_twitter');
$templater->register('cistwitter', $cistwitter);
$templatevalues['cistwitterarray'] = $templater->render();
vB_Template::preRegister('vbcms_content_article_pa ge', $templatevalues);

Then I created a template named vbcms_twitter that had only the word 'test' in it. Then I edited the vbcms_content_article_page template and just under the css line at the top I added {vb:raw cistwitterarray}. Now when I view an article I get "test" at the top, so that seems to work.

When you want to use the user's actual twitter profile field, the $userinfo won't work. You could use $vbulletin->userinfo, but that would show each user their own profile field, and I have a feeling that's not what you want. If you want the article author's twitter field, I'm not sure how to do that offhand.

That does work. It looks like my issue is $userinfo is not available on the CMS, so..

$cistwitter = $userinfo["field{$vbulletin->options['cistwitterprofilefield']}"];

does not work because of userinfo. How can I make this available?

--------------- Added 1417847973 at 1417847973 ---------------

when I try the below I get my profile field6 instead of the person who posted the article

$cistwitter = $vbulletin->userinfo['field6'];

Dead Eddie
12-06-2014, 06:05 AM
<a href="https://vborg.vbsupport.ru/showthread.php?t=270256" target="_blank">https://vborg.vbsupport.ru/showthread.php?t=270256</a>

AndrewSimm
12-06-2014, 06:14 AM
https://vborg.vbsupport.ru/showthread.php?t=270256

that worked