Keyword

Custom K2 Content Module Assistance

More
8 years 2 months ago #157664 by Lefteris
Replied by Lefteris on topic Custom K2 Content Module Assistance
The code that Krikor provided should work fine. Just remember that the caching module should be disabled, if you want this to work properly.

Ideally this kind of functionality fits better in a plugin, but the module with disabled caching should do the trick.

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

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

  • Fábio Jordan
  • Fábio Jordan's Avatar
  • Offline
  • Senior Member
  • Nothing like a good coffee to make a better web
More
8 years 2 months ago #157666 by Fábio Jordan
Replied by Fábio Jordan on topic Custom K2 Content Module Assistance
Hi Joe Campbell.

Actually, the BNR Content for K2 works fine in K2 2.7. I'm using it with no problem.

If you need assistance with that module, let me know. See examples of how I'm using it:
www.cafecomfilme.com.br/filmes/caes-de-guerra
www.cafecomfilme.com.br/filmes/o-sono-da-morte

Best luck!

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

  • Joe Campbell
  • Joe Campbell's Avatar Topic Author
  • Offline
  • Platinum Member
More
8 years 2 months ago #157669 by Joe Campbell
Replied by Joe Campbell on topic Custom K2 Content Module Assistance
Hi @FábioJordan your K2 looks very nice.

Please provide details on how you're using BNR Content for K2 for your website?

An annotated screenshot would be awesome :)

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

  • Fábio Jordan
  • Fábio Jordan's Avatar
  • Offline
  • Senior Member
  • Nothing like a good coffee to make a better web
More
8 years 2 months ago #157671 by Fábio Jordan
Replied by Fábio Jordan on topic Custom K2 Content Module Assistance
Hi Joe Campbell.

So, what I've done is to insert two modules with BNR in differents positions (both are above the content).

In one module, I just call an extrafield (image type) to insert a background (and use fixed position in the DIV), like this:
<?php if($item->extraFields->NAMEOFEXTRAFIELD->value): ?>
<div>
<?php echo $item->extraFields->NAMEOFEXTRAFIELD->value ?>
 </div>
<?php endif; ?>

In another, I call the other parameters, like this:
<?php if($params->get('bnrItemTitle')): ?>
<div class="itemTitleTopo">
<?php echo strstr($item->title, '|', true) ?: $item->title ?>
</div>
<?php endif; ?>

BNR has some specifics codes for title, image of item and other fields, but extrafields works pretty fine.

Just to let you know, I'm using K2 2.7, so I don't know if it works with 2.7.1

Best luck!

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

  • Joe Campbell
  • Joe Campbell's Avatar Topic Author
  • Offline
  • Platinum Member
More
8 years 2 months ago #157673 by Joe Campbell
Replied by Joe Campbell on topic Custom K2 Content Module Assistance
Thanks @FábioJordan please send me your company's Twitter handle, as I would like to feature the site.

Here's an example:
Invalid consumer key/secret in configuration

Also, have you ever communicated with the developer of the BNR module?

Posted 2.7 Issue:
bnrjoomla.com/forums/posts/f2/t16/k2-bnr-nonfunctional-since-update-to-k2-2-7.html

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 2 months ago #157674 by Krikor Boghossian
Replied by Krikor Boghossian on topic Custom K2 Content Module Assistance
Here you go mate:
<?php
/**
 * @version     1.0
 * @package     Get the current item's data
 * @license     GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
 */

// no direct access
defined('_JEXEC') or die('Restricted access'); 

// imports
require_once (JPATH_SITE.'/components/com_k2/helpers/route.php');
require_once (JPATH_SITE.'/components/com_k2/helpers/utilities.php');

// required params
$mainframe 	= JFactory::getApplication();
$db 		= JFactory::getDBO();
$user 		= JFactory::getUser();

$option 	= JRequest::getCmd('option');
$view 		= JRequest::getCmd('view');

// Execute only in a K2 item
if($option == 'com_k2' && $view == 'item')
{
	// Get the current id
	$itemid = JRequest::getInt('id');

	// Perform the query
	$query = "SELECT i.*, c.name AS categoryname,c.id AS categoryid, c.alias AS categoryalias, c.params AS categoryparams 
		FROM #__k2_items as i 
		LEFT JOIN #__k2_categories c ON c.id = i.catid 
		WHERE i.published = 1 ";

	$query .= " AND i.access IN(".implode(',', $user->getAuthorisedViewLevels()).") ";
	$query .= " AND i.id={$itemid}";

	// Load the results
	$db->setQuery($query);
	$item = $db->loadObject();

	// Load the model
	$model = K2Model::getInstance('Item', 'K2Model');

	// Building the object

	// Build the object - tags
	$tags = $model->getItemTags($item->id);

	for ($i = 0; $i < sizeof($tags); $i++)
	{
		$tags[$i]->link = JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name));
	}
	$item->tags = $tags;

	// Build the object - extrafields
	$item->extra_fields = $model->getItemExtraFields($item->extra_fields, $item);

}
?>
<!-- Start the layout -->
<?php if($option == 'com_k2' && $view == 'item'): ?>
	
<!-- PASTE YOUR CODE HERE JOE -->

<?php endif; ?>
<!-- end -->

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

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

  • Joe Campbell
  • Joe Campbell's Avatar Topic Author
  • Offline
  • Platinum Member
More
8 years 2 months ago #157679 by Joe Campbell
Replied by Joe Campbell on topic Custom K2 Content Module Assistance
Krikor, you are THE MAN!!!

Thank you soooooo muchhhh - I just tested it (title, tag, and extra field) and it works perfectly.

This is how I feel right now...

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 2 months ago #157680 by Krikor Boghossian
Replied by Krikor Boghossian on topic Custom K2 Content Module Assistance
You 're welcome Joe :)

If this is something that has some potential as a standalone module, let me know so I can create it.

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

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

  • Joe Campbell
  • Joe Campbell's Avatar Topic Author
  • Offline
  • Platinum Member
More
8 years 2 months ago #157682 by Joe Campbell
Replied by Joe Campbell on topic Custom K2 Content Module Assistance
Are you talking about offering a:

K2 Item Module
Add item content (title, tags, and extra fields) in any module position throughout a K2 page.

If so, would it ship with the K2 package, so in essence, users would receive three K2 module types:

mod_k2_tools
mod_k2_content
mod_k2_item

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 2 months ago #157683 by Krikor Boghossian
Replied by Krikor Boghossian on topic Custom K2 Content Module Assistance
Actually I was thinking of a free module which could display any data of the current module in a module position with show/hide params.

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