how to reduce the number of templates? [solved]

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Locked
pumuklee

how to reduce the number of templates? [solved]

Post by pumuklee »

hi

i make a multilanguage website
i choose for a menu structure something like this

german
  g1
  g2
english
  e1
  e2
french
  fr1
  fr2

the page structure are the same for german eglish french pages
just the content are different because the language

my problem is that
i must make for every language a separate template because of menu, links ...

for german

Code: Select all

 <div id="menucontainer"> <img src="images/mpsbb_05.jpg" id="logopos">    
	<table id="menutable" cellpadding="0" cellspacing="0" height="" border="0" style="float: left;">
      <tr> 
        <td id="exclude"><img src="images/mpsb_02.jpg"> </td>
		<td>{cms_module module='menumanager' template='cssmenu.tpl' start_level="3" start_page=german}</td>
      </tr>
    </table>    
  </div>
		
  <div id="submaincontainer"> 
    <div id="leftpad">{content block="imageleft"} 
      <div id="textcontainerpad"> 
        {cms_module module='menumanager' start_page="links_german" template='hotlinks1'}
for english

Code: Select all

 <div id="menucontainer"> <img src="images/mpsbb_05.jpg" id="logopos">    
	<table id="menutable" cellpadding="0" cellspacing="0" height="" border="0" style="float: left;">
      <tr> 
        <td id="exclude"><img src="images/mpsb_02.jpg"> </td>
		<td>{cms_module module='menumanager' template='cssmenu.tpl' start_level="3" start_page=english}</td>
      </tr>
    </table>    
  </div>
		
  <div id="submaincontainer"> 
    <div id="leftpad">{content block="imageleft"} 
      <div id="textcontainerpad"> 
        {cms_module module='menumanager' start_page="links_english" template='hotlinks1'}
as you can see
just theese rows are different
{cms_module module='menumanager' template='cssmenu.tpl' start_level="3" start_page=german}
{cms_module module='menumanager' template='cssmenu.tpl' start_level="3" start_page=english}

{cms_module module='menumanager' start_page="links_german" template='hotlinks1'}
{cms_module module='menumanager' start_page="links_english" template='hotlinks1'}

how can i make something like this
{cms_module module='menumanager' template='cssmenu.tpl' start_level="3" start_page=}

and language comes from a php script

thanks
Last edited by pumuklee on Thu Jan 18, 2007 4:00 pm, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: how to reduce the number of templates?

Post by calguy1000 »

You can try creating a smarty variable or two in the metadata section of each page:

Code: Select all

{assign var="language" value="english"} for the english pages, change english to german for the german pages, etc.
{capture assign="links_language"}links_{$language}{/capture}
Then try this in your menumanager call:

Code: Select all

{cms_module module='menumanager' template='cssmenu.tpl' start_level="3" start_page=$language}
{cms_module module='menumanager' start_page="$links_language" template='hotlinks1'}
I haven't tested it, but it should be pretty close.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
pumuklee

Re: how to reduce the number of templates?

Post by pumuklee »

hi
i find a solution for the problem: "too many templates for a multilanguage website"

i have a structure like this
german
  g1
  g2
english
  e1
  e2
french
  fr1
  fr2

the problem was that for each language i must make a separate template because in the template i must specify some kind of theese data:
{cms_module module='menumanager' template='cssmenu.tpl' start_level="3" start_page=german}
{cms_module module='menumanager' template='cssmenu.tpl' start_level="3" start_page=english}

{cms_module module='menumanager' start_page="links_german" template='hotlinks1'}
{cms_module module='menumanager' start_page="links_english" template='hotlinks1'}

so that the result was for example if i had 3 templates for german than in the final it becomes 9 templates because i have 3 languages

my solution: i have 3 languages but the number of the templates remains 3 not 9

description of the solution:
all of my pages has an alias in this way -
ge_welcome for german
en_welcome for english
fr_welcome for french
...

in the index.php of the cmsms it is a variable: $page which is  = with the alias of the current page
this variable i put into a session variable
session_start(); --- this row comes at the start of the page index.php

after these rows from index.php

Code: Select all

	$smarty->assign('friendly_position', $gCms->variables['friendly_position']);
}
else if (get_site_preference('enablecustom404') == '' || get_site_preference('enablecustom404') == "0")
{
	ErrorHandler404();
	exit;
}
put this:
//addon------------------------------------------
$_SESSION['page'] = $page;
session_write_close();
//-----------------------------------------------


than i make a user defined tag
page_name

session_start();
$pagename = $_SESSION['page'];
$lang = explode('_',$pagename);
echo($lang[0]);

---this return for me the language definition - like ge, en, fr

and in template i insert this:
after {metadata} at the suggestion of calguy1000
{capture assign="links_name"}links_{page_name}{/capture}

---this return for me a value like this links_ge, links_en, links_fr

and somewhere in the page i call a GCB like this

{global_content name=$links_name}

and depend on which page am i it calls the german or english or french GCB


thats all folks

i hope it is useful for someone
if someone find a bug please make a reply

thanks
Last edited by pumuklee on Fri Jan 19, 2007 10:20 am, edited 1 time in total.
streever

Re: how to reduce the number of templates? [solved]

Post by streever »

thank you for figuring this out for all of us, it's very nice of you to offer it!!!
pumuklee

Re: how to reduce the number of templates? [solved]

Post by pumuklee »

hi i want to mention something to my description

in the index.php register the session var not at the end

put it after this:

Code: Select all


	$smarty->assign('content_id', $pageinfo->content_id);
	$smarty->assign('page', $page);
	$smarty->assign('page_id', $page);	
	$smarty->assign('page_name', $pageinfo->content_alias);
	$smarty->assign('page_alias', $pageinfo->content_alias);
	$smarty->assign('position', $pageinfo->content_hierarchy);
	$smarty->assign('friendly_position', $gCms->variables['friendly_position']);
}
else if (get_site_preference('enablecustom404') == '' || get_site_preference('enablecustom404') == "0")
{
	ErrorHandler404();
	exit;
}
this one:

//addon------------------------------------------
$_SESSION['page'] = $page;
session_write_close();
//-----------------------------------------------


thats all
Last edited by pumuklee on Fri Jan 19, 2007 10:21 am, edited 1 time in total.
Locked

Return to “Layout and Design (CSS & HTML)”