gkAvatar for k2 Categories Listing

Rate this topic: Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.1.00 out of 6 based on 1 vote(s)
GK User
Wed Oct 22, 2014 10:04 am
Reply with quote
Report this post
Hello,

We would like to add the gkAvatar for the authors in a custom categories listing template display.

Please see the picture in attachment for a more detailed explanation.

Regards.
User avatar
Platinum Boarder

teitbite
Fri Oct 24, 2014 5:11 pm
Reply with quote
Report this post
Hi

Please tell me the url to the page You have made this screen on.
User avatar
Moderator

GK User
Fri Oct 24, 2014 5:17 pm
Reply with quote
Report this post
There you go. You will need to login.

http://miggg.quebecguitare.com/suivi-en ... itare.html

I've send userinfo to your inbox.

Regards
User avatar
Platinum Boarder

teitbite
Sat Oct 25, 2014 11:10 am
Reply with quote
Report this post
Hi

Please edit /html/com_k2/templates/default/category_item.php

And put this code over line 17:

Code: Select all
<img src="<?php echo $this->item->author->avatar; ?>" style="float:left;" />
User avatar
Moderator

GK User
Sat Oct 25, 2014 12:00 pm
Reply with quote
Report this post
Hello,

I tried adding the code but it has no effect on the category_item page. Cleared the cache and checked in.

Line 17 looks in between 2 blocks of code. Are you sure that is what you meant?
https://github.com/joomlaworks/k2/blob/ ... y_item.php


Regards.
User avatar
Platinum Boarder

teitbite
Mon Oct 27, 2014 1:06 pm
Reply with quote
Report this post
Hi

Is the link a correct project folder ??? If yes than components/com_k2/templates/default/category_item.php is a wrong file, You need to change template's override for this file which is in templates/gk_john_s/html/com_k2/templates/default/category_item.php
User avatar
Moderator

GK User
Thu Oct 30, 2014 6:46 am
Reply with quote
Report this post
Hello, OK now it works.

However I want to do it only for one particular category. Is this called a template override?

Could you give me rough guidelines on how to affect this to only one category?
I know it has to do with associating a category template with one category, but besides that I am clueless.

EDIT: OK I found my answer here https://www.gavick.com/blog/power-custom-k2-templates/

Thank you,
Regards.
User avatar
Platinum Boarder

GK User
Thu Oct 30, 2014 6:57 am
Reply with quote
Report this post
Solved. Thank you Teitbite!

Code: Select all
          <div class="itemBlock">
          <img src="<?php echo $this->item->author->avatar; ?>" style="float:left; padding-right:10px;" />
                    <?php if($this->item->params->get('catItemImage') && !empty($this->item->image)): ?>
                    <div class="itemImageBlock"> <a class="itemImage" href="<?php echo $this->item->link; ?>" title="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>">
User avatar
Platinum Boarder

teitbite
Fri Oct 31, 2014 11:11 am
Reply with quote
Report this post
Hi

Great to hear that, but I'm afraid I do not understand how You did this :D I mean how You have separated this to a one category only. Have You created a new k2 template and attached to this one categoru only in k2 category settings or used a condition in default layout like:

Code: Select all
<?php if($this->item->category->id == '28')?>


just an example for anyone who may be looking for a similar solution.
User avatar
Moderator

GK User
Fri Oct 31, 2014 11:50 am
Reply with quote
Report this post
Ive created a new k2 template and attached to this one category only in k2 category settings on the backend.

Is that the way it should be done?


teitbite wrote:Hi

Great to hear that, but I'm afraid I do not understand how You did this :D I mean how You have separated this to a one category only. Have You created a new k2 template and attached to this one categoru only in k2 category settings or used a condition in default layout like:

Code: Select all
<?php if($this->item->category->id == '28')?>


just an example for anyone who may be looking for a similar solution.
User avatar
Platinum Boarder

teitbite
Mon Nov 03, 2014 10:08 am
Reply with quote
Report this post
Hi

I believe so. Yes that's one way of doing that. Other can be the condition I presented already inside an override of a default template.
User avatar
Moderator

GK User
Wed Nov 05, 2014 8:29 am
Reply with quote
Report this post
Hi teitbite,

I experienced a problem when trying to use the new template I created to show up the avatar on the left of each item in the category item listing.

By isolating the problem, I notice that with the following code, "Author" must be set to "Show" in the "category item view options in category listings" in the K2 category edit.

Code: Select all
<img src="<?php echo $this->item->author->avatar; ?>" style="float:left; padding-right:10px;" />


