Page 1 of 2

[SOLVED] language dependent module

Posted: Tue May 16, 2006 3:27 pm
by designguru
I'm having trouble getting the joomfish language dependent module working - it keeps spewing the following code:

Code: Select all

Fatal error: Call to undefined function: moscheckmlmenutype() in /var/www/html/modules/mod_mainmenu_ml.php on line 416
I'll look into the module php and see what's going on but wanted to see if anyone's simply just added a php parameter in their template to selectively load module positions based on the language.

I'm not great with php but will post results here on the php needed to only display modules in the, say 'inner_french' position when the is 'fr'

q./

Re: language dependent module

Posted: Tue May 16, 2006 3:37 pm
by akede
Is the function existing in your file?

Have to check but it should work

Alex

Re: language dependent module

Posted: Tue May 16, 2006 3:47 pm
by designguru
Hey akede,

I took a peek and found the function - here's the excerpted line 374 - 296 incl:

Code: Select all

/**
	 * checking for multi lingual menutype
	 * @param string menutype
	 * @return changed menutype
	 */
	function mosCheckMLMenutype( $menutype ) {
		global $database, $mosConfig_multilingual_support, $iso_client_lang;
		if( $mosConfig_multilingual_support ) {
			$mlMenutype = $menutype .'_' . $iso_client_lang;
			$sql = "SELECT count(*)"
			. "\n FROM #__menu AS m"
			. "\n WHERE menutype = '". $mlMenutype ."'"
			. "\n AND published = 1";
			$database->setQuery( $sql );
			$count = $database->loadResult();
			if( $count > 0 ) {
				$menutype = $mlMenutype;
			}
		}
		
		return $menutype;
	}
}
Hmmm..
q.

Re: language dependent module

Posted: Tue May 16, 2006 3:51 pm
by akede
I know the problem. You have both mainmenu and mainmenu_ml activated and used in your site, right?

If so the functions will not be loaded a second time as the check in the if clause prevents this.

You should only use one kind of those mainmenus at the same time

Alex

Re: language dependent module

Posted: Tue May 16, 2006 4:00 pm
by designguru
Alex, perhaps I've misunderstood the application of this module that you've created:

I'm trying to use it on a site with, say, 10 mainmenus already setup - I want to make some of them language-dependant and thought that I could associate one mainmenu_ml to each of those, unpublish the associated mainmenu module and voila, it would work....  this isn't the case is it?

I'm now thinking that your module is for use on sites with just one mainmenu to replace per language...

Let me know if this is correct - the easiest solution for me might just be to include some php in my template to only display a certain position depending on the language...

q.

Re: language dependent module

Posted: Tue May 16, 2006 4:16 pm
by designguru
Would something like this work in my template, do you think?

Code: Select all


if ($mosConfig_lang=='en') {
	  echo <?php mosLoadModules ( 'inside_r', -2 ); ?>
}

if ($mosConfig_lang=='fr') {
	  echo <?php mosLoadModules ( 'inside_rfr', -2 ); ?>
}

q./

Re: [SOLVED] language dependent module

Posted: Tue May 16, 2006 8:24 pm
by designguru
Okay Guys,  I figured it out and this is a fantastic soluton I'm sure lots of you implementing Joomfish will love!

I decided to write a simple php statement that will load certain module positions in the same space on a template, depending which language I want them to independantly handle.

Benefits of this approach:
  • you can create content in any language you want and hide the default message or auto-created joomfish version
  • you have flexibility in what you want each language's menu-modules to display
  • you can still include native language menu items in your alternate language menus - effectively using joomfish for parts of your site and not the whole site
Here's the code:

Code: Select all

<!-- BEGIN custom language switch by http://www.designguru.org to load language-specific modules -->

<?php
if ($mosConfig_lang== english )
{mosLoadModules ( 'inside_r', -2 );} 
?>

<?php
if ($mosConfig_lang== french )
{mosLoadModules ( 'inside_rfr', -2 );} 
?>

<!-- END language switch -->
Of course, you can use any module position - you aren't restricted to 'inside_r' and 'inside_rfr' - I arbitrarily chose 'em ;)


Cheers,

q./

Re: [SOLVED] language dependent module

Posted: Thu May 18, 2006 7:45 am
by akede
This is a quite clever solution as well. It gives you a kind of flexible control over languages and modules.

I think this might be specially helpful if you use RTL and LTR languages in one site.

Alex

Re: [SOLVED] language dependent module

Posted: Tue Jun 13, 2006 7:57 am
by sikifon
Hi everybody

Effectively, my problem now is how to change the rirection to RTL depending on the language.
I've to create a web site with two languages: french and arabic

My problem is how to remember the user language, must i use the joomla session? global vars? and if it's resolved, how to change the direction, should i change the template?

Thanks for all

N@bil

Re: [SOLVED] language dependent module

Posted: Thu Jul 06, 2006 7:53 am
by Lionel
What makes joomfish work in a module? Is it just a matter of adding a function? If yes where to find it? I have a lot of important modules such as D4J Content listing which are not supported and I am trying to solve it.

thanks.

Re: [SOLVED] language dependent module

Posted: Fri Jul 21, 2006 7:24 am
by sagemaniac

Code: Select all

if ($mosConfig_lang== english ) { ...
@ design your my guru -
why didn't I think of that myself???

Thank you for sharing!


Greetz from Tübingen,
Ritch

Re: [SOLVED] language dependent module

Posted: Fri Jul 21, 2006 9:14 am
by akede
Lionel wrote: What makes joomfish work in a module? Is it just a matter of adding a function? If yes where to find it? I have a lot of important modules such as D4J Content listing which are not supported and I am trying to solve it.

thanks.
Hi I don't fully get what you want. But I assume you are asking what the language switching module does, right?

Basically this module has very less to do with the Fish itself. It just shows the languages active in your system. Then it calls the same site (including all params) and adds an attribute &lang= to the GET or POST parameters.

So if you want to rebuild it in a different module it's fine.

If you want to know how do make your component work together with the Fish (and with that be translated) check out the WIKI (http://forge.joomla.org/sf/wiki/do/view ... i/HomePage) of the Joom!Fish and you will find all requested information.

Alex

Re: [SOLVED] language dependent module

Posted: Mon Aug 14, 2006 8:13 pm
by ghilderink
Hello,

I am an newbee in this forum, but I didn't understand the answers above. I have read the wiki and the text above but i can't solve my problem!

I want to make a multilanguage website with 3 languages (german, Engllish and Dutch), using joomla 1.09 multilangual. Is it possible that i can get for each language a different menu?

I made aready three menu's:

- mainmenu (disabled)
- mainmenu_du (disabled)
- mainmenu_en (disabled)

I installed mod_mainmenu_ml (active) with the following settings:

menu name: mainmenu

but the menu will not switch? What am i doing wrong?

Greetings,

Gerrit-Jan

Re: [SOLVED] language dependent module

Posted: Sun Aug 20, 2006 8:19 pm
by miggalvez
I don't really understand how to implement this solution.

1. Where am I supposed to insert the code?
2. What is the "-2" in the

Code: Select all

{mosLoadModules ( 'inside_r', -2 );}
line?
3. What happens when you want to load a language dependent module that is positioned in the right or left position with several other modules that are not language dependent?

Re: [SOLVED] language dependent module

Posted: Thu Oct 19, 2006 2:12 pm
by gg4j
Tryed the code:





Works, but error reported:
Use of undefined variable italian - assumed 'italian' in

..templates\nametemplate\index.php line ...



I tryed
inserting the line
global $mosConfig_lang;

above the if declaration, but it's the same..
Why does it say it's an undefined variable (or constant, after global $mosConfig_lang; declaration) if it can properly read it?


About the position of modules: is it possible to load the order of modules in the same position horizontally?

Re: [SOLVED] language dependent module

Posted: Thu Oct 19, 2006 2:13 pm
by gg4j
Tryed the code:





Works, but error reported:
Use of undefined variable italian - assumed 'italian' in

..templates\nametemplate\index.php line ...



I tryed
inserting the line
global $mosConfig_lang;

above the if declaration, but it's the same..
Why does it say it's an undefined variable (or constant, after global $mosConfig_lang; declaration) if it can properly read it?


About the position of modules: is it possible to load the order of modules in the same position horizontally?

Re: [SOLVED] language dependent module

Posted: Fri Oct 20, 2006 8:36 am
by Jmx
Hi all!

I am really impressed of the skill you people posses  :-*

Anyway, i'm quite new to Joomla and Joomfish and as many others would like to get different menus when switching languages.
I simply want one language to not show the full menu and the main language the full.
I've tried to read/understand this thread but i don't understand what file to edit with what.
If anyone has got this working i twould probably be highly appreciated by many if you could post a "step by step" how to achieve it.

Thanks a lot

Re: [SOLVED] language dependent module

Posted: Tue Jan 02, 2007 3:25 pm
by g39n22e
Hi, can we please have more information about this feature? :(

For example, the code that the design guru has posted here, is it supposed to be included in the template's index code? and where in the code are we supposed to include it?

Should we use the module for the multilingual mod_mainmenu or it is not required?

I need a different menu for several languages and sorry to say this but i'm kind of a hurry to get an answer to this...

Thanks in advance for your help.

Re: [SOLVED] language dependent module

Posted: Wed Jan 03, 2007 6:52 am
by ivo.apostolov
Read the Wiki on http://www.joomfish.net

Re: [SOLVED] language dependent module

Posted: Wed Jan 03, 2007 7:41 am
by g39n22e
I did, can't understand what i'm supposed to do, it's not very clear how to use the module and from this post where to put the code. Can it be explained more clearly?

Re: [SOLVED] language dependent module

Posted: Wed Jan 03, 2007 6:04 pm
by madjar
I also didn't understand the modification but I know now, so if this helps...

This is the modified \administrator\templates\...\index.php
Somewhere in the middle You'll find a code similar to this, change it.


 
 



 

The "french" is the same as it is written in Site->Language Manager->Languages.
mosLoadModule is a function which exepts "position" as a variable.
Go to Modules->Site Modules.
Now You see a lot of modules and they are placed on Your site according to the setting in the Position collumn.
You change this position when You open the properties of any module. By default it will probably be left. In my case I've changed the 1st menu's position to user5, 2nd to user6 and so on...
You also need to publish theese menus.
That's it!

Thank's everyone for this topic. Really helpful!

Re: [SOLVED] language dependent module

Posted: Tue Feb 20, 2007 4:33 pm
by plankie
The code mentioned above did not work for me.I changed it to call for the variable $lang instead of $mosconfig_lang and to look for the ISO-codes:














And now it's working OK!

Re: [SOLVED] language dependent module

Posted: Sun Apr 08, 2007 11:10 pm
by adrianmak
after reading this post, for language dependent menu module there are two solutions
1. making depend language menu like mainmenu, mainmenu_nl, mainmenu_jp and install the multilingual aware mod_mainmenu for Joomla

2. use php code like others posted, to call different language module

Am I right ?

Re: [SOLVED] language dependent module

Posted: Fri Apr 20, 2007 10:59 am
by tishma
For newbies (or in order I figured out this stuff) :

1. Any joomla module can be published at a specified template position within specified pages.
2. The code

Code: Select all

<?php
    if ($mosConfig_lang== english )
        {mosLoadModules ( 'inside_r', -2 );} 
?>

<?php
    if ($mosConfig_lang== french )
       {mosLoadModules ( 'inside_rfr', -2 );} 
?>
belongs to template index.php file, and actually renders all modules belonging to position 'inside_r' in english and to position 'inside_rfr' in french. The second argument '-2' has to do with layout, and I'd rather not explain it here.

3. Accordingly -  there is backend work to configure language dependent menu (or whatever module) to belong to the appropriate position. To be honest - I've had hard time to figure out that it is location in index.php that determines where the content goes, not the position name such as 'left'.  :-[

4. For those who wanted to insert multilanguage module to a position ('left', for example) in the middle of language non-dependent stuff - it's probably the best to split the position into 3 (or whatever appropriate) parts (positions). Good news is that you can add positions and give the names you want, as long as those are meaningful to you.

Code: Select all


<?php mosLoadModules ( 'left_pre', -2 ); //content position before lang dependent stuff ?>

<?php  // lang dependent - english stuff 
    if ($mosConfig_lang== english )
        {mosLoadModules ( 'left_en', -2 );} 
?>

<?php  // lang dependent - french stuff 
    if ($mosConfig_lang== french )
        {mosLoadModules ( 'left_fr', -2 );} 
?>

<?php mosLoadModules ( 'left_post', -2 ); //content position after lang dependent stuff  ?>

Hope this helps.
v.

Re: [SOLVED] language dependent module

Posted: Wed Jun 06, 2007 9:01 am
by joseph21
akede wrote: If you want to know how do make your component work together with the Fish (and with that be translated) check out the WIKI (http://forge.joomla.org/sf/wiki/do/view ... i/HomePage) of the Joom!Fish and you will find all requested information.
Alex
Hello,

Could you please update the link to that tutorial? I want to make the CB Invite plugin work with the Fish and including the CB onlineFull..
I went to http://www.joomfish.net/content/view/3/11/lang,english/ but the link to that tutorial is dead.

Thanks.

Re: [SOLVED] language dependent module

Posted: Tue Jul 24, 2007 2:23 pm
by sittard
I've been testing this on my site and it's execllent, such a simple solution - many thanks for posting the code!

The only issue that I can't resolve is that when a user does a search on my site they find content for all languages. It is particular issue when you have both US and UK content on the same site.

A multi lingual content searchbot does exist for JoomFish but it only limits the search for directly translated content. Looking at the 'Search Content' mambot I'm pretty sure this would be an easy mod for someone who knew what they were doing!

Re: [SOLVED] language dependent module

Posted: Thu Jul 26, 2007 1:16 pm
by sittard
I've had a go at modifying the content search mambot so that the language selector $iso_client_lang is used to limit the search based on the section name. The section name should use the country code as follows:

- en_sectname1 (all English content)
- en_sectname2 (all English content)
- fr_sectname1  (all French content)
- fr_sectname2  (all French content)

It's a bit experimental but feel free to download and tweak as you see fit!

Download here: http://extensions.joomla.org/component/ ... Itemid,35/

:)

Re: [SOLVED] language dependent module

Posted: Fri Jul 27, 2007 11:49 am
by pvh123
All this could be done much simpler, I think.
If the language check is done early in the template and a variable is set accoring to the language, that var could be used at the spot of the mosloadmodules.
$lang_ext





    etc.
This way you do only once the lingo test and use a standard var for the loadmodules.

Re: [SOLVED] language dependent module

Posted: Thu Aug 02, 2007 3:35 pm
by hasse_r
I got some problem with a module belonging to the Joomlart Rochea template and the technique described here.


What I have done is the following...:


I included this among the global variables in the template...

Code: Select all

$mosConfig_lang 
And then changed the index.php code as follows...

Code: Select all

        <?php
        $spotlight = array ('user1_en','user2_en','user5_en','user1_se','user2_se','user5_se');
        $topspl = calSpotlight ($spotlight);
        if( $topspl ) {
        ?>
        <!-- BEGIN: TOP SPOTLIGHT -->
        <div id="ja-topslwrap">
            <div id="ja-topsl" class="clearfix">

    
              <?php if ($mosConfig_lang== english ){ // Only load user1_en if language is english.
              if( mosCountModules('user1_en') ) {?>
              <div class="ja-box<?php echo $topspl['modules']['user1_en']; ?>" style="width: <?php echo $topspl['width']; ?>;">
                <?php mosLoadModules('user1_en', -2); ?>
              </div>
              <?php }} ?>

              <?php if ($mosConfig_lang== english ){ // Only load user2_en if language is english.
              if( mosCountModules('user2_en') ) {?>
              <div class="ja-box<?php echo $topspl['modules']['user2_en']; ?>" style="width: <?php echo $topspl['width']; ?>;">
                <?php mosLoadModules('user2_en', -2); ?>
              </div>
              <?php }} ?>

              <?php if ($mosConfig_lang== english ){ // Only load user5_en if language is english.
              if( mosCountModules('user5_en') ) {?>
              <div class="ja-box<?php echo $topspl['modules']['user5_en']; ?>" style="width: <?php echo $topspl['width']; ?>;">
                <?php mosLoadModules('user5_en', -2); ?>
              </div>
              <?php }} ?>

              <?php if ($mosConfig_lang== swedish ){ // Only load user1_se if language is swedish.
              if( mosCountModules('user1_se') ) {?>
              <div class="ja-box<?php echo $topspl['modules']['user1_se']; ?>" style="width: <?php echo $topspl['width']; ?>;">
                <?php mosLoadModules('user1_se', -2); ?>
              </div>
              <?php }} ?>

              <?php if ($mosConfig_lang== swedish ){ // Only load user2_se if language is swedish.
              if( mosCountModules('user2_se') ) {?>
              <div class="ja-box<?php echo $topspl['modules']['user2_se']; ?>" style="width: <?php echo $topspl['width']; ?>;">
                <?php mosLoadModules('user2_se', -2); ?>
              </div>
              <?php }} ?>

              <?php if ($mosConfig_lang== swedish ){ // Only load user5_se if language is swedish.
              if( mosCountModules('user5_se') ) {?>
              <div class="ja-box<?php echo $topspl['modules']['user5_se']; ?>" style="width: <?php echo $topspl['width']; ?>;">
                <?php mosLoadModules('user5_se', -2); ?>
              </div>
              <?php }} ?>
            </div>
            <div class="sep"></div>
        </div>
        <!-- END: TOP SPOTLIGHT -->
I then put up some new modulepossitions in the backend and made some copies of the modules to use one for an English translation and one set for a Swedish translation.

The English ones show up as they should on my English frontend. When activating the ones that should be used if the language is Swedish messes things up a bit. First they don't show up at my Swedish frontpage and I will also get an empty space big as the modules that are showed on my English frontpage for each of the same module I assign to my Swedish frontpage.

Anyone got any usefull suggestions on how to get this to work? I am not sure that I have put things right in the PHP code...

Any tips and suggestions would be appreciated and excuse my bad English.

Re: [SOLVED] language dependent module

Posted: Sat Aug 04, 2007 6:06 am
by Beata
There isn't such rows in /administrator/templates/joomla_admin/index.php

madjar wrote: I also didn't understand the modification but I know now, so if this helps...

This is the modified \administrator\templates\...\index.php
Somewhere in the middle You'll find a code similar to this, change it.


 
 



 

The "french" is the same as it is written in Site->Language Manager->Languages.
mosLoadModule is a function which exepts "position" as a variable.
Go to Modules->Site Modules.
Now You see a lot of modules and they are placed on Your site according to the setting in the Position collumn.
You change this position when You open the properties of any module. By default it will probably be left. In my case I've changed the 1st menu's position to user5, 2nd to user6 and so on...
You also need to publish theese menus.
That's it!

Thank's everyone for this topic. Really helpful!