- Posts: 23
COMMUNITY FORUM
Show Author name in latest items from... menu item
- Ben Koren
-
Topic Author
- Offline
- Junior Member
Less
More
10 years 4 months ago #135879
by Ben Koren
Show Author name in latest items from... menu item was created by Ben Koren
Hello,
i made my home page to use menu item type "Latest items from.. (user or category), and its show 3 latest article from category, but without the name of the Author, "Written By Author Name" how can i display the name of the Author in this menu item type ?
i went to the file "latest_item.php" and i tried to add manually this code:
but its only shows me the "Written By" without the author name (user name) ?
please advice ? how can i display it ?
i made my home page to use menu item type "Latest items from.. (user or category), and its show 3 latest article from category, but without the name of the Author, "Written By Author Name" how can i display the name of the Author in this menu item type ?
i went to the file "latest_item.php" and i tried to add manually this code:
<?php if($this->item->params->get('catItemAuthor')): ?>
<!-- Item Author -->
<span class="catItemAuthor">
<?php echo K2HelperUtilities::writtenBy($this->item->author->profile->gender); ?>
<?php if(isset($this->item->author->link) && $this->item->author->link): ?>
<?php echo $this->item->author->name; ?>
<?php else: ?>
<?php echo $this->item->author->name; ?>
<?php endif; ?>
</span>
<?php endif; ?>
</div>
but its only shows me the "Written By" without the author name (user name) ?
please advice ? how can i display it ?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 4 months ago #135894
by Krikor Boghossian
Replied by Krikor Boghossian on topic Show Author name in latest items from... menu item
Hello,
You should use this to echo the name of the author.
You should use this to echo the name of the author.
$this->item->authorName
Please Log in or Create an account to join the conversation.
- Ben Koren
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 23
10 years 4 months ago #135896
by Ben Koren
Replied by Ben Koren on topic Show Author name in latest items from... menu item
hello and thank you for replaying very fast!
please forgive me but i am no PHP expert
were exactly i need to put the code in this code and what to remove from this code ? how do i modify ?
this is the code
please forgive me but i am no PHP expert
were exactly i need to put the code in this code and what to remove from this code ? how do i modify ?
this is the code
<?php if($this->item->params->get('catItemAuthor')): ?>
<!-- Item Author -->
<span class="catItemAuthor">
<?php echo K2HelperUtilities::writtenBy($this->item->author->profile->gender); ?>
<?php if(isset($this->item->author->link) && $this->item->author->link): ?>
<?php echo $this->item->author->name; ?>
<?php else: ?>
<?php echo $this->item->author->name; ?>
<?php endif; ?>
</span>
<?php endif; ?>
</div>
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 4 months ago #135928
by Krikor Boghossian
Replied by Krikor Boghossian on topic Show Author name in latest items from... menu item
You should try something like this:
<span class="catItemAuthor">
<?php echo K2HelperUtilities::writtenBy($this->item->author->profile->gender); ?>
<?php echo $this->item->authorName; ?>
</span>
Please Log in or Create an account to join the conversation.
- Ben Koren
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 23
10 years 4 months ago #135999
by Ben Koren
Replied by Ben Koren on topic Show Author name in latest items from... menu item
hello
sorry but its still not working for me
its only shows ״Written By״ without the name of the Author
please advice ?
sorry but its still not working for me
its only shows ״Written By״ without the name of the Author
please advice ?
Please Log in or Create an account to join the conversation.
- alexandria
-
- Offline
- Senior Member
Less
More
- Posts: 41
10 years 4 months ago - 10 years 4 months ago #136012
by alexandria
Replied by alexandria on topic Show Author name in latest items from... menu item
Hello,
Maybe you can try this
Maybe you can try this
<!-- Item Author -->
<?php
$author = JFactory::getUser($this->item->created_by);
$author->link = JRoute::_(K2HelperRoute::getUserRoute($this->item->created_by)); ?>
<?php echo JText::_('K2_WRITTEN_BY').' '; ?><a rel="author" href="<?php echo $author->link; ?>"><?php echo $author->name; ?></a>
Last edit: 10 years 4 months ago by alexandria.
Please Log in or Create an account to join the conversation.
- Ben Koren
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 23
10 years 4 months ago #136014
by Ben Koren
Replied by Ben Koren on topic Show Author name in latest items from... menu item
Thank You all, the last solution works for me.
great support and great component!
great support and great component!
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 4 months ago #136029
by Krikor Boghossian
Replied by Krikor Boghossian on topic Show Author name in latest items from... menu item
Thank you for your kind words Ben.
Please Log in or Create an account to join the conversation.