By Jordan Weinstein on Sunday, 09 August 2015
Posted in General Issues
Likes 0
Views 2K
Votes 0
Hello,

Using the K2 plugin for EasySocial, there is an issue when an author alias is used in the K2 Item instead of the actual user that made the item.



The plugin displays the user who made it it, not the alias entered in the K2 item (which defeats the purpose of using an alias . This applies to category and item views. I suppose the issue is that if using an alias name, there would be no profile to link the author name to in EasySocial, so perhaps in the case of using an alias, simply display the name but don't link to EasySocial profile. This is actually how K2 itself handles displaying author alias.

If there is a code change, please attache here so I can apply to my live site (below is a test site)

Jordan
Hey Jordan,

I am sorry for the delay of this reply,

Can you try download my attached file and replace into JoomlaFolder\plugins\k2\easysocial\easysocial.php and see how it goes?
·
Monday, 10 August 2015 18:27
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey Jordan,

Not really sure if I understand the issue here. When accessing http://ja.ukidney.com/index.php?option=com_k2&view=item&id=1 , I don't seem to see any issues. Am I missing anything here?
·
Sunday, 09 August 2015 13:01
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Mark,

The Author (under the Title: Test) is showing as Dr. Jordan Weinstein, as I am the Joomla user who made the item. However, K2 allows you to specify an author alias (as in the screen shot above) so that you can specify any name written in text to appear as the author name. So in this case, the author should appear as 'Mr. Author Alias'. In fact fact if you disable your plugin, you will see the native K2 behavior doing this.

As I said earlier, the problem with your plugin might be that you wouldn't be able to link the Alias to an EasySocial profile since Mr. Author Alias doesn't exist; it is made up. In this case, when using your plugin with an alias, the alias should appear as simple text, not a link in item view and in the category listing of K2. By the way, that is how K2 natively handles it with your plugin off.

Jordan
·
Sunday, 09 August 2015 18:35
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey Jordan,

I am really sorry for the delay of this reply as it is a weekend for us here. Hm, I am actually still a little lost here. If that's the case, shouldn't the author's name be linked currently at http://ja.ukidney.com/index.php?option=com_k2&view=item&id=1 ? It doesn't seem to contain any hyperlink on the name?
·
Monday, 10 August 2015 02:55
·
0 Likes
·
0 Votes
·
0 Comments
·
That's correct Mark,

When using an alias, there should be no hyperlink because there would be no profile corresponding to that user. It's almost like having a guest author with no profile.

In native K2, if no alias is used, then there will be a hyperlink to the user profile. If an alias is used, then just the name appears with no hyperlink. In your plugin, if an alias is used, the name is ignored and the author displayed is the Joomla user, linked to his profile. This defeats the purpose of using an alias which is handy in many cases. I believe the plugin should have the same behavior as the native k2 where alias is concerned.

Jordan
·
Monday, 10 August 2015 03:08
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi again Mark,

If I can summarize more clearly.

The native K2 behavior for:

1. No author alias used >>> In item and category view, a hyperlink is created on the Joomla user who is author of the item and links to K2 Profile page. In my case:

component/k2/itemlist/user/62-drjordanweinstein

2. Author alias is used >>> In item and category view, no hyperlink is created and the author alias is displayed as text without a hyperlink

This is controlled in components/com_k2/templates/default/item.php in this block:

<span class="itemAuthor">
<?php echo K2HelperUtilities::writtenBy($this->item->author->profile->gender); ?>
<?php if(empty($this->item->created_by_alias)): ?>
<a rel="author" href="<?php echo $this->item->author->link; ?>"><?php echo $this->item->author->name; ?></a>
<?php else: ?>
<?php echo $this->item->author->name; ?>
<?php endif; ?>
</span>



Behavior with EasySocial K2 plugin enabled

3. No author alias used >>> hyperlink on In item and category view, a hyperlink is created on the Joomla user who is author of the item and links to EasySocial profile. In my case:

network/profile/62-dr-jordan-weinstein

4. Author alias is used >>> In item and category view, no hyperlink is created and the author alias should be displayed as text without a hyperlink. In the current plugin, the Joomla user (not the alias) is displayed with a link to that user profile

Jordan
·
Monday, 10 August 2015 04:44
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Arlex,

In the demo site above (I presume with your file updated), all that has changed in the item view is that the Joomla author name is no longer hyperlinked. But it should show the alias author name, not hyperlinked. So in the example, it should read:

Mr. Author Alias (not hyperlinked)

Also, the category view will also be affected by these changes and should behave the same:

http://ja.ukidney.com/index.php?Itemid=40

Jordan
·
Monday, 10 August 2015 21:28
·
0 Likes
·
0 Votes
·
0 Comments
·
Sorry Arlex,

It seems you hadn't uploaded the changed file to demo site. I just did and the item view is fixed and is perfect.

The only thing now is in category view:

http://ja.ukidney.com/index.php?Itemid=40

The alias name is hyperlinked to the site root. Instead, there should be no hyperlink at all for author alias, just like in the item view.

Jordan
·
Monday, 10 August 2015 21:33
·
0 Likes
·
0 Votes
·
0 Comments
·
Sorry Arlex...

This appears to be a bug in K2.

For others, to fix, go to:

/components/k2/templates/default/category_item.php

replace:

<span class="catItemAuthor">
<?php echo K2HelperUtilities::writtenBy($this->item->author->profile->gender); ?>
<?php if(isset($this->item->author->link) && $this->item->author->link): ?>
<a rel="author" href="<?php echo $this->item->author->link; ?>"><?php echo $this->item->author->name; ?></a>
<?php else: ?>
<?php echo $this->item->author->name; ?>
<?php endif; ?>
</span>


with:

<span class="catItemAuthor">
<?php echo K2HelperUtilities::writtenBy($this->item->author->profile->gender); ?>
<?php if(empty($this->item->created_by_alias)): ?>
<a rel="author" href="<?php echo $this->item->author->link; ?>"><?php echo $this->item->author->name; ?></a>
<?php else: ?>
<?php echo $this->item->author->name; ?>
<?php endif; ?>
</span>


All else is fixed now
·
Monday, 10 August 2015 22:04
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey Jordan,

Thanks for getting back to us that was working fine.

I believe K2 already fix this in v2.6.9 because my local K2 file already existed this code.

If everything work fine, I will push in our internally repo.
·
Monday, 10 August 2015 22:27
·
0 Likes
·
0 Votes
·
0 Comments
·
Great!

Thanks Arlex.

Jordan
·
Monday, 10 August 2015 22:32
·
0 Likes
·
0 Votes
·
0 Comments
·
You're welcome Jordan
·
Monday, 10 August 2015 22:37
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post