Keyword

[SOLVED] How to call K2 viewed item's title / creation date ?

More
7 years 9 months ago #156869 by Paul
Hello here !

As mentionned in title, I'd like to know how to call the K2 current item's title / creation date on my template index.php ?

What I'm trying to achieve is to display (if user is on a K2 item's page ) the title and creation date of a K2 item somewhere else ( in my index.php of my template for example ).

The thing is that I'd like to completely move the title/created date from K2 item to a module position on my template.

I've done a lot of researches but couldn't find anything but this, that work well but only for Joomla article's titles, not K2's : p
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
if ($option=="com_content" && $view=="article") {
$ids = explode(':',JRequest::getString('id'));
$article_id = $ids[0];
$article =& JTable::getInstance("content");
$article->load($article_id);
echo $article->get("title");
}

Thanks in advance !

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
7 years 9 months ago #156871 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic How to call K2 viewed item's title / creation date ?
I think this module is helpful for this purpose extensions.joomla.org/extension/bnr-content-for-k2

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store

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

More
7 years 9 months ago #156872 by Paul
Nice ! Exactly what I wanted, thanks a lot : )

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

More
7 years 9 months ago #156883 by Paul
Do you know if the same module exist but for Joomla articles plz ? : p

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
7 years 9 months ago #156886 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic How to call K2 viewed item's title / creation date ?
I think the developer has a similar module for Joomla, you can have a look at their website.

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store

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

More
7 years 9 months ago #156887 by Paul
aye but its not free :-/

I managed to do it with the code I posted on my original topic but had to do some tweaking : p

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

More
7 years 7 months ago #158118 by Andy
Hi, I looked for ages for a way to display the k2 item outside of the main k2 container (i wanted the title to be big and 100% width at the top of the page and separate from the other k2 info. This worked for me:

<?php
$db = JFactory::getDBO();
$articleid = JRequest::getInt('id');
$db->setQuery('SELECT title FROM #__k2_items WHERE id='.$articleid);
$myid=$db->loadResult();
echo $myid;
?>

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 7 months ago #158124 by Krikor Boghossian
Replied by Krikor Boghossian on topic How to call K2 viewed item's title / creation date ?

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