0

On a page I´m working on, users can submit comments on blog posts and their avatars are showed. Althought I can retrieve alle the information about the comment author, when I query for its avatar, the query allways return empty, even if all information is there.

The example link is: http://www.natives.de/blogeintrag/items/59.html

and the template code is as follows:

<?php
$this->import('Database');
$authoravatar = $this->Database->prepare("SELECT xt_avatar FROM tl_user WHERE email=?")
  ->execute($this->email);
//var_dump($authoravatar);
?>

<div class="comment_default<?php echo $this->class; ?>" id="<?php echo $this->id; ?>">
<h3 class="info"><strong><?php if ($this->website): ?><a href="<?php echo $this->website; ?>" rel="nofollow" target="_blank"><?php endif; ?><?php echo $this->name; ?><?php if ($this->website): ?></a><?php endif; ?></strong> <time datetime="<?php echo $this->datetime; ?>" class="date"><?php echo $this->date; ?></time></h3>


<div class="authoravatar">
{{image::<?php echo $authoravatar->xt_avatar =='' ? 'tl_files/theme/image/notauser.png' : $authoravatar->xt_avatar; ?>?width=102&height=87&alt=<?php echo $this->name; ?>}}
</div>

<div class="comment">
<?php echo $this->comment; ?> 
</div>
<?php if ($this->addReply): ?>
<div class="reply">
<p class="info"><?php echo $this->rby; ?> <?php echo $this->authorName; ?></p>
<div class="comment">
<?php echo $this->reply; ?> 
</div>
</div>
<?php endif; ?>
</div>

I tried everything but cant find how to return the avatars. Any Though? Any help is more than appreciated!

2
  • You should not use plain mysql commands within templates - this is a perfect example for bad coding.
    – mate64
    Commented Jan 15, 2014 at 20:58
  • I know it´s an awful practice, but the site I got has sql queries on every template… change that is out of scope
    – brubs
    Commented Jan 16, 2014 at 12:02

0

Browse other questions tagged or ask your own question.