- Posts: 6
COMMUNITY FORUM
item author in generic.php
- Peppo Nedra
-
Topic Author
- Offline
- New Member
I want to add the item auhor in generic.php, after the category name of every item.
I'm not able with php. :-)
I add this at line 96:
echo $this->item->author->name; ?
but I'm non able to view the author name, after the category
Please, give me some info :-))))
THANKS!!!!
Please Log in or Create an account to join the conversation.
- jeanchristophe
-
- Offline
- Junior Member
- Posts: 32
You will have to replace 'genericItemDateCreated' by something like 'author' which you will find in one another file (sorry I don't remember the exact string.
Hope thats help
Regards
Jean-Christophe
Please Log in or Create an account to join the conversation.
- jeanchristophe
-
- Offline
- Junior Member
- Posts: 32
if($item->params->get('genericItemDateCreated')):
Please Log in or Create an account to join the conversation.
- Peppo Nedra
-
Topic Author
- Offline
- New Member
- Posts: 6
if($this->item->params->get('itemTitle')):
echo $this->item->title;
endif;
OR
if($item->params->get('genericItemTitle')):
echo JText::_('Published in');
echo $item->title->name;
endif;
BUT THE ITEM TITLE IS NOT VISIBLE!
Please, give me some info
Please Log in or Create an account to join the conversation.
- Peppo Nedra
-
Topic Author
- Offline
- New Member
- Posts: 6
THANKS!!!
Please Log in or Create an account to join the conversation.
- Peppo Nedra
-
Topic Author
- Offline
- New Member
- Posts: 6
I use this solution:
$Item->author->username
After this passage, I write (n) html redirect page, one for every "username"
My english is terrible, but if you are going to the page, you view the solution:
live-arcimantova.it/blow-up-arci-mantova
Please Log in or Create an account to join the conversation.
- Olivier Karfis
-
- Offline
- Elite Member
Anybody try this solution with K2.4.1? Been trying for an hour and I'm not getting anywhere...
I'd like to get the author name and also the tag list for items within the generic.php view.
Thanks!
--Olivier
Owner of www.FrenchToday.com - K2 fan and freelancer, runs the Joomla/K2 tip site: www.yanaku.com
Please Log in or Create an account to join the conversation.
- Miro Mitov
-
- Offline
- New Member
- Posts: 9
managed to get the author name to display, but cant modify this for the link:
$items[$i]->author = &JFactory::getUser($items[$i]->created_by);
any help? How can i modify it for the link to the author? Google turns up dry for once...
Thanks.
Please Log in or Create an account to join the conversation.
- krmr
-
- Offline
- Senior Member
- Posts: 61
However I tried the suggestion and it did work in generic template, but broke the category item template displaying error messages.May be I did it wrong? I placed "$items[$i]->author = &JFactory::getUser($items[$i]->created_by);" in view.html.php in line 255, after "else {" (just above "//Pathway" string)
Can someone point out the exact place for placing the code?
My problem is I have authors, and author aliases, so first the alias should be shown, and if absent then author/user is displayed, so I guess there must be some variable added to clear the error?
Any help is mush appreciated!
Please Log in or Create an account to join the conversation.
- Miro Mitov
-
- Offline
- New Member
- Posts: 9
To get the author in the view.html.php you dont need to to include this... simply put the following to get the author and the link:
<?php if($this->item->params->get('catItemAuthor')): ?>
<!-- Item Author -->
<span class="catItemDateCreated">
<?php echo K2HelperUtilities::writtenBy($this->item->author->profile->gender); ?> <a href="<?php echo $this->item->author->link; ?>"><?php echo $this->item->author->name; ?></a>
</span>
<?php endif; ?>
you can change the span class to anything you like to get it to display the way you like it.
Hope this works for you.
krmr trzv said:
Hi everyone,I have been struggling to get the author in generic.php for ages, and am happy to see now there is a solution.
However I tried the suggestion and it did work in generic template, but broke the category item template displaying error messages.May be I did it wrong? I placed "$items[$i]->author = &JFactory::getUser($items[$i]->created_by);" in view.html.php in line 255, after "else {" (just above "//Pathway" string)
Can someone point out the exact place for placing the code?
My problem is I have authors, and author aliases, so first the alias should be shown, and if absent then author/user is displayed, so I guess there must be some variable added to clear the error?
Any help is mush appreciated!
Please Log in or Create an account to join the conversation.
- krmr
-
- Offline
- Senior Member
- Posts: 61
but i probably did not make myself clear, sorry.
i need to insert author in generic.php not in view.html.php
the string you propose is from category item.php and does not work in generic.php becouse it is not category item i.e. does not have params like "item->params->get('catItemAuthor')"
i know nothing of php, but guess that was the reason to insert the params in view.html.php
please advise what and where exactly could be used!
10x in advance
Miro Mitov said:
Hey there,
To get the author in the view.html.php you dont need to to include this... simply put the following to get the author and the link:
<?php if($this->item->params->get('catItemAuthor')): ?>
<!-- Item Author -->
<span class="catItemDateCreated">
<?php echo K2HelperUtilities::writtenBy($this->item->author->profile->gender); ?> <a href="<?php echo $this->item->author->link; ?>"><?php echo $this->item->author->name; ?></a>
</span>
<?php endif; ?>
you can change the span class to anything you like to get it to display the way you like it.
Hope this works for you.
krmr trzv said:
Hi everyone,I have been struggling to get the author in generic.php for ages, and am happy to see now there is a solution.
However I tried the suggestion and it did work in generic template, but broke the category item template displaying error messages.May be I did it wrong? I placed "$items[$i]->author = &JFactory::getUser($items[$i]->created_by);" in view.html.php in line 255, after "else {" (just above "//Pathway" string)
Can someone point out the exact place for placing the code?
My problem is I have authors, and author aliases, so first the alias should be shown, and if absent then author/user is displayed, so I guess there must be some variable added to clear the error?
Any help is mush appreciated!
Please Log in or Create an account to join the conversation.
- Mark Schultz
-
- Offline
- Junior Member
- Posts: 28
I've tried applying variations of what I've read above and I get no output.
I added $items[$i]->author = &JFactory::getUser($items[$i]->created_by);
to the items for loop in view.html.php
and this to display the author in generic.php:
<?php if($this->item->params->get('genericItemAuthor')): ?><!-- Item Author --><span class="catItemAuthor"><a href="<?php echo $this->item->author->link; ?>"><?php echo $this->item->author->name; ?></a></span><?php endif; ?>
also this:
<?php if($this->item->params->get(author')): ?><!-- Item Author --><span class="catItemAuthor"><a href="<?php echo $this->item->author->link; ?>"><?php echo $this->item->author->name; ?></a></span><?php endif; ?>
anybody got this to work?
thanks.
Please Log in or Create an account to join the conversation.
- Mark Schultz
-
- Offline
- Junior Member
- Posts: 28
thanks for any help out there in K2 land....
Please Log in or Create an account to join the conversation.
- Simon Wells
-
- Offline
- Platinum Member
- Posts: 955
Simonk2 Suppot
Please Log in or Create an account to join the conversation.
- Mark Schultz
-
- Offline
- Junior Member
- Posts: 28
Thanks so much!
Please Log in or Create an account to join the conversation.
- Mark Schultz
-
- Offline
- Junior Member
- Posts: 28
wondering what the status of this is... thanks...
Simon Wells (K2 Support) said:
I am working on a couple of possabilities and will psot a response here to cover this and a couple of other tag/generic views.
Simonk2 Suppot
Please Log in or Create an account to join the conversation.
- Jock
-
- Offline
- Premium Member
- Posts: 90
Please Log in or Create an account to join the conversation.
- Mark Schultz
-
- Offline
- Junior Member
- Posts: 28
<?php $config=new JConfig(); $query = " SELECT a.id as thisid, a.created_by as createdby, b.id as thisauthorid, b.name as thisauthor " ." FROM #__k2_items AS a " ." LEFT JOIN #__users AS b ON a.created_by=b.id " ." WHERE a.id=$item->id "; $db =& JFactory::getDBO(); $db->setQuery( $query ); $row = $db->loadObject(); $thisauthor = $row->thisauthor; $thisauthorid = $row->thisauthorid;?>
display it using something like this code:
<a href="<?php echo $config->live_site?>/index.php?option=com_k2&view=itemlist&task=user&id=<?php echo $thisauthorid;?>&Itemid=<?php echo $_REQUEST["Itemid"];?>"><?php echo $thisauthor; ?></a>
Please Log in or Create an account to join the conversation.
- cellardoor_ncx
-
- Offline
- New Member
- Posts: 9
I just wonder if it works with SEF links.
Please Log in or Create an account to join the conversation.
- Pierre de Mûelenaere
-
- Offline
- New Member
- Posts: 14
Displaying author name on tag display looks like a very usefull (and needed) modification.
thanks in advance...
Mark Schultz said:
Pull the author name using this code:
<?php $config=new JConfig(); $query = " SELECT a.id as thisid, a.created_by as createdby, b.id as thisauthorid, b.name as thisauthor " ." FROM #__k2_items AS a " ." LEFT JOIN #__users AS b ON a.created_by=b.id " ." WHERE a.id=$item->id "; $db =& JFactory::getDBO(); $db->setQuery( $query ); $row = $db->loadObject(); $thisauthor = $row->thisauthor; $thisauthorid = $row->thisauthorid;?>
display it using something like this code:
<a href="<?php echo $config->live_site?>/index.php?option=com_k2&view=itemlist&task=user&id=<?php echo $thisauthorid;?>&Itemid=<?php echo $_REQUEST["Itemid"];?>"><?php echo $thisauthor; ?></a>
Please Log in or Create an account to join the conversation.