This means that the avatar cannot be shown without the "Author" field. This is quite redundant in my opinion. Is there anyway to bypass that "Show/Hide" attribute and just retrieve the K2 author avatar without passing by this condition?

Regards,
User avatar
Platinum Boarder

GK User
Wed Nov 05, 2014 8:30 am
Reply with quote
Report this post
...or maybe the other way around: keeping the "Author" field to "Show" but hiding it with a template override?
User avatar
Platinum Boarder

teitbite
Thu Nov 06, 2014 12:16 pm
Reply with quote
Report this post
Hi

K2 made it the way that only when informations about user are being pulled out from database than an url to avatar is provided.

Please make my access work again, so I'll see the code needed to hide author name with css.
User avatar
Moderator

teitbite
Sun Nov 09, 2014 9:39 am
Reply with quote
Report this post
Please add this code to override.css and make sure override is enabled in template settings.

Code: Select all
li.itemAuthor { display: none; }
User avatar
Moderator

GK User
Sun Nov 09, 2014 3:54 pm
Reply with quote
Report this post
I would like to do this only for one custom category template. It's a category item layout in /templates/gk_john_s/html/com_k2/templates/suivi_k2.

Is there anyway to put this condition in the override.css?

Regards
User avatar
Platinum Boarder

teitbite
Mon Nov 10, 2014 5:00 pm
Reply with quote
Report this post
Hi

On top of /templates/gk_john_s/html/com_k2/templates/suivi_k2/category.php You will find this code:

Code: Select all
<div id="k2Container" class="itemListView<?php if($this->params->get('pageclass_sfx')) echo ' '.$this->params->get('pageclass_sfx'); ?>">


replace it with:

Code: Select all
<div id="k2Container" class="suivi itemListView<?php if($this->params->get('pageclass_sfx')) echo ' '.$this->params->get('pageclass_sfx'); ?>">


than the CSS code will look like this:

Code: Select all
.suivi li.itemAuthor { display: none; }
User avatar
Moderator

GK User
Wed Nov 12, 2014 11:56 am
Reply with quote
Report this post
Thank you Teitbite. Great job! :)
User avatar
Platinum Boarder

GK User
Fri Nov 14, 2014 7:39 am
Reply with quote
Report this post
Hi,

We would like to make the avatar clickable with a link that directs and open the item like a "Read-more", only for this custom template "Suivi_K2".

Thank you,
Best Regards
User avatar
Platinum Boarder

GK User
Fri Nov 14, 2014 9:31 am
Reply with quote
Report this post
Hi,

We would like to be able to show the K2 avatar in the category item listing layout when there is no picture associated with the K2 item.

Code: Select all
Check if K2 item has picture
   show K2 picture
Else
  Show K2 Avatar


Regards
User avatar
Platinum Boarder

teitbite
Sat Nov 15, 2014 12:05 pm
Reply with quote
Report this post
Hi

Ok, but I will need an access to ftp. It's starting to be too complicated to just guess. I need to try how it works first.
User avatar
Moderator

teitbite
Sun Nov 16, 2014 11:00 am
Reply with quote
Report this post
Hi

I had a lot of problems to do that since it's not possible to add an image to K2 item becuase extra fields validation always say they are required even if filled in.

So I used a different method and added this on top of /category_item.php file

Code: Select all
     <?php if(empty($this->item->image): ?>
       <?php $this->item->image = $this->item->author->avatar; ?>
     <?php endif; ?>


this will work differently than before. Now a regular item image will be shown, so it has to be enabled in category settings, but this image will be replaced with avatar if no item image was provided.
User avatar
Moderator

GK User
Mon Nov 17, 2014 7:42 am
Reply with quote
Report this post
Perfect it works great! Sorry for all the problem you had to make the mod, but thank you for doing that on your weekend.

As requested, can we have that avatar clickable as a replacement for a "Read-more" or just like a category_item link would do?

I have a last thing I needed to sincronize with this modification, is the gkTabsWrap vertical module. Normally the module will show the picture associated with the item. Can it do the same if there is not picture available in the item and show the Avatar instead?

Much appreciated,
Alex
User avatar
Platinum Boarder

teitbite
Tue Nov 18, 2014 11:16 am
Reply with quote
Report this post
Hi

I'm afraid I do not understand about this gkTabsWrap. Tabs are only preparing module positions which can be changed on table name click, so whatever related with Your problem must be about modules placed in this tabs.

Ok. I've just been looking into Your ftp to add a link to image, but I cannot even find the code I've entered there yesterday ;/
Which project is this related with again ? I can see K2 template style "suivi_k2". Anyway this shoud go around image to make it link to an article:

Code: Select all
<a href="<?php echo $this->item->link; ?>"> </a>
User avatar
Moderator

GK User
Tue Nov 18, 2014 11:25 am
Reply with quote
Report this post
Hi

Actually I am not sure where you've put the code yesterday either. It was for the category_item layout; replacing a non-existant image for the author avatar.

Yes the project is "Suivi_K2"

As for the new problem, I am talking about the gkTabs thumbnail. This is a module in the position sidebar to present tabs, either recent articles or a category. Items without images won't show any thumbnails. So in the same spectrum it would be nice to have the Author Avatar to fill the empty space in the case of an item without image.
User avatar
Platinum Boarder

GK User
Tue Nov 18, 2014 11:43 am
Reply with quote
Report this post
Is this the right file in attachement?

I have other provider that has the FTP access right now, maybe they overwrited it.

This is a backup in attachment.

I see as well that the modification (avatar) is not showing on the layout today.


Regards
User avatar
Platinum Boarder

GK User
Tue Nov 18, 2014 11:56 am
Reply with quote
Report this post
I am not too sure where to put the Link Image code:

The link code:
Code: Select all
<a href="<?php echo $this->item->link; ?>"> </a>



Your Code:
Code: Select all
?>
<article class="itemView group<?php echo ucfirst($this->item->itemGroup); ?><?php echo ($this->item->featured) ? ' itemIsFeatured' : ''; ?><?php if($this->item->params->get('pageclass_sfx')) echo ' '.$this->item->params->get('pageclass_sfx'); ?><?php if($this->item->params->get('catItemImage') && !empty($this->item->image)): echo ' has-image'; endif; ?>"> <?php echo $this->item->event->BeforeDisplay; ?> <?php echo $this->item->event->K2BeforeDisplay; ?>
          <div class="itemBlock">
          <img src="<?php echo $this->item->author->avatar; ?>" style="float:left; padding-right:10px;" />
                    <?php if($this->item->params->get('catItemImage') && !empty($this->item->image)): ?>
                    <div class="itemImageBlock"> <a class="itemImage" href="<?php echo $this->item->link; ?>" title="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>">
                              <img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" style="width:<?php echo $this->item->imageWidth; ?>px; height:auto;" />
                              </a> </div>
                    <?php endif; ?>

User avatar
Platinum Boarder

GK User
Tue Nov 18, 2014 12:00 pm
Reply with quote
Report this post
There seems to be a problem with the last code to replace image with avatar if non-existant.

There is an error:

Code: Select all
/<br />
<b>Notice</b>:  Undefined property: stdClass::$author in <b>/home2/guitar88/public_html/_mig2/templates/gk_john_s/html/com_k2/templates/suivi_k2/category_item.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Trying to get property of non-object in <b>/home2/guitar88/public_html/_mig2/templates/gk_john_s/html/com_k2/templates/suivi_k2/category_item.php</b> on line <b>17</b><br />
User avatar
Platinum Boarder

teitbite
Wed Nov 19, 2014 12:05 pm
Reply with quote
Report this post
Hi

Yes file was replaced and now it's all wrong with the previous solution which I've replaced when You had some additional requests.

I fixed what I could so please check.

About the module image. I'm not sure if I'll be able to help if module is not picking avatars on it's own. This may be too big job this time. But first please tell me exactly which module You gave in mind. GKTabs is just a frame for other modules. You have 5 of them there. So please show me a screen or something telling me which one.
User avatar
Moderator

GK User
Wed Nov 19, 2014 12:25 pm
Reply with quote
Report this post
Hi Teitbite, the site got messed up after your last upload of the catogory_item.php.

Entire category with the template Suivi_K2 have their images replaced with the K2 avatar, even though there is images in the first place.

I have no idea who has replaced this file. I am pretty sure it wasn't me. I thought I had a backup of that file. I uploaded it yesterday.

Here's what I have in attachment...

for the gkTabs, here is the section and the tabs that don,t have thumbnails:

(under tab "Guitar Hero" - no thumbnails)
http://miggg.quebecguitare.com/blog-cou ... -hero.html

(under tab "suivi" - no thumbnails)
http://miggg.quebecguitare.com/suivi-en ... itare.html

Sorry for the headaches...
Regards.
User avatar
Platinum Boarder

GK User
Wed Nov 19, 2014 12:28 pm
Reply with quote
Report this post
Did you keep any backup of my file before replacing it on the site?

I always keep a backup before I make changes...

Regards.
User avatar
Platinum Boarder

GK User
Thu Nov 20, 2014 7:17 am
Reply with quote
Report this post
quebecguitare wrote:Entire category with the template Suivi_K2 have their images replaced with the K2 avatar, even though there is images in the first place.


Correction: After having a second look at the problem, I was wrong in my last statement. Rather, the avatar has taken the usual space of the image, rather than the customization I've made making the avatar smaller and on the left of the title of the item.

See post previous post:

With the following code. I will try to implement it again.

Code: Select all
<img src="<?php echo $this->item->author->avatar; ?>" style="float:left;" />


Regards.
User avatar
Platinum Boarder

GK User
Thu Nov 20, 2014 7:41 am
Reply with quote
Report this post
Maybe there is something I don't understand about "adding an override" in K2. This would explain maybe why the custom code was crushed.

The thing that I don't understand is how to apply this statement to the override.css file?

There might be a confusion in the words used or I don't understand the meaning of it.

See lower in this thread.:
Code: Select all
You need to change template's override for this file which is in templates/gk_john_s/html/com_k2/templates/default/category_item.php
User avatar
Platinum Boarder

teitbite
Thu Nov 20, 2014 10:00 am
Reply with quote
Report this post
Hi

Can You please tell me in a simple way:
- what is the problem
- url to the problem

I'm sorry, but You are posting a lot and I got lost a bit ;/

In template /html folder You keep overrides to extensions. Most extensions is made with /tmpl folder and any file placed there can be overriden from it. Like for example templates/gk_john_s/html/com_k2/templates/suivi_k2/category_item.php

I only put this code there on top:

Code: Select all
<?php if(empty($this->item->image)): ?>
          <?php $this->item->image = $this->item->author->avatar; ?>
<?php endif; ?>


It means: "If IMAGE is empty use AVATAR as IMAGE".
User avatar
Moderator

GK User
Thu Nov 20, 2014 10:33 am
Reply with quote
Report this post
Hi Teitbite,

the problem is that some of the modifications made for on this thread has been lost. I didn't do any K2 update and I confirm you that I understand where goes the overriding files in /templates/gk_john_s/html/com_k2/templates/suivi_k2.

Do you have a backup? Is it possible you made a wrong manipulation that has overwritten the file category_item.php in /suivi_k2?

I think you and I are the only one that works in that folder as of now. I keep backups, I've sent them to you in my last post.

So what I need, to summarize all the problems in this thread for this template:

-The first post contains the Avatar explanation and it's wanted position
---This is the link of the page: http://miggg.quebecguitare.com/suivi-en ... itare.html

-A modification in the override.css was done for the author field that I wanted to remove. But a new class needed to be added to the /templates/gk_john_s/html/com_k2/templates/suivi_k2/category_item.php file

Code: Select all
<div id="k2Container" class="suivi_k2 itemListView<?php if($this->params->get('pageclass_sfx')) echo ' '.$this->params->get('pageclass_sfx'); ?>">


-Then avatar should be clickable

Code: Select all
<a href="<?php echo $this->item->link; ?>"> </a>




-Then the avatar should show only when there is not item image.


Code: Select all
     <?php if(empty($this->item->image): ?>
       <?php $this->item->image = $this->item->author->avatar; ?>
     <?php endif; ?>


Could you fix all for me?

Thank you
Best Regards.
User avatar
Platinum Boarder

teitbite
Sun Nov 23, 2014 10:32 am
Reply with quote
Report this post
Hi

All the code is still there, I've just checked, so please tell me what is missing. I think only style is not there becuase images are much too big, but maybe You wanted it like that.
User avatar
Moderator

GK User
Mon Nov 24, 2014 5:21 am
Reply with quote
Report this post
Hi Teitbite, thank you for your time.

The code seems complete. It's just the placement and the size of the avatar. Originally it was placed to the left of the header with some padding-right and the size was preserved.

Also, have you figured out a way to insert that avatar as an substitute image in the GK tabs module?
(Check under Blog QG/Guitar Hero and "GK tab = Ressource or Guitar Hero)

See snippets.


Thank you
Regards.
User avatar
Platinum Boarder

GK User
Tue Nov 25, 2014 6:30 pm
Reply with quote
Report this post
Any ideas?

Thank you... almost done here!
User avatar
Platinum Boarder

teitbite
Wed Nov 26, 2014 10:35 am
Reply with quote
Report this post
Hi

This is why I do not understand how do You like it. It is left aligned with a margin to right and header to the right. I need to know what do You mean. I do not remember how it looked like before, sorry. I'm being asked to help with dozens of websites everyday, so it's not possible to remember :(
User avatar
Moderator

GK User
Wed Nov 26, 2014 10:37 am
Reply with quote
Report this post
Just have a look at the attachment of post MON NOV 24, 2014 4:21 AM.

Regards
User avatar
Platinum Boarder


cron