Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

JoomFish frontend detection and "and if" fonction in PHP

JoomFish frontend detection and "and if" fonction in PHP

Hi Stephen,

I am having this problem using the latest MetamodPro version for j1.5. MetaModPro2-12DEBUG-J1-5

I cannot find a way for the detection to be made according to fronten joomfish language.

I want a module to be included for "fr" only and one for "en" only.

I tried several ways. I was unsuccessful in all my attempts.

The "and if" function doesn't work. I don't if it's my synthax in the free PHP field. MetamodPro = module ID:     696

Code:


$mainframe =& JFactory::getApplication();
$template =& $mainframe->getTemplate();

if ($template == "electric_standard_jan2011" and if $language_code == "fr") return 786;
if ($template == "electric_standard_jan2011" and if $language_code == "en") return 787;

Any suggestions?

Cheers.

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: JoomFish frontend detection and "and if" fonction in PHP

Hi Alex,

it's the "and if" that is not valid PHP syntax. Just use "and".

Code:

$mainframe =& JFactory::getApplication(); 

$template =& $mainframe->getTemplate();

if ($template == "electric_standard_jan2011"
  and $language_code == "fr") return 786;
if ($template == "electric_standard_jan2011"
  and $language_code == "en") return 787;

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: JoomFish frontend detection and "and if" fonction in PHP

Hi Stephen, thank you for the synthax.

I still cannot have to do what I need; it seems that the frontend language won't be detected by the following:

Code:


$mainframe =& JFactory::getApplication();
$template =& $mainframe->getTemplate();

if ($template == "electric_standard_jan2011" and $language_code == "fr") return 786;
if ($template == "electric_standard_jan2011" and $language_code == "en") return 787;

MetaMod debug info:
Module ID: 696
$option: com_content
$view: frontpage
$id:
$Itemid: 1
$timezone: Etc/GMT+0
$language: en-us
$language_code: en
$language_region: us
Including modules: 787

I always get this DEBUG INFO no matter what language is used on the front end with the joomfish module (flag selection).

It always return 787 with is "en". When selecting "fr" which is suppose to be default, I can never get 786 to be included.

Cheers.

Note: Language determination in System - jfrouter is set to "yes" or "no" doesn't have any effect. It is currently set to "NO"

Note 2: I am using AWS Cloudfront.

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: JoomFish frontend detection and "and if" fonction in PHP

I also got this error on one of my template:

Code:

Parse error: syntax error, unexpected T_IF in /home/guitar88/public_html/modules/mod_metamod/helper.php(606) : eval()'d code on line 4

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: JoomFish frontend detection and "and if" fonction in PHP

Can you paste the exact code you are using in the MetaMod? It's probably a missing bracket or something simple like that.

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: JoomFish frontend detection and "and if" fonction in PHP

There you go, for ID 696:

Code:


$mainframe =& JFactory::getApplication();
$template =& $mainframe->getTemplate();

if ($template == "electric_standard_jan2011" and $language_code == "fr") return 786;
if ($template == "electric_standard_jan2011" and $language_code == "en") return 787;


/*old setting - geoip needs andif condition*/
/*
if ($template == "electric_standard_jan2011") {
  if ( $language == "fr" ) return 786;
  if ( $language == "en" ) return 787;

  if ( $fromCountryId == "FR" ) return 698;
  if ( $fromCountryId == "BE" ) return 698;
  if ( $fromCountryId == "CH" ) return 698;
  if ( $fromCountryId == "ID" ) return 786;
  return 786;
}
*/


/* if ($template == "flamencofusion_internationnal_jan2011")
return 419; */

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: JoomFish frontend detection and "and if" fonction in PHP

Ok, it's weird that that is giving you an error. Are you 100% sure that this is the PHP code at fault?

One remote possibility is that "=&" in the 1st 2 lines. You could try removing the "&". Apart from that you could just retype those 1st lines in case some stray character has crept in via a copy/paste.

Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: JoomFish frontend detection and "and if" fonction in PHP

I think there's a misunderstanding: the error mentionned above would not be related to the Mod ID: 696.

I am sorry I just pasted in a random error I saw earlier.:

Code:


Parse error: syntax error, unexpected T_IF in /home/guitar88/public_html/modules/mod_metamod/helper.php(606) : eval()'d code on line 4

As for the initial problem:

I cannot get any metamod to detect the frontend language triggered by joomfish. That's the most important issue for now.

Cheers. Sorry for the confusion.

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: JoomFish frontend detection and "and if" fonction in PHP

ok, the error you are getting relates to the PHP in the box in one of the MetaMod modules. It says that in the 4th line there's an "if" statement that looks out of place. This is often due to mismatched brackets etc.

So I was asking you to paste in the code from the MetaMod that produced that particular error. It shouldn't be too hard to find that module (hopefully) based on what page it's on, and what position it's in. If the code above was indeed the one producing the error, I can't make out what was causing the error as the code looks fine. Hence my advice above.

As to the original error:
make sure the "$language handling" selector is set to "front-end language" in MetaMod. That should then match the language that JoomFish sets the page to.

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: JoomFish frontend detection and "and if" fonction in PHP

Ok Stephen, it all make sense to me. I'll have a look and let you know in a bit. Cheers for now.

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5913
Dormant:
User Info:
 
Total Users:
10796
Newest User:
mokao3
Members Online:
0
Guests Online:
190

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked