vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Showing an avatar in the CMS (https://vborg.vbsupport.ru/showthread.php?t=282874)

imnomarty 05-14-2012 01:02 AM

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.

LifesGreatestGift 05-14-2012 03:03 AM

Where exactly does the avatar need to show? Show us what you have tried, and what you found but is outdated.

imnomarty 05-14-2012 09:05 AM

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}" 


Lynne 05-14-2012 03:47 PM

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));
}


Mr_Running 05-14-2012 04:48 PM

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

imnomarty 05-14-2012 09:13 PM

Quote:

Originally Posted by Lynne (Post 2329329)
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?

Lynne 05-14-2012 09:16 PM

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.)

imnomarty 05-14-2012 09:32 PM

Hmm, its still not working. Do i have to enable something?

lewisforlife 05-15-2012 03:59 PM

Quote:

Originally Posted by imnomarty (Post 2329417)
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>


Lynne 05-15-2012 04:36 PM

You could probably also just use this instead:
Code:

<vb:if condition="$avatarurl">
Thank you for posting your working code! :)

imnomarty 05-15-2012 09:48 PM

It still does not work and I have no idea why. I'm not sure what I'm doing wrong. I tried the codes you guys gave, but still no luck.

Although thanks for all the help, this is a really great community for good software.

Lynne 05-16-2012 04:51 PM

You need to post a link to your page where it is not working and then post *exactly* (copy/paste it) what you have done and please use code tags when you do so.

imnomarty 05-16-2012 05:34 PM

Quote:

Originally Posted by Lynne (Post 2329937)
You need to post a link to your page where it is not working and then post *exactly* (copy/paste it) what you have done and please use code tags when you do so.

Okay so here is the page. Front page of my site. http://thejestersgallery.com/content.php

So what i have done so far is follow the instructions on the site to make the plugin and instead of using his code I used yours. And since I want this to go in preview I used lewisforlife code to change it.
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_preview',array('avatarurl' => $avatarurl));
}

Then I put the img code into preview and all i get is a white box

Code:

<vb:if condition="$showuser OR $showpublishdate OR ($showupdated AND $lastupdated) OR ($viewcount AND $showviewcount) OR ($showrating AND $rating!='')">
        <div class="cms_article_username cms_publish_column">
<img src="{vb:raw avatarurl}" alt="Author Avatar" />
                <vb:if condition="$showuser">
                        {vb:rawphrase by_x_nolink, {vb:raw memberaction_dropdown}}
                </vb:if>


Lynne 05-16-2012 08:56 PM

As it says in the original article, you cannot have the condition (if(self::VIEW_PAGE == $viewtype)) around the code if you need it for the preview page.

imnomarty 05-16-2012 10:37 PM

Thank You this is wonderful

JustAskJulie 08-26-2013 05:39 PM

I used the coding below and I'm getting nothing showing up. My site (adult related)

Quote:

Originally Posted by Lynne (Post 2329329)
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));
}


Quote:

Originally Posted by Lynne (Post 2329413)
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.)


Lynne 08-26-2013 08:41 PM

Try removing the condition around that template code and see if it shows up. Also, you are editing the style that you are using, right?

JustAskJulie 08-30-2013 07:51 PM

Quote:

Originally Posted by Lynne (Post 2441296)
Try removing the condition around that template code and see if it shows up. Also, you are editing the style that you are using, right?

So, change
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>

to

Code:

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

?

Still doesn't give me an avatar :(

Lynne 08-31-2013 02:37 AM

If it still doesn't give you an avatar, then you either have it inside another condition that isn't allowing it to display or you are editing the wrong template or wrong style template.

JustAskJulie 09-04-2013 03:10 PM

I'm in the vbcms_content_article_page template.

Going to the top of the code, this is what it has. Am I putting the Author avatar stuff in the wrong place?
Code:

{vb:raw css}

<div class="article_width" id="article_content">
        <div class="title">

                <h1 class="article_title cms_article_title"><span>{vb:raw title}</span>
                        <vb:if condition="$can_edit">
                                <a href="{vb:raw edit_url}" class="edit"><img class="editimage" src="{vb:stylevar imgdir_cms}/edit_small.png" alt="{vb:rawphrase edit}" /></a>
                        </vb:if>
                </h1>
        </div>
        <div class="article_author_date_comment_container">
                <vb:comment>
                                             
<img src="{vb:raw avatarurl}" alt="Author Avatar" />
                                <div>
                                        <a href="{vb:link member, {vb:raw userid}}"><img src="{vb:raw vboptions.bburl}/image.php?{vb:raw session.sessionurl}u={vb:raw userid}&amp;type=profile" alt="" class="post_avatar" /></a>
                                </div>
                     
                </vb:comment>


Lynne 09-04-2013 04:02 PM

It is between <vb:comment> tags which means it won't show. You need to remove those comment tags.

JustAskJulie 09-09-2013 06:07 PM

That fixed it. Thank you for being patient and helpful!

One more question, how would I edit it so that the image aligns to the left of the the author name, date, etc ?

JustAskJulie 09-18-2013 09:02 PM

Can you tell me what I need to edit in the CSS so that the avatar aligns up to the left of the username and publishing info.

Lynne 09-18-2013 10:53 PM

I'd need to see the page and view it using firebug to be able to write some CSS.

JustAskJulie 09-19-2013 07:32 PM

<a href="http://www.swingersboard.com/forums/content/1159-don-t-wallflower-pt-4-approach.html" target="_blank">http://www.swingersboard.com/forums/...-approach.html</a> (*this site contains adult content)

Lynne 09-19-2013 08:46 PM

You are going to have to rewrite parts of that template to do that. You can't just add some simple CSS to make it how you want. You'd want to throw the image into the "class="fullwidth"" div and float it left. After that you should be able to play with the other CSS to get things to lineup how you want.


All times are GMT. The time now is 02:17 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.01211 seconds
  • Memory Usage 1,817KB
  • 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
  • (16)bbcode_code_printable
  • (2)bbcode_html_printable
  • (1)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (26)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete