Keyword

Show Author name in latest items from... menu item

  • Ben Koren
  • Ben Koren's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 8 months ago #135879 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:
<?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
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 8 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.
$this->item->authorName

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Ben Koren
  • Ben Koren's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 8 months ago #135896 by Ben Koren
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
<?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
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 8 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>

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Ben Koren
  • Ben Koren's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 8 months ago #135999 by Ben Koren
hello
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.

More
9 years 8 months ago - 9 years 8 months ago #136012 by alexandria
Hello,
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: 9 years 8 months ago by alexandria.

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

  • Ben Koren
  • Ben Koren's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 8 months ago #136014 by Ben Koren
Thank You all, the last solution works for me.
great support and great component!

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 8 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.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum