Different languages, different templates. how?

This is a FORK of the CMS Made Simple project and is not oficially supported in any way by the CMS Made Simple development team.
Locked
palaueb
New Member
New Member
Posts: 7
Joined: Thu Nov 12, 2009 10:54 am

Different languages, different templates. how?

Post by palaueb »

Hi all!

first of all thanks for this great job, I know that is quite hard to maintain a big piece of software like this, congrats!

well, my doubt is that I have 2 templates and 2 languages, but I really don't know where to assign a template to a language. If I change the languate to a page it will change to the other language correctly, having allways the same language for the template.

How can I assign a template to a lang?

spanish pages -> spanish template
catalan pages -> catalan template

I hope you understand my non-academic-non-native english.

thanks!
Peciura

Re: Different languages, different templates. how?

Post by Peciura »

Use one template for all languages

Code: Select all

{if $lang==es_ES}
   {arrange_items_for_Spanish_taste}
{elseif $lang==ca_ES}
   {arrange_items_for_Catalan_taste}
{/if}
Usually translations can be used in one template, also use of "$lang" variable modifier allows you to use different pictures, forms for each language.
I am not sure what exactly you are trying to accomplish.
palaueb
New Member
New Member
Posts: 7
Joined: Thu Nov 12, 2009 10:54 am

Re: Different languages, different templates. how?

Post by palaueb »

Maybe your solution solve my problem, but, what I'm trying to do is:

- have two templates, each for every language
- assign each template to every language
- be happy ;-)

I'm searching the database for the template_id config and it assigns a unique template_id for page, that's not a good point to start.

Now I'm studing the code of class.pageinfo.inc.php to know from where it gets the template_id ($onepageinfo->template_id = $row['template_id'];, line 161 or $pi->template_id = $data['template_id'];, line 104). If I can add a new table in the database i can assign a languate to each template and then obtain an especific template for language.

Another solution is to use a unique template (the option that you says).

reggards and thanks! :)
palaueb
New Member
New Member
Posts: 7
Joined: Thu Nov 12, 2009 10:54 am

Re: Different languages, different templates. how?

Post by palaueb »

Here is my modification of the code to get multilang on templates:



Modify database:

Code: Select all

ALTER TABLE `cms_templates` ADD `mle_lang` VARCHAR( 255 ) NOT NULL 
Assign the languages manually: (volunteer to code the admin for this?)

Code: Select all

UPDATE cms_templates SET mle_lang = 'esp' WHERE template_id = 17; //exaple for lang 'esp' , with ID 17
UPDATE cms_templates SET mle_lang = 'cat' WHERE template_id = 19; //example for lang 'cat' with ID 19
Open and edit:

Code: Select all

path_to_website/lib/classes/class.pageinfo.inc.php
#$Id: class.pageinfo.inc.php 115 2009-08-04 16:42:12Z alby $
Edit:

Code: Select all

//Start MLE
global $mleblock, $mleblockfallback;
And add at bottom of the parent code:

Code: Select all

$mle_lang = &$gCms->smarty->compile_id;
then:

Code: Select all

//Start MLE
global $mleblock, $mleblockfallback;
$mle_lang = &$gCms->smarty->compile_id;

Now, we modify this lines with the next ones:

Code: Select all

//Start MLE
$query = "SELECT {$mlequery} c.content_id, c.content_alias, c.hierarchy, c.id_hierarchy, c.prop_names, c.create_date AS c_create_date, c.modified_date AS c_date, c.cachable, c.last_modified_by, t.template_id, t.encoding, t.modified_date AS t_date FROM ".cms_db_prefix()."templates t INNER JOIN ".cms_db_prefix()."content c ON c.template_id = t.template_id WHERE (c.content_alias = ? OR c.content_id = ?) AND c.active = 1";
//End MLE
			$row = &$db->GetRow($query, array($alias, $alias));
		}
		else
		{
//Start MLE
$query = "SELECT {$mlequery} c.content_id, c.content_alias, c.hierarchy, c.id_hierarchy, c.prop_names, c.create_date AS c_create_date, c.modified_date AS c_date, c.cachable, c.last_modified_by,t.template_id, t.encoding, t.modified_date AS t_date FROM ".cms_db_prefix()."templates t INNER JOIN ".cms_db_prefix()."content c ON c.template_id = t.template_id WHERE c.content_alias = ? AND c.active = 1";
//End MLE


/* MODIFY WITH THIS */

Code: Select all

//Start MLE
			if($mle_lang!=''){
				$query = "SELECT {$mlequery} c.content_id, c.content_alias, c.hierarchy, c.id_hierarchy, c.prop_names, c.create_date AS c_create_date, c.modified_date AS c_date, c.cachable, c.last_modified_by, t.template_id, t.encoding, t.modified_date AS t_date FROM ".cms_db_prefix()."templates t INNER JOIN ".cms_db_prefix()."content c ON t.mle_lang = '$mle_lang' WHERE (c.content_alias = ? OR c.content_id = ?) AND c.active = 1";
			}else{
				$query = "SELECT {$mlequery} c.content_id, c.content_alias, c.hierarchy, c.id_hierarchy, c.prop_names, c.create_date AS c_create_date, c.modified_date AS c_date, c.cachable, c.last_modified_by, t.template_id, t.encoding, t.modified_date AS t_date FROM ".cms_db_prefix()."templates t INNER JOIN ".cms_db_prefix()."content c ON c.template_id = t.template_id WHERE (c.content_alias = ? OR c.content_id = ?) AND c.active = 1";
			}
//End MLE
			$row = &$db->GetRow($query, array($alias, $alias));
		}
		else
		{
//Start MLE
			if($mle_lang!=''){
				$query = "SELECT {$mlequery} c.content_id, c.content_alias, c.hierarchy, c.id_hierarchy, c.prop_names, c.create_date AS c_create_date, c.modified_date AS c_date, c.cachable, c.last_modified_by,t.template_id, t.encoding, t.modified_date AS t_date FROM ".cms_db_prefix()."templates t INNER JOIN ".cms_db_prefix()."content c ON t.mle_lang = '$mle_lang' WHERE c.content_alias = ? AND c.active = 1";
			}else{
				$query = "SELECT {$mlequery} c.content_id, c.content_alias, c.hierarchy, c.id_hierarchy, c.prop_names, c.create_date AS c_create_date, c.modified_date AS c_date, c.cachable, c.last_modified_by,t.template_id, t.encoding, t.modified_date AS t_date FROM ".cms_db_prefix()."templates t INNER JOIN ".cms_db_prefix()."content c ON c.template_id = t.template_id WHERE c.content_alias = ? AND c.active = 1";
			}
//End MLE
Peciura

Re: Different languages, different templates. how?

Post by Peciura »

Have you read tips 5-7 on http://forum.cmsmadesimple.org/index.ph ... 318.0.html ?
{news category="Home-$lang" .....other params....}
Use TranslationManager module!
I would use different templates only if structure (not text or images) of pages of different languages differ by 50% and over. Can you post your templates to forum ?
palaueb
New Member
New Member
Posts: 7
Joined: Thu Nov 12, 2009 10:54 am

Re: Different languages, different templates. how?

Post by palaueb »

Hi!

My templates are both equal, only difference is text.

I have readed few posts of the forum and the documentation and I don't found that you told me.

Thanks for the point, but I have now the problem solved with that patch.

reggards!
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Different languages, different templates. how?

Post by Dr.CSS »

If the only difference is text you don't need to do anything...
Locked

Return to “[locked] CMSMS MLE fork”