k2 user avatar in minik2 simple template

I use minik2 sub-template simple.

I need to add in the visualization of single item uploaded by k2: his avatar.

I tried calling the variable of the avatar in the file default.php of simple template but does not work.

does anyone know how to tell?

thanks
11 years 11 months ago #1 by david

Please Log in or Create an account to join the conversation.

Hi DAvid

Can you tell us how did you manage to call the avatar inside default.php?
11 years 10 months ago #2 by erwinschro

Please Log in or Create an account to join the conversation.

Hi enwinschro,

my call in default.php of simple template is:

<?php if ($params->get('itemAuthorAvatar')): ?>
<div>
<?php echo $item->authorAvatar = K2HelperUtilities::getAvatar($author->id, $author->email, $componentParams->get('userImageWidth')); ?>
</div>
<?php } ?>

result: page white

thanks
11 years 10 months ago #3 by david

Please Log in or Create an account to join the conversation.

Mmm... those such lines should be in the helper file but in fact we already have those lines in helper.php so what you should do is to put these lines to call the avatar in default.php
<a class="k2Avatar moduleItemAuthorAvatar" rel="author" href="<?php echo $item->authorLink; ?>">
  <img src="<?php echo $item->authorAvatar; ?>" alt="<?php echo K2HelperUtilities::cleanHtml($item->author); ?>" style="width:20px;height:auto;" />
</a>

but as you can see in the helper.php there are code lines for checking if the author should be display or not (about line 507-541)
//Author
if ($params->get('itemAuthor')) 
{
...
}

but the problem then is in minik2 we have stripped down that option in the xml file, so you need to add that option manually in the xml file so then you have an option in the module parameter.
Add the following somewhere in mod_minik2.xml file
<field name="showItemAuthor" type="radio" default="1" label="Show Author" description="tto show item Author or not">
	<option value="1">show</option>
	<option value="0">hide</option>
</field>
<field name="itemAuthorAvatar" type="radio" default="1" label="Show Author Avatar" description="to show author avatar or not, the above show Item Author should be set to Yes too">
	<option value="1">show</option>
	<option value="0">hide</option>
</field>

Have a try then...
11 years 10 months ago #4 by erwinschro

Please Log in or Create an account to join the conversation.

Hi,

I tried this way but it returns blank page

in defaul.php

<a class = "k2Avatar moduleItemAuthorAvatar" rel = "author" href = "/ <? php echo $ item-> authorLink;?>">
<img src = "/ <? php echo $ item-> authorAvatar;?>" alt = "<? php echo K2HelperUtilities :: cleanHtml ($ item-> author);?>" style = "width: 190px; height: auto; "/>
</ a>

in helper.php

/ / Author name
if ($ params-> get ('itemAuthor'))
{
$ item-> author = $ model-> getItemAuthor ($ item-> author);
}

in mod_minik2.xml

<field name="showItemAuthor" type="radio" default="1" label="Show Author" description="tto show item or Author not">
<option value="0"> hide </ option>
<option value="1"> show </ option>
</ field>
<field name="itemAuthorAvatar" type="radio" default="1" label="Show Author Avatar" description="to show author avatar or not, above show the Item Author Should be Set to Yes too">
<option value="0"> hide </ option>
<option value="1"> show </ option>
</ field>

where am I wrong?
11 years 10 months ago #5 by david

Please Log in or Create an account to join the conversation.

So sorry my mistake...
These xml
<field name="showItemAuthor" type="radio" default="1" label="Show Author" description="tto show item Author or not">
    <option value="1">show</option>
    <option value="0">hide</option>
</field>

should be
<field name="itemAuthor" type="radio" default="1" label="Show Author" description="tto show item Author or not">
    <option value="1">show</option>
    <option value="0">hide</option>
</field>

Let me know then...
11 years 10 months ago #6 by erwinschro

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum