- Posts: 61
COMMUNITY FORUM
item author in generic.php
- krmr
- Offline
- Senior Member
Less
More
13 years 8 months ago #77319
by krmr
Replied by krmr on topic item author in generic.php
thanks for the hint,
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!
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
Less
More
- Posts: 28
13 years 7 months ago #77320
by Mark Schultz
Replied by Mark Schultz on topic item author in generic.php
Hello, wondering if anyone has this working for K2 2.4.1?
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.
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
Less
More
- Posts: 28
13 years 7 months ago #77321
by Mark Schultz
Replied by Mark Schultz on topic item author in generic.php
bump... Has anyone gotten author field to appear on generic.php with K2 2.4.1. The methods above haven't worked thus far...
thanks for any help out there in K2 land....
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
Less
More
- Posts: 955
13 years 7 months ago #77322
by Simon Wells
Replied by Simon Wells on topic item author in generic.php
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
Simonk2 Suppot
Please Log in or Create an account to join the conversation.
- Mark Schultz
- Offline
- Junior Member
Less
More
- Posts: 28
13 years 7 months ago #77323
by Mark Schultz
Replied by Mark Schultz on topic item author in generic.php
Simon,
Thanks so much!
Thanks so much!
Please Log in or Create an account to join the conversation.
- Mark Schultz
- Offline
- Junior Member
Less
More
- Posts: 28
13 years 6 months ago #77324
by Mark Schultz
Replied by Mark Schultz on topic item author in generic.php
Hi Simon,
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
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
Less
More
- Posts: 90
13 years 3 months ago #77325
by Jock
Replied by Jock on topic item author in generic.php
Did anything ever get done with this?
Please Log in or Create an account to join the conversation.
- Mark Schultz
- Offline
- Junior Member
Less
More
- Posts: 28
13 years 3 months ago #77326
by Mark Schultz
Replied by Mark Schultz on topic item author in generic.php
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>
<?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
Less
More
- Posts: 9
13 years 2 months ago #77327
by cellardoor_ncx
Replied by cellardoor_ncx on topic item author in generic.php
I approve it's working on K2 2.4.1. Thanks Mark ! You saved me couple of hours trying to write it myself.
I just wonder if it works with SEF links.
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
Less
More
- Posts: 14
13 years 2 months ago #77328
by Pierre de Mûelenaere
Replied by Pierre de Mûelenaere on topic item author in generic.php
Hello Could you be more precise about which files has to be changed exactly, where modify the code, etc.
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>
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.