vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   How to put user profile field in Article Page (https://vborg.vbsupport.ru/showthread.php?t=270256)

killer_t 09-14-2011 01:37 PM

How to put user profile field in Article Page
 
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 :
PHP Code:

<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:

PHP Code:

$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
PHP Code:

{vb:raw fieldx


Dead Eddie 09-17-2011 01:27 PM

Hook vbcms_article_populate_end:

PHP Code:

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:

Code:

<vb:if condition="$field['field10']">
But it doesn't work :-D

Dead Eddie 09-22-2011 04:21 PM

This line:

PHP Code:

$view->fieldx $field['fieldx']; 

only makes $fieldx available to the template. So, in theory, it should be:

PHP Code:

<vb:if condition="$fieldx"

If you want more than just that one field, you can change the line above to:

PHP Code:

$view->field $field

And then your syntax would work.


All times are GMT. The time now is 05:28 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01070 seconds
  • Memory Usage 1,742KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (7)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete