Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-14-2012, 01:02 AM
imnomarty imnomarty is offline
 
Join Date: Apr 2012
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Showing an avatar in the CMS

Hello

I need to add an avatar to the articles of my site on request of the authors, but everything I have tried does not work.

I found something but I'm pretty sure it is outdated and does not work.

So please help me out.
Reply With Quote
  #2  
Old 05-14-2012, 03:03 AM
LifesGreatestGift's Avatar
LifesGreatestGift LifesGreatestGift is offline
 
Join Date: Jul 2009
Location: Louisville, KY USA
Posts: 885
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where exactly does the avatar need to show? Show us what you have tried, and what you found but is outdated.
Reply With Quote
  #3  
Old 05-14-2012, 09:05 AM
imnomarty imnomarty is offline
 
Join Date: Apr 2012
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

http://thejestersgallery.com/index.php

if you take a look at the articles, I want the avatars to show above the publish information.

I have tried this link for vBulletin.com How-To: Add User Avatar to CMS Articles (i thought this was outdated)
This one shows a nice white box but no avatar image

ive also tired this code added to and img code, with no luck
PHP Code:
<img src="{vb:raw post.avatarurl}" 
Reply With Quote
  #4  
Old 05-14-2012, 03:47 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I got it to work by using this as the plugin code:

Code:
require_once(DIR . '/includes/functions_user.php');
if(self::VIEW_PAGE == $viewtype) {
$avatarurl = fetch_avatar_url($view->authorid, true);
if ($avatarurl[0]) $avatarurl = $avatarurl[0];

/* render template and register variables */
vB_Template::preRegister('vbcms_content_article_page',array('avatarurl' => $avatarurl));
}
Reply With Quote
  #5  
Old 05-14-2012, 04:48 PM
Mr_Running Mr_Running is offline
 
Join Date: May 2010
Posts: 536
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I attempted this back in Sept 2011 and now today and the closest I get is just seeing the title Author Avatar and I have never seen the avatar image.

If anyone has a suggestion where to place the code...
Code:
<img src="{vb:raw avatarurl}" alt="Author Avatar" />
in the
Code:
vbcms_content_article_page
Reply With Quote
  #6  
Old 05-14-2012, 09:13 PM
imnomarty imnomarty is offline
 
Join Date: Apr 2012
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
I got it to work by using this as the plugin code:

Code:
require_once(DIR . '/includes/functions_user.php');
if(self::VIEW_PAGE == $viewtype) {
$avatarurl = fetch_avatar_url($view->authorid, true);
if ($avatarurl[0]) $avatarurl = $avatarurl[0];

/* render template and register variables */
vB_Template::preRegister('vbcms_content_article_page',array('avatarurl' => $avatarurl));
}
Would I change
Code:
vbcms_content_article_page
to
Code:
vbcms_content_article_preview
to use it were i want it?
Reply With Quote
  #7  
Old 05-14-2012, 09:16 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I just placed it where they spit out the authors name:
HTML Code:
			<vb:if condition="$showuser">
<img src="{vb:raw avatarurl}" alt="Author Avatar" />
				<div class="article_username_container<vb:if condition="!$showrating">_full</vb:if>">
					{vb:rawphrase by_x_nolink, {vb:raw memberaction_dropdown}}
				</div>
			</vb:if>
However, it needs some styling, so you'll have to add some CSS to move things around. (Since I don't actually use this code, I never got that far.)
Reply With Quote
  #8  
Old 05-14-2012, 09:32 PM
imnomarty imnomarty is offline
 
Join Date: Apr 2012
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm, its still not working. Do i have to enable something?
Reply With Quote
  #9  
Old 05-15-2012, 03:59 PM
lewisforlife lewisforlife is offline
 
Join Date: Mar 2012
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by imnomarty View Post
Hmm, its still not working. Do i have to enable something?
You do have to enable the plugin by going to Plugins & Products->Plugin Manager, scroll down to your plugin and enable it.


Lynne: This is working for me, now I also want to show the avatar on the CMS preview on the home page. What are the steps that I take to register the variable to work on: vbcms_content_article_preview?

Thanks.

--------------- Added [DATE]1337101605[/DATE] at [TIME]1337101605[/TIME] ---------------

Nevermind, this worked:

Code:
vB_Template::preRegister('vbcms_content_article_preview',array('avatarurl' => $avatarurl));
Now my question is, if the person has an avatar the avatar shows, if they don't have one, then text shows up that says: "Author Avatar". I do not want that text to show up, I would like to show a blank avatar picture if the user doesn't have one, sort of like what shows on the blog page if a user doesn't have an avatar. How would I accomplish this?

--------------- Added [DATE]1337102608[/DATE] at [TIME]1337102608[/TIME] ---------------

I tried this:

Code:
<vb:if {vb:raw avatarurl}!="">


<br /><img src="{vb:raw avatarurl}" alt="Author Avatar" />&nbsp;<br />

<vb:else />

<img src="images/misc/unknown.gif" />

</vb:if>
but I get "an empty or invalid if condition was found. What is wrong with this, can you help me change this so that the unkown.gif shows if a user does not have an avatar? thanks.

--------------- Added [DATE]1337102888[/DATE] at [TIME]1337102888[/TIME] ---------------

This worked, sorry I asked my question too soon:

Code:
<vb:if condition="$avatarurl != ''">


<br /><img src="{vb:raw avatarurl}" alt="Author Avatar" />&nbsp;<br />

<vb:else />

<br /><img src="images/misc/unknown.gif" />&nbsp;<br />

</vb:if>
Reply With Quote
Благодарность от:
Lynne
  #10  
Old 05-15-2012, 04:36 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You could probably also just use this instead:
Code:
<vb:if condition="$avatarurl">
Thank you for posting your working code!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:05 PM.


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.04270 seconds
  • Memory Usage 2,268KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (10)bbcode_code
  • (1)bbcode_html
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete