View Full Version : How to put user profile field in Article Page
killer_t
09-14-2011, 01:37 PM
Hello at all. Sorry for my bad english!!
I want to get from db one userfield of article creator, and put them into the end of article in CMS.
I have try to put this code in vbcms_content_article_page :
<vb:if condition="$post['fieldx']"><dt>Descrizione</dt> <dd>{vb:raw post.fieldx}</dd></vb:if>
but i received a bad request from server.
I think missing some variable in the content.php file...
Can anyone help me please?
Thank's, Thomas.
killer_t
09-16-2011, 07:53 AM
No one can help me? Lynne even you?
Dead Eddie
09-16-2011, 10:27 AM
Use the plugin vbcms_article_populate_end:
$view->fieldx = vB::$vbulletin->userinfo['fieldx'];
Then you'll be able to use {vb:raw fieldx} in your template
killer_t
09-16-2011, 01:20 PM
Don't work,
He takes the field of the user reading the article. Not the field of the article editor.
Dead Eddie
09-17-2011, 01:22 AM
Whoops. Guess 6:30 AM is too early for me to look at code. :)
You're right. The information isn't in scope. You'll have to first query the userfield table to grab it. Same hook.
The other option would be to add it via the model to the query hooks, but in order to do that, you'll have to edit the model. I'm not seeing a quick and obvious way of doing that without doing manual file edits.
If that's the case, though, it seems silly to have that hook in there...
killer_t
09-17-2011, 10:17 AM
Now I'll explain what I need fieldx.
Each article created by each author, will have 3 adsense modules. But how to divide the advertising of each author?
Entering your adsense code in fieldx, I withdraw this code so that it is put into scritp by {vb:raw fieldx}
Dead Eddie
09-17-2011, 01:27 PM
Hook vbcms_article_populate_end:
if(self::VIEW_PAGE == $viewtype){
$field = vB::$vbulletin->db->query_first('SELECT fieldx FROM ' . TABLE_PREFIX . ' userfield AS userfield WHERE userid = ' . $view->authorid);
$view->fieldx = $field['fieldx'];
}
Then you can use {vb:raw fieldx} in the template.
killer_t
09-17-2011, 05:51 PM
Great, now works!! you have been legendary!
If you were here in Italy would offer you a beer!
Many thank's Eddie!!
killer_t
09-22-2011, 10:07 AM
I created a mod, and I thank you...
I have a question, if I wanted to know if the field exists, as I do?
I tried with this:
<vb:if condition="$field['field10']">
But it doesn't work :-D
Dead Eddie
09-22-2011, 04:21 PM
This line:
$view->fieldx = $field['fieldx'];
only makes $fieldx available to the template. So, in theory, it should be:
<vb:if condition="$fieldx">
If you want more than just that one field, you can change the line above to:
$view->field = $field;
And then your syntax would work.
killer_t
09-22-2011, 04:43 PM
Maybe I have not explained well. :-D
I want to know if fieldx of the editor is empty or not.
If it is empty then i fill it with my adsense code..
Dead Eddie
09-22-2011, 09:08 PM
Second code block above. ;)
<vb:if condition="$fieldx">
Their ad code
<vb:else />
Your ad code
</vb:if>
killer_t
09-22-2011, 09:19 PM
Thank you!!!!!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.