Keyword

show GPS Tools tracks in K2 items page

More
9 years 1 month ago #146370 by kloud
Hello I need to show tracks from component GPT Tools in K2 itms page, but when I insert special code >> {GPSCONTENT ["id": 45, "elevation": 1, "speed": 1, "hr": 1]}
it does not change anything. but in com_content it works fine.
what I need to do? I tried to add extrafields to com_content but there are not extensions which will fit my needs. Only K2 can do what I need.

this is how it is in K2


and this is how it is in Com_content

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

More
9 years 1 month ago #146371 by kloud
Replied by kloud on topic show GPS Tools tracks in K2 items page
It seems like attachments add file button does not work, I can't add gps_content file to my post so I uploaded it to my hosting
getride.learnhow.xyz/plg_gpscontent_v3.0.1.zip
So if someone wants to help please look at php file in archive, it is not big file.
thanks for attention

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
9 years 1 month ago #146390 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic show GPS Tools tracks in K2 items page
Hi kloud,

I've checked the plugin file gpsconent.php, and it seems to have a condition to run on Joomla articles only.

Please try this code modification at line: 35
Replace:
if ($context != 'com_content.article' || $context == 'com_finder.indexer') {

With:
if ($context != 'com_content.article' || $context != 'com_k2.item' || $context == 'com_finder.indexer') {

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
9 years 1 month ago #146405 by kloud
Replied by kloud on topic show GPS Tools tracks in K2 items page
thanks for answer but it does not works.
<?php
defined('_JEXEC') or die('Restricted access');
jimport( 'joomla.plugin.plugin' );
jimport( 'joomla.html.parameter' );
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
defined('G_APP_NAME') or define('G_APP_NAME', 'com_gpstools');
require_once JPATH_ROOT.DS.'components'.DS.G_APP_NAME.DS.'helpers'.DS.'constants.php';
require_once JPATH_ROOT.DS.'components'.DS.G_APP_NAME.DS.'lib'.DS.'gps_helper.php';
require_once JPATH_ROOT.DS.'components'.DS.G_APP_NAME.DS.'lib'.DS.'gps_loader.php';
class plgContentGpsContent extends JPlugin{	function plgContentGpsContent( &$subject, $params ){		parent::__construct( $subject, $params );	}
	public function onContentPrepare($context, &$article, &$params, $page = 0){
		//Don't run this plugin when the content is being indexed		
		if ($context != 'com_content.article' || $context == 'com_finder.indexer') 
		{			
			return true;
		}
		// simple performance check to determine whether bot should process further
		if (strpos($article->text, 'GPSCONTENT') === false) {
			return true;
		}
		// j2.5
		return plgContentGpsContent::process_content($article, $params, $page, $context);
	}	
	function process_content(&$article, &$params, $page, $context){
		$document = JFactory::getDocument();
		$cjlib = JPATH_ROOT.DS.'components'.DS.'com_cjlib'.DS.'framework.php';
		if(file_exists($cjlib)){			require_once $cjlib;		}else{			die('CJLib (CoreJoomla API Library) component not found. Please download and install it to continue.');		}
		
		$language = JFactory::getLanguage();
		$language->load('com_gpstools', JPATH_ROOT);
		
		CJLib::import('corejoomla.framework.core');
		CJLib::import('corejoomla.ui.bootstrap', true);
		
		$article->text = preg_replace_callback('/\{GPSCONTENT(.*?)\}/', 'replace_gps_tags', $article->text);
	}
}
?>
I guess that only this part of php file is looking for displaying maps in com_content, but I don't know what and how to change to make it work with K2

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
9 years 1 month ago #146409 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic show GPS Tools tracks in K2 items page
Hi,

Have you applied the modification in my first reply?
I can't see it in the code you posted in the last reply!

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.


Powered by Kunena Forum