PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Re:Include Content Item & Joomfish (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:Include Content Item & Joomfish


#433
Xtream (User)
Fresh Boarder
Posts: 1
graphgraph
User Offline Click here to see the profile of this user
Include Content Item & Joomfish 2 3 Years, 10 Months ago Karma: 0  
Hello!

My site has 2 language. With main language plugin "include content item" works fine, but how to be with second language? When language is switched to second, plugin still use article from main language and dont want to use translated article from Joomfish.
 
  The administrator has disabled public write access.

#519
kksou (Admin)
Admin
Posts: 1599
graph
User Online Now Click here to see the profile of this user
Re:Include Content Item & Joomfish 2 3 Years, 9 Months ago Karma: 23  
I'm not familiar with the Joomfish codes.

I believe it's just adding one to two lines of codes to select the id of the translated page instead of the main page.

If someone has done it already and knows how to do it, would be great if you could share the solution with the rest.

Regards,
/kksou
 
  The administrator has disabled public write access.

#645
Dr.J.R.Halon (User)
Fresh Boarder
Posts: 4
graphgraph
User Offline Click here to see the profile of this user
Re:Include Content Item & Joomfish 3 Years, 9 Months ago Karma: 0  
Hi,

I have sites in 8 langueages (I can speek only czech and a bit english :) ). I need support JoomFISH!...

Include Content Item is great mambot but have not support JoomFISH!. Here is a code-update for JoomFISH! support. :)

It is compatible vith:
Joomla! 1.0.15 Stable
JoomFISH! v1.7
ARTIO JoomSEF v2.2.7

All functions of Include Content Item v1.03 are well-kept but now is possible add iso lang shortcut before content item id.

example:


Is possible write this code better, but I think, this is OK...

Code:
<?php
/**
* include_content_item plugin
* This plugin allows you to insert or include one content item
* into another content item.
* Author: kksou
* Copyright (C) 2006-2008. kksou.com. All Rights Reserved
* Website: http://www.kksou.com/php-gtk2
* v1.0 May 3, 2008
* v1.01 June 21, 2008
* v1.02 July 23, 2008 added display of content item title
* v1.03 July 31, 2008 added new tag {include_intro} {include_fulltext}
*/

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
$_MAMBOTS->registerFunction( 'onPrepareContent', 'botIncludeContentItem' );

function botIncludeContentItem( $published, &$row, &$params, $page=0  ) {
	#print "bp301. include content item ($published)<br>";
	#$regex = '/\{(include_content_item|include_intro|include_fulltext)\s+(\d+)\}/i';
	$regex = '/\{(include_content_item|include_intro|include_fulltext)\s+(.*?)\}/i';
	if ( !$published ) {
		$row->text = preg_replace( $regex, '', $row->text );
		return true;
	}
	$plugin = new Plugin_IncludeContentItem($row, $regex);
	return true;
}

class Plugin_IncludeContentItem {

	function Plugin_IncludeContentItem( &$row, $regex ) {
		#print "bp302. regex = $regex<br>";
		$contents = $row->text;
		#$regex = '/\{include_content_item\s*(\d+)\}/i';
		#$regex = '/\{include_content_item(.*?)\}/i';

		if (preg_match_all( $regex, $contents, $matches, PREG_SET_ORDER )) {
			#print "bp303<br>";
			$count = count( $matches[0] );
			if ($count==0) return true;
			foreach($matches as $matches2) {
				$this->process($row, $matches2);
			}
			$row->text = preg_replace( $regex, '', $row->text );
		}
		return true;
	}

	function process(&$row, $matches) {
		#print "bp304<br>";
		#print "<pre>"; print_r($matches); print "</pre>";
		$content_lang = '';
		$show_title = 0;
		$link_title = 0;
		$matches[2] = str_replace('&nbsp;', ' ', $matches[2]);
		#echo $matches[2];
		if (preg_match('/^\s*([a-z]{2})\s+(\d+)\s+(0|1)\s+(0|1)/', $matches[2], $str)) 
			{
			$content_lang = $str[1];
			$content_id = $str[2];
			$show_title = $str[3];
			$link_title = $str[4];
			} 
		elseif (preg_match('/^\s*([a-z]{2})\s+(\d+)\s+(0|1)/', $matches[2], $str))
			{
			$content_lang = $str[1];
			$content_id = $str[2];
			$show_title = $str[3];
			}
		elseif (preg_match('/^\s*([a-z]{2})\s+(\d+)/', $matches[2], $str)) 
			{
			$content_lang = $str[1];
			$content_id = $str[2];
			} 
		elseif (preg_match('/^\s*(\d+)\s+(0|1)\s+(0|1)/', $matches[2], $str)) 
			{
			$content_id = $str[1];
			$show_title = $str[2];
			$link_title = $str[3];
			} 
		elseif (preg_match('/^\s*(\d+)\s+(0|1)/', $matches[2], $str)) 
			{
			$content_id = $str[1];
			$show_title = $str[2];
			} 
		else 
			{
			$content_id = $matches[2];
			}
		

		global $database;
		
		if(strlen($content_lang)==0)
			{
			$query = "SELECT #__content.title, #__content.introtext, #__content.fulltext 
FROM #__content WHERE id=$content_id";
			$database->setQuery( $query );
			$rows = $database->loadObjectList();
			$r = $rows[0];
			$title = '';
			
			if ($show_title)
				{
				if ($link_title)
					{
					global $mosConfig_live_site;
					$Itemid = mosGetParam( $_REQUEST, 'Itemid', 0 );
					$link = $mosConfig_live_site.
"/index.php?option=com_content&
task=view&id=$content_id&Itemid=$Itemid";
          			$title = '<div class="contentheading"><a href="'. $link.'" class="contentpagetitle">'.  $r->title . '</a></div>';
					}
				else
					{
					$title = '<div class="contentheading">'.$r->title.'</div>';
					}
				}
				
			#$output = $r->introtext . $r->fulltext;
			if ($matches[1]=='include_intro') 
				{
				$output = $title . $r->introtext;
				} 
			elseif ($matches[1]=='include_fulltext') 
				{
				$output = $title . $r->fulltext;
				} 
			else 
				{
				$output = $title . $r->introtext . $r->fulltext;
				}
			$row->text = str_replace($matches[0], $output, $row->text);
			}
		else
			{
		 	$query = "SELECT #__jf_content.reference_field, #__jf_content.value FROM #__jf_content JOIN #__languages ON #__jf_content.language_id = #__languages.id WHERE #__jf_content.reference_id=$content_id AND #__jf_content.reference_table='content' AND #__languages.iso='$content_lang'";
			$database->setQuery( $query );
			$rows = $database->loadObjectList();
			$jf_title = '';
			$jf_introtext = '';
			$jf_fulltext = '';
			$title = '';
			
			foreach($rows as $key)
				{
				if (preg_match("/title/",$key->reference_field))
					{
					$jf_title = $key->value;
					}
				elseif (preg_match("/introtext/",$key->reference_field))
					{
					$jf_introtext = $key->value;
					}
				elseif (preg_match("/fulltext/",$key->reference_field))
					{
					$jf_fulltext = $key->value;
					}
				}			
			
			if ($show_title)
				{
				if ($link_title)
					{
					global $mosConfig_live_site;
					$Itemid = mosGetParam( $_REQUEST, 'Itemid', 0 );
					$link = $mosConfig_live_site.
"/index.php?option=com_content&
task=view&id=$content_id&lang=$content_lang&Itemid=$Itemid ";
          			$title = 
'<div class="contentheading">
<a href="'. $link.'" class="contentpagetitle">'.
$jf_title. '</a></div>';
					}
				else
					{
					$title = '<div class="contentheading">'.$jf_title.'</div>';
					}
				}

			#$output = $r->introtext . $r->fulltext;
			if ($matches[1]=='include_intro') 
				{
				$output = $title . $jf_introtext;
				} 
			elseif ($matches[1]=='include_fulltext') 
				{
				$output = $title . $jf_fulltext;
				} 
			else 
				{
				$output = $title . $jf_introtext . $jf_fulltext;
				}
			$row->text = str_replace($matches[0], $output, $row->text);
			}

		
	}
}

?>
Copy >> Paste :)
 
  The administrator has disabled public write access.
#652
kksou (Admin)
Admin
Posts: 1599
graph
User Online Now Click here to see the profile of this user
Re:Include Content Item & Joomfish 3 Years, 9 Months ago Karma: 23  
Thanks much for the code.

