vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Please help urgently (https://vborg.vbsupport.ru/showthread.php?t=320598)

SilverBoy 10-24-2015 12:58 AM

Please help urgently
 
Hi dears

I used this code to show author avatar in both article page and article preview page (section page).

PHP Code:

require_once(DIR '/includes/functions_user.php');
$avatarurl fetch_avatar_url($this->content->getUserId());
if (
$avatarurl[0]) {
$avatarurl $avatarurl[0];
}
/* render template and register variables */
vB_Template::preRegister('vbcms_content_article_page',array('avatarurl' => $avatarurl));
vB_Template::preRegister('vbcms_content_article_preview',array('avatarurl' => $avatarurl)); 

I use the hook vbcms_article_populate-end and it works great in article page, but it show the same avatar for all authors in section page, any suggestion to make it works right in section page?

this is the code I use in the templates.
HTML Code:

<img class="cms_article_preview_image" src="{vb:raw avatarurl}" alt="{vb:raw $authorname}">

Dead Eddie 10-24-2015 08:55 AM

Haven't tested this lately, but it worked last time I did it:

PHP Code:

require_once(DIR '/includes/functions_user.php');
$avatarurl fetch_avatar_url($view->authoridtrue);
if (
$avatarurl[0]) {
     
$avatarurl $avatarurl[0];
}
/* render template and register variables */

$view->avatarurl $avatarurl


SilverBoy 10-24-2015 11:46 AM

Thank you for your help Eddie.

But your code looks like the same as I used, btw what is the hook that I must insert this code using it?

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

Thank you Eddie, It works great :)


All times are GMT. The time now is 10:10 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.01095 seconds
  • Memory Usage 1,721KB
  • 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_html_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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