Will test it out and see if the code works for Joomla 1.5 too.

When I get both working on Joomla 1.0 and 1.5, I will upload the code to share with the rest.

Thanks and Regards,
/kksou
 
  The administrator has disabled public write access.
#667
kksou (Admin)
Admin
Posts: 1599
graph
User Online Now Click here to see the profile of this user
Re:Include Content Item & Joomfish 3 Years, 9 Months ago Karma: 23  
Hi Dr. J.R.Halon,

Thanks again for shaing the code.

I modified your code slightly so that the plugin will automatically detect which language the current page is in, and automatically retrieve the corresponding translated page of the specified content item (without the need to manually specify which language to use).

I've also added the support for Joomla 1.5, which works with their latest release of Joom!Fish 2.0 Beta.

More details here:
http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,4809/Itemid,35/

Thanks and Regards,
/kksou
 
  The administrator has disabled public write access.
#1579
deeno (User)
Fresh Boarder
Posts: 4
graphgraph
User Offline Click here to see the profile of this user
Re:Include Content Item & Joomfish 2 3 Years, 3 Months ago Karma: 0  
hi there! there seems to be another issue with joomfish...

my site has 3 languages (DE-EN-GR), and default language in joomla/joomfish is set to EN.

now if i visit the site on a browser (FF) with a language-order-of-preference set to
DE-EN-GR, the content i am including via your plugin shows up in EN !!!
but it sohuld be DE, as all the other content...

the content has been translated (just to be sure i translated also the module...)

this behaviour appears only on the frontpage!

any ideas???
 
  The administrator has disabled public write access.
#1580
Dr.J.R.Halon (User)
Fresh Boarder
Posts: 4
graphgraph
User Offline Click here to see the profile of this user
Re:Include Content Item & Joomfish 2 3 Years, 3 Months ago Karma: 0  
I don´t understand, what you exactly mean, but...

Default language in Joomla is EN, but default language in website frontend is DE. This is a potential problem. I am not a 100% sure, but on homepage in Joomla is not set languages...

Example:
www.site.com >>> www.site.com/index.php?Itemid=0
www.site.com/index.html >>> www.site.com/index.php?option=com_content&id=1&lang=en&task=view&Itemid=2

In booth cases is it the same site, but only in second case is language set. (&lang=en) I think, this is your problem. If you have not set the language in frontend (url,...) Joomla use the default language. In your case is it EN. Problem solving for you is using language shortcut in iclude content item on homepage.

Code:
{ include_intro de 123 }
 
 
Last Edit: 2009/02/03 03:37 By Dr.J.R.Halon.
  The administrator has disabled public write access.
#1582
deeno (User)
Fresh Boarder
Posts: 4
graphgraph
User Offline Click here to see the profile of this user
Re:Include Content Item & Joomfish 2 3 Years, 3 Months ago Karma: 0  
but this shouldnt be a problem! isnt it?
the idea behind it is, that of course you set a default language for the site (eg EN),
but to be user-friendly, if somebody uses a browser with language DE, AND your site also
is available in DE, then if you visit it, the startpage displays in DE!!!
(automatically, i am not setting anything here...)
i have used this behaviour many times, and it makes perfect sense!

i dont think the language shortcut would solve the problem because you force the user to see
the DE site, no matter what his browser is set to! what if he is visiting the site from UK
(and therefore his browser is probably set to EN)? then he would see the DE site! isnt it?
 
  The administrator has disabled public write access.
#1583
Dr.J.R.Halon (User)
Fresh Boarder
Posts: 4
graphgraph
User Offline Click here to see the profile of this user
Re:Include Content Item & Joomfish 2 3 Years, 3 Months ago Karma: 0  
Joomfish work with content and you include english content to english translation and deutsch content to deutsch translation. Browser seting is not important for translation and include content item plugin.
 
  The administrator has disabled public write access.
#1584
deeno (User)
Fresh Boarder
Posts: 4
graphgraph
User Offline Click here to see the profile of this user
Re:Include Content Item & Joomfish 2 3 Years, 3 Months ago Karma: 0  
as i said: content IS translated and works everywhere except on FRONTPAGE...
i dont believe you understand what i mean...
 
  The administrator has disabled public write access.



Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2012. kksou.com. All Rights Reserved