Joomla! Discussion Forums



It is currently Wed Nov 25, 2009 7:20 am (All times are UTC )

 





Post new topic Reply to topic  [ 14 posts ] 
Author Message
Posted: Tue Mar 31, 2009 9:10 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Mar 31, 2009 8:35 pm
Posts: 9
Hi,

Here is the problem that I and many other Joomla 1.5.x users probably face:

I have assigned a different template (as the default) to one (only) menu-link, and I want to use Joomfish to change this template by another, when choosing a different language in the front-end of this template. As I can understand it, this can only be achieved by altering the index.php file of the above template (since using e.g. the plug-in Yos this will assign a template for each language for the whole site and not only for the above mentioned e.g. menu link and
the specified template).

The facts are:

1). In Joomla 1.0.x the solution is obvious, adding the following lines in the index.php (so that every template would be named by its standard name and a "-en" or "-de" etc. etc.):

// gets template for page
$cur_template = $mainframe->getTemplate();
// add this
if( $mosConfig_multilingual_support ) {
$cur_template .= "-". $iso_client_lang;
}
else {
$cur_template .= "-en";
}

2). But If you are using Joomla 1.5.x and want to switch (style sheets or) templates this method will not work as the variable $mosConfig_lang is not valid to joomla 1.5.x. By searching the Internet you can find e.g. that you can do the following instead:

"...:[/u] predifine the following early in your template:
$config=&JFactory::getConfig(); $lang=$config->getValue('language'); then use the variable $lang to point to the style sheet you would like to include: Ex: /templates/YOURTEMPLATE/css/.css" type="text/css" /> Then in my case I had to create en-GB.css for English es-ES.css for spanish etc etc...".

Since I am not good in php, can someone help and specify more/exactly which php lines to add to
the index.php to assign templates to language selected in Joomfish...(& confirm if this works?)

The question remains: which exactly lines to add in the index.php (in Joomla 1.5.x) to assign a template for each language selected in the front-end???

Thanks in advance

Styl


Top
  E-mail  
 
Posted: Wed Apr 01, 2009 10:50 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Mar 31, 2009 8:35 pm
Posts: 9
Hi,

in a plug-in for Joomla 1.5.x, that assigns to every language selected in Joomfish a different template to and for the whole website, the php code looks like these:

<?php
jimport( 'joomla.plugin.plugin' );
class plgSystemEXAMPLE_jf_template extends JPlugin
{
function plgSystemEXAMPLE_jf_template(& $subject, $config)
{
parent::__construct($subject, $config);
}
function onAfterRoute(){
global $option, $mainframe;
if ($mainframe->isAdmin()) {
return; // Dont run in admin
}
$registry =& JFactory::getConfig();
$jfLang = $registry->getValue("joomfish.language", false);
if (!$lang) {
return;
}
$str_config = $this->params->get('template_config', '');
$str_config = preg_replace('/\s/', '', $str_config);
if (preg_match('/'. $lang->shortcode . '=>(((.*?),)|((.*?)$))/', $str_config, $match)) {
$newTemplate = $match[1];
$newTemplate = preg_replace('/,/', '', $newTemplate);
$mainframe->set('setTemplate', $newTemplate);
}
}
}


You can then in the back-end select and assign the templates for each language like this e.g. en=>ja_purity
(i.e. <params><param name="template_config" type="" size="" default="" label="" description="shortcode=>template_code, separate by ','. EXAMPLE: en=>beez,de=>rhuk_milkyway,fr=>ja_purity" /></params>)

I tried to change and modify the above code in a way that it could fit into the index.php of a joomla template, but to no avail till now since I am a novice at such things like Joomla plug-ins...

Can someone with the appropriate skills help and propose a solution on how to modify this code and add it in the index.php, so that we would be able to assign to and for a specified template different other templates for each language selected with Joomfish...

I tried to modify for the same reason also a cookie, that I use for switching style sheets (with a link) in the joomla templates, but this also to no avail, I will probably post its code to, if only someone could help in this direction...

Thanks for any help

Styl


Top
  E-mail  
 
Posted: Wed Apr 01, 2009 12:11 pm 
Joomla! Enthusiast
Joomla! Enthusiast
Offline

Joined: Wed Feb 13, 2008 3:48 pm
Posts: 166
Hi,

I don't know if you read this already? It's a blogpost about how to assign different templates to the selected language in Joom!Fish: http://www.joomfish.net/en/blog/30-ivos ... mfish-only

Regards, Carolien

_________________
Carolien - http://twitter.com/caro84g
Don't forget: Backup and test before you do major changes to your site


Top
   
 
Posted: Wed Apr 01, 2009 8:17 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Mar 31, 2009 8:35 pm
Posts: 9
Hi Carolien,

thank you for your contribution. After your advice I did read the blogpost that you proposed at: http://www.joomfish.net/en/blog/30-ivos ... mfish-only

But unfortunately this post is not about how to assign different templates to the selected languages in Joom!Fish! On the contrary, it has the presentation only of 3 cases written...: 1) Load different CSS file, based on the language 2) Display certain module position only into one language 3) Load different image with the different languages. This 3 cases are quite different as the case to assign different templates to the selected language in Joom!Fish. It will not work if you add in your index.php the following e.g.:

<?php
if ($this->language=="de-de") {
?>
<link rel="" href="/<?php echo $this->baseurl ?>/<?php echo $this->template ?>/<?php echo $this->language ?>-beez" type="" />
<?php } ?>

and name your templates that you want to call de-beez or de-ya_purity or fr-beez ect. ect., when you select then languages with Joom!Fish there is no "switch" of the template obviously...

To change templates is quite a different story, more complicated maybe if you like, since you have to replace/go from one template to an other, and not just to select, from the same template in which you already into, different style sheets or modules or images with a simple if/link statement, as this happens in the above mentioned blogpost, as far I can understand it it needs a more elaborated approach to achieve this.

The question that still remains & needs an answer is: which exactly lines to add in the index.php (in Joomla 1.5.x) to assign a template for each language selected in the front-end???

Thanks in advance for any further help

Regards, Styl


Top
  E-mail  
 
Posted: Thu Apr 02, 2009 7:32 am 
Joomla! Enthusiast
Joomla! Enthusiast
Offline

Joined: Wed Feb 13, 2008 3:48 pm
Posts: 166
Hi Styl,

yes, the document only explains about different css files per template, you're right.

Just a question: why don't you use the plugin, where you got the code from?

Regards, Carolien

_________________
Carolien - http://twitter.com/caro84g
Don't forget: Backup and test before you do major changes to your site


Top
   
 
Posted: Thu Apr 02, 2009 9:50 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Mar 31, 2009 8:35 pm
Posts: 9
Hi Carolien,

thanks for your question. If you use the above code as a plug-in then you are in a position to assign "only" for and to the "whole website" a template for each language (selected with Joom!Fish), but not for and to each template you use...

In case that you have assigned in the back-end an other (e.g. beez) as the default template (e.g. ja_purity) to a few menu links then you have to deal with the problem (if you use the above code as a plugin) that for this both mentioned templates (i.e. beez and ja_purity), you can assign only "one" template for each language selected with Joom!Fish (e.g. for the German language only the template
e.g. beez-de).

Or in other words, in our case e.g. for the German language: Using the above code as plugin you cannot assign to the template "beez" the template "beez-de" and to the template "ja_purity" the template "ja_purity-de", for both (or more templates that you use) you can assign only one template for each language. To explain it simple, using the above code as plugin you can "assign to each language"!!! (only) one template, but if you add this code in the index.php of each template then you are in the position to "assign to each template"!!! (and not only to each language & the whole site) a different template for each language, that you select with Joom!Fish.

I hope that I have explained it clear enough, if you want to be creative in your website with different languages, and you want to use different templates assigned in the back-end to different menus and/or links ect. ect., then you must find a way to add the above or a similar code into the index.php of your templates (if you want to use Joom!Fish).

I have opened also a thread about this in the Joom!Fish Forum: Joom!Fish 2.0 series/General Discussion + bug reports (http://www.joomfish.net/forum/viewtopic.php?f=28&t=3763)

Regards, Styl

PS: I tried to use a cookie to make a workaround to this problem, but unfortunately Joomla 1.5.9, which I use, does not work properly and has obvious one problem (at least); but I will post about this seperately in my next reply...


Top
  E-mail  
 
Posted: Fri Apr 03, 2009 7:32 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Mar 31, 2009 8:35 pm
Posts: 9
Hi again,

I tried to make also a workaround to the above problem with a cookie, but Joomla 1.5.x has still some bugs/misfunctions and does not work as it should...!!!

E.g. I established in a menu (e.g. in example pages) a menu link pointing to the external link: a page in my joomla (like http://www.yoursite.com/index.php option=com_content&view=article&id=19&Itemid=27&lang=de) and did then assign from the back-end to this menu link a different template
(e.g. beez). When I call this link then the default template does not change to the assigned templated (here beez)!?!? Therefore some more improvements to Joomla 1.5.9 should be made, since it still does not work always properly, fixing some bugs!

A selected template in the back end for a menu link (pointing to an external link) does not change the default template when you call this link, the link works alright but with the default template!!!

Anyone can test that Joomla 1.5.x does not work properly (and in this direction it must be upgrated to solve among others also this problem): Just go to the Menu Item Manager, choose menu Example Pages, then New and then External Link, give there any title you want e.g. EXPERIMENT and as link give e.g. the link to the page in the main menu e.g. Joomla! Overview (from the integrated sample data)(URLofYourSite/joomla159/index.php?option=com_content&view=article&id=19&Itemid=27&lang=en), choose Save, go now to the Template Manager, choose now a different template as the default that you have, e.g. beez and click Edit, then choose Select from List (Menu Assignment) and in the Menu Selection choose the created menu link from the menu ExamplePages EXPERIMENT (hold down the Ctrl key and choose also another link e.g. Section Blog for testing!), click save and then Preview; in your home site you can now choose from the menu Example Pages the link that you have created EXPERIMENT, as you can see the template does not change to beez as you do so!?!?!?, on the contrary if you choose the link Section Blog the template does change to beez...

Has anyone any ideas on how to fix this bug in Joomla 1.5.9 (1.5.x)

Regards, Styl

PS: If Joomla where an European project, then something like Joom!Fish would have been integrated in the core functions of Joomla from the beginning, but still as the saying goes "one nation, one planet", the Joomla team should therefore consider and do that anyway in the future upgrades of Joomla...


Top
  E-mail  
 
Posted: Fri Apr 03, 2009 8:37 pm 
User avatar
Joomla! Exemplar
Joomla! Exemplar
Offline

Joined: Thu Aug 18, 2005 9:58 am
Posts: 8101
Location: Hillerød - Denmark
Hi Styl,

Not quite sure what output you are heading for, but there are good options for switching style dependend on the active language.

You are so absolutely right that joomla! is not just a european project, its global and its used in a wealth of languages throughout the world :)

Maybe an example can help you on the way to reach your target?

Lets have a look at the standard rhuk_milkyway template that has some colorstyling options included. If we try renaming orange.css to en-GB.css and green.css to da-DK.css, then we just need to add very little code to our template to let it choose css dependend on langauge.
From this:
Code:
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/css/template.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/css/<?php echo $this->params->get('colorVariation'); ?>.css" type="text/css" />

to this:
Code:
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/css/template.css" type="text/css" />
<?php $lang =& JFactory::getLanguage(); ?>
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/css/<?php echo $lang->getTag(); ?>.css" type="text/css" />

Now, when en-GB is the active language, then the orange en-GB.css will be used, and when we switch to da-DK, then the styling switch to become green ~ da-DK.css

_________________
Ole Bang Ottosen - Joomla! Translation Coordination Team
Joomla Leadership Team - Production Working Group - i18n/l10n/translation

Webløsninger og professionel support http://www.ot2sen.dk | Dansk Joomla! support - http://joomla.dk/


Top
  E-mail  
 
Posted: Sun Apr 05, 2009 7:53 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Mar 31, 2009 8:35 pm
Posts: 9
Hi,

thanks ot2sen for your advice, on how to switch style sheets depending on the active language
in use, with some minor modifications you can use this method also in ja_purity, renaming
your styles to en-gb.css, de-de.css, da-dk.css... I did have also an idea for a workaround, but
I don't know if you can help in this direction.

As you know every language and every nation has its own character, therefore only if you use
a different template (and not only different style sheets), for each language selected, will you
be able to address this special characteristics of each nation, and therefore only in this way
will you be in the position to create a really good and functional multilingual website...

So, it would be still much better if we could "assign to each template a different template" for
each language selected (e.g. for the Danish language, to beez the template de-da-beez, to
ja_purity the template da-de-ja_purity ect., in this way someone could assign further also this
templates to menu and/or links...), and this could be achieved only if someone could insert in
the index.php file of every template the appropriate php code, therefore I hope still that a
solution could be find in this direction...

Till then I have thought that maybe the following idea could help. When you put in the head section of your index.php the code

Code:
<?php
   $pageview = JRequest::getVar('view', '');
   $pageoption = JRequest::getVar('option', '');
?>


then you can use if blocks where you want the code to differ between your home and interior pages or a particular component type page. E.g.

Code:
<?php
   if ($pageview == 'frontpage') :  // Frontpage, so include the 'example1' x module ?>
   <div id="example1">
   <jdoc:include type="modules" name="example1" style="xhtml" />
   </div>
   <?php endif; ?>
   ...   
   <?php
   if ($pageoption != 'com_comprofiler') : // Don't show the 'example2' x module on the particular
community builder type pages ?>
   <div id="example2">
   <jdoc:include type="modules" name="example2" style="xhtml" />
   </div>
    <?php endif; ?>
    ...


So if you could modify this code appropriately, then you can do stuff only for a selected active
language, in this way you can make one template to differentiate itself according to the language selected, the code should in this case look e.g. approximately like this:

Code:
...
$pagelanguage = JRequest::getVar............................
// which should get the language that is beeing used ect.
...
if ($pagelanguage == '...............')
//do the things that you want for the german language (de-de)
if ($pagelanguage == '...............')
// do the danish language (da-dk) things
...


I don't know if such a code would finally work, could someone specify this (or propose a similar) code. Which variables to get and how will the entire php code look like then exactly at the end? before someone could add it in the index.php...

Thanks for any help in advance

Regards, Styl


Top
  E-mail  
 
Posted: Mon Apr 06, 2009 12:29 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Mar 31, 2009 8:35 pm
Posts: 9
Hi again,

I figured finally out how the exact code in my above last posting should be written, so that someone can do stuffs according to the current language selected. In this way we will be able to differentiate our template in respect to the each language every time in use - but still the big problem remains! on how to assign to each template a different one, for each language selected,
adding the appropriate code in the index.php, I hope that somebody will at the end help and solve this problem???

What we need to do now in our template is determine if we are on the language in use specific page and make the necessary changes to the template based on which type of page we are on
to...

here is some code that can help with this:

Code:
$config = &JFactory::getConfig();
$lang = $config->getValue('language');
// Predifine this early in the head section
if ($lang == 'de-DE') {
  //do the german language stuff
} else {
  // do the other languages page stuff
}


We use so the "if blocks" where the code between a selected language page and the rest languages page differ. E.g. lets say that our German language page template and our other language page is the same except that the German language page doesn't have a left column, plus the English language page has a 'picture' position that has a image which comes somewhere
under the header. In this case the exact code will be as follows:

in the head section of the template add:

Code:
<?php
      $config = &JFactory::getConfig();
      $lang = $config->getValue('language');
?>


and in the body section add this lines where the code should differ:

Code:
<?php
   if ($lang != 'de-DE') :  // If the current language is not german include the right column ?>
   <div id="rightcolumn">
   <jdoc:include type="modules" name="right" style="xhtml" />
   </div>
   <?php endif; ?>
   ...   
   <?php
   if ($lang == 'de-DE') : Include in the german language page the 'picture' image module ?>
   <div id="picture">
   <jdoc:include type="modules" name="picture" style="xhtml" />
   </div>
    <?php endif; ?>
    ...


The above brief step by step tutorial would be incomplete without some sample page included? For example the code of the following template has inside some "if blocks" to do separate stuff according to the language selected or if we are in our home or interior pages, or in a particular
component type page.

Code:
<?php
/**
* Example template code (with two user positions etc. implementing if blocks for language selected
* or component in use, or if we are in the home or interior pages ect.
* .........................
*/

// no direct access
defined('_JEXEC') or die('Restricted access');
?>
<?php echo '<?xml version="1.0" encoding="utf-8"?' .'>'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this-

>language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo

$this->direction; ?>" >

<head>
<meta http-equiv="Content-Type" content="text/html; <?php echo _ISO; ?>"

/>
<?php
   $pageoption = JRequest::getVar('option', '');
   $pageview = JRequest::getVar('view', '');
   $config = &JFactory::getConfig();
   $lang = $config->getValue('language');
?>

   <jdoc:include type="head" />

   <link href="/templates/<?php echo $this->template; ?

>/css/template_css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
  <div id="header">
     <div id="banner">
     <a href="/"><img src="/templates/<?php echo $this->template; ?

>/images/logos/logo.png" alt="Home" border="0" align="left" id="logo"

/></a>
    <jdoc:include type="modules" name="banner" style="xhtml" />
    <jdoc:include type="modules" name="header" style="xhtml" />
     </div>
     <?php if ($this->countModules('top')) : ?>
            <div id="top-module">
               <jdoc:include type="modules" name="top" style="xhtml" />
            </div><!-- end top-module -->
            <?php endif; ?>
     </div> <!-- End header -->
<div id="topnav">
   <jdoc:include type="modules" name="topnav" style="xhtml" />
  </div> <!-- End topnav -->
<!-- HERE IS FOR EXAMPLE THE IF BLOCK to include the 'picture' position that has an image which comes right under the header only if the selected language is English -->
<?php if($lang == 'en-GB'): ?> :  // If the selected language is English, so include the 'picture' image module ?>
    <div id="picture">
   <jdoc:include type="modules" name="feature" style="xhtml" />
    </div>
  <?php endif; ?>
      <div id="main">
        <div id="content">
<!-- HERE IS FOR EXAMPLE THE IF BLOCK don't show the breadcrumbs on the extension community builder type pages -->
     <?php if ($pageoption != 'com_comprofiler') : // Don't show the breadcrumbs on the community builder particular component type pages ?>
      <div id="breadcrumbs">
        <jdoc:include type="modules" name="breadcrumbs" />
      </div><!-- end breadcrumbs -->
     <?php endif; ?>
          <div id="mainbodby">
     
            <div id="top-user-modules">
            <?php if ($this->countModules('user1')) : ?>
            <div id="user1">
            <jdoc:include type="modules" name="user1" style="xhtml" />
            </div><!-- end user1 -->
            <?php endif; ?>
            <?php if ($this->countModules('user2')) : ?>           

            <div id="user2">
            <jdoc:include type="modules" name="user2" style="xhtml" />   
            </div><!-- end user2 -->
            <?php endif; ?>         
             </div><!-- end top-user-modules -->
            
          <jdoc:include type="component" />
          </div><!-- end mainbody -->


<!-- HERE IS FOR EXAMPLE THE IF BLOCK to show the left column only if the language in use is the e.g. the German language -->
      <?php if($lang == 'de-DE'): ?>
       <div id="leftcolumn">
     <jdoc:include type="modules" name="left" style="xhtml" />
         </div> <!-- End leftcolumn -->
    <?php endif; ?>

<!-- HERE IS THE FOR EXAMPLE IF BLOCK to show the right column only on the home page -->
     <?php if ($pageview == 'frontpage') : ?>
           <div id="rightcolumn">
      <jdoc:include type="modules" name="right" style="xhtml" />
           </div> <!-- End rightcolumn -->
   <?php endif; ?>
         
      </div>
    </div><!-- end BodyContent -->
<div id="footer" class="clearfix">
           <?php if ($this->countModules('footer')) : ?>
         <div class="inside">
               <jdoc:include type="modules" name="footer" style="xhtml" />
            </div><!-- end inside -->
            <?php endif; ?>
        </div><!-- end footer -->
       </div><!-- end page -->
    <?php if ($this->countModules('debug')) : ?>
    <div id="debug"><jdoc:include type="modules" name="debug" /></div>
    <?php endif; ?>
</body>
</html>


The above template code should give an idea on how to go about changing the template for each language selected, or the home or interior pages or particular component type pages...

I still hope that someone will figure the needed code out, on how to assign to a specific template a different one for each language selected!

Regards, Styl


Top
  E-mail  
 
Posted: Thu Apr 16, 2009 9:04 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Mar 31, 2009 8:35 pm
Posts: 9
Hi,

I figured finally out also how to assign for each language selected a different template... So,
if you want to create a site with a totally different template for each language selected, then you
need to call the templates by using PHP and if conditions in a "fake template". The logic here
is that you must have already defined a default template in your database; in the index.php file
of this default template you must also set the right conditions like this:


If the language selected is English include once the file english-template/index.php

\/ (If the answer is NO then continue
\/ with the else statement)
\/
If the language selected is German include once the file german-template/index.php

\/ (If the answer is NO then continue
\/ with the else statement)
\/
If the language selected is French include once the file french- template/index.php

\/
\/
\/
.................


In other words, the fake template will have only this (index.php code) inside:

Code:
<?php
  $config=&JFactory::getConfig();
  $lang=$config->getValue('language');
if ($lang=="en-GB")
include_once("english-template/index.php");
else
if ($lang=="de-DE")
include_once("german-template/index.php");
else
if ($lang=="fr-FR")
include_once("french-template/index.php");
....
?>


As example, if we use for the english language the beez template, for the german language the
rhuk_milkyway template, and for the french language the ja_purity template, then your fake
template will just say this:

Code:
<?php
  $config=&JFactory::getConfig();
  $lang=$config->getValue('language');
if ($lang=="en-GB")
include_once("beez/index.php");
else
if ($lang=="de-DE")
include_once("rhuk_milkyway/index.php");
else
if ($lang=="fr-FR")
include_once("ja_purity/index.php");
?>


In this example, to be more analytical, I have created in the htdocs/template a template file (e.g.
with the name fake-template) and copied in this template file the whole template files of the above three templates.
So when you choose as default template the fake-template, then your default template will be
beez, and when you choose then the german language, the template will change to rhuk_milkyway and when you select french the template turns to ja_purity. Of course, in this
example, in the two of this templates you can select parameters in the back end, therefore we
have to change the index.php code of this templates accordingly, since the parameters can only
be called if the specific template is active as a default one in joomla (but obviously our default
template remains always the fake-template). Furthermore you must correct also the path for the
css etc. files (except if you have this templates also as separate ones in your templates file, then
the css ect. files can be loaded directly from there). For the rhuk_milkyway the code correction is
the following:

This code in the index.php:

Code:
...
<head>
<jdoc:include type="head" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/system.css"
type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/general.css"
type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/css/template.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/css/<?php
echo $this->params->get('colorVariation'); ?>.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/css/<?php
echo $this->params->get('backgroundVariation'); ?>_bg.css" type="text/css" />
<!--[if lte IE 6]>
<link href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/ieonly.css" rel="stylesheet" type="text/css" />
<![endif]-->
<?php if($this->direction == 'rtl') : ?>
   <link href="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/css/template_rtl.css" rel="stylesheet" type="text/css" />
<?php endif; ?>
</head>
<body id="page_bg" class="color_<?php echo $this->params->get('colorVariation'); ?> bg_<?php
echo $this->params->get('backgroundVariation'); ?> width_<?php echo $this->params->get
('widthStyle'); ?>">
...


must be changed to this code (if you want to choose the white variation and the template width
medium (i.e. 950px):

Code:
...
<head>
<jdoc:include type="head" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/system.css"
type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/general.css"
type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/fake-template/rhuk_milkyway/css/template.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/fake-template/rhuk_milkyway/css/blue.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/fake-template/rhuk_milkyway/css/blue_bg.css" type="text/css" />
<!--[if lte IE 6]>
<link href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/fake-template/css/ieonly.css" rel="stylesheet" type="text/css" />
<![endif]-->
<?php if($this->direction == 'rtl') : ?>
   <link href="<?php echo $this->baseurl ?>/templates/fake-template/rhuk_milkyway/css/template_rtl.css" rel="stylesheet" type="text/css" />
<?php endif; ?>
</head>
<body id="page_bg" class="medium_small">
...


I hope that the above codes will give an idea on how to go about in changing the templates for
the language each time in use...

Regards, Styl


PS: To my earlier post about the "if blocks" I have to add that it is obvious that someone can use
"and" & "or" statements to do more complicated stuff, even integrate a whole template... For
example, you can write the if blocks like this:

1)
Code:
<?php if($lang == 'de-DE or da-DK or fr-FR or ru-RU'): // You can do stuff which will appear only in this four languages: German, Danish, French and Russian ?>


or like this

2)
Code:
<?php if($lang == 'de-De' and $pageview != 'frontpage' and $pageoption == 'com_comprofiler'):
?>: // You can do stuff which
will appear only in the German language selection and only in the interios pages, and if it is
community builder particular component type page ?>


or

3) if you want to have a collapsible e.g. left column which should show only if the selected
language is English, then for example in the template ja_purity the code should be modified to:

Code:
<?php if ($this->countModules('right') and $lang == 'en-GB'): ?>
      <!-- BEGIN: RIGHT COLUMN -->
      <div id="ja-col2">
         <jdoc:include type="modules" name="right" style="jarounded" />
      </div><br />
      <!-- END: RIGHT COLUMN -->
      <?php endif; ?>


4) you can even integrate a whole template in the if blocks (if you don't want to use a fake
template), like this for the english, german and other languages:

Code:
...
<head>
...
<?php
if ($this->language=="en-GB"): ?>
<link rel="stylesheet" href="/<?php echo $this->baseurl ?>/<?php echo $this->template ?>/css/template_en.css" type="text/css" />
<?php else
if ($this->language=="de-DE"): ?>
<link rel="stylesheet" href="/<?php echo $this->baseurl ?>/<?php echo $this->template ?>/css/template_de.css" type="text/css" />
<?php else
if ($this->language=="..-.."): ?>
<link rel="stylesheet" href="/<?php echo $this->baseurl ?>/<?php echo $this->template ?>/css/template_OTHERlanguage.css" type="text/css" />
<?php } endif; ?>
...
</head>
<body>
...
<?php if ($lang == 'en-GB': //You can put the php body code of your template for the english
language which has the template_en.css stylesheet
?>
<?php if ($lang == 'de-DE': //You can put the php body code of your template for the german
language which has the template_de.css stylesheet
?>
<?php if ($lang == '..-..': //You can put the php body code of your template for the .. language
which has the template_OTHERlanguage.css stylesheet
?>
...
</body>
...


Top
  E-mail  
 
Posted: Thu Apr 30, 2009 10:05 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Mar 31, 2009 8:35 pm
Posts: 9
Hi,

in my earlier post I have mistyped and the following corrections should be made therefore:

The correction for the rhuk_milkyway code is obviously for the blue (background/color) variation (if you want the white variation you have to change the files from blue.css and blue_bg.css to white.css and white_bg.css, or if you want blue background and white color then change to
white.css and blue_bg.css), also for template width you have to correct the code to <body id="page_bg" class="width_medium"> or if you want the "fluid with maximum" one (min-width 750px and max-width 1050px) then change the class to "width_fmax", also correct the path in the IE 6 hack... etc.

In my earlier post in PS: 4) it is obvious also that you should put all your template body code in <?php if ($lang == 'en-GB': // Put here all the body code of your template for the english language ?>...<?php endif; ?> etc., and obviously the head section should be written with the correct placing of "{", etc., so the head/body sections to function properly must be corrected to:

Code:
...
<head>
<?php
$config=&JFactory::getConfig();
$lang=$config->getValue('language');
if($lang == 'en-GB') { ?>
<link rel="stylesheet" href="/<?php echo $this->baseurl ?>/<?php echo $this->template ?>/css/template_en.css" type="text/css" />
<?php } else 
if($lang == 'de-DE') { ?>
<link rel="stylesheet" href="/<?php echo $this->baseurl ?>/<?php echo $this->template ?>/css/template_de.css" type="text/css" />
<?php } else 
if($lang == '..-..') { ?>
<link rel="stylesheet" href="/<?php echo $this->baseurl ?>/<?php echo $this->template ?>/css/template_OTHERlanguage.css" type="text/css" />
<?php } ?>
</head>

<body>
<?php if ($lang == 'en-GB': //You can put in this if block the php body code of your template for the english language which has the template_en.css stylesheet ?>
...
<?php endif; ?>
<?php if ($lang == 'de-DE': //You can put in this if block the php body code of your template for the german language which has the template_de.css stylesheet ?>
...
<?php endif; ?>
<?php if ($lang == 'fr-FR': //You can put the php body code of your template for the .. (OTHER) language which has the template_OTHERlanguage.css stylesheet ?>
...
<?php endif; ?>
</body>


or, if you prefere, you can write the head section simply with separated if blocks like this:

Code:
<head>
<?php if($lang == 'en-GB'): ?>
<link rel="stylesheet" href="/<?php echo $this->baseurl ?>/<?php echo $this->template ?>/css/template_en.css" type="text/css" />
<?php endif; ?>
<?php if($lang == 'de-DE'): ?>
<link rel="stylesheet" href="/<?php echo $this->baseurl ?>/<?php echo $this->template ?>/css/template_de.css" type="text/css" />
<?php endif; ?>
<?php if($lang == '..-..'): ?>
<link rel="stylesheet" href="/<?php echo $this->baseurl ?>/<?php echo $this->template ?>/css/template_OTHERlanguage.css" type="text/css" />
<?php endif; ?>
</head>


I hope this corrections will help

Regards, Styl


PS: It is obvious that you have to create more than one fake template if you want to assign different (as the default) templates to menus and/or links, sections or categories etc..., and in such a case you can assign to your second (or third or whatsoever) fake template whatever other templates you wish for each language selected with Joom!Fish..., something impossible if should use the above mentioned plugin...


Top
  E-mail  
 
Posted: Fri May 08, 2009 9:00 am 
User avatar
Joomla! Master
Joomla! Master
Offline

Joined: Fri Aug 12, 2005 3:47 pm
Posts: 11679
Location: **Translation Matters**
In fact, one does not really need to copy the language-related templates inside of the fake template folder.

Code of the fake template index.php would for example be

Code:
<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
$config=&JFactory::getConfig();
$lang=$config->getValue('language');
if ($lang=="en-GB")
include_once("./templates/beez/index.php");
else
if ($lang=="fr-FR")
include_once("./templates/rhuk_milkyway/index.php");
?>


Then one has to copy the params.ini file of rhuk_milkyway (in this example) in the fake template folder.
If other templates are used (and if the params names are different!), the content of their params.ini would have to be added.

The params.ini below would contain params for milkyway as well as ja_purity.
Code:
colorVariation=blue
backgroundVariation=blue
widthStyle=fmax
logoType=image
logoText=Joomla!
sloganText=...because open source matters
ja_font=3
ja_screen=fluid
ja_screen_width=97
theme_header=
theme_background=lighter
theme_elements=black
horNav=1
horNavType=css
rightCollapsible=1
rightCollapseDefault=show
excludeModules=38
showComponent=1


Therefore the fake template folder would contain 3 files
index.php
templateDetails.xml
params.ini

_________________
Jean-Marie Simonet / infograf · http://www.info-graf.fr · GMT +1
Qui vult dare parva non debet magna rogare.
---------------------------------
Joomla! Translation Coordination Team


Top
  E-mail  
 
Posted: Sat Nov 07, 2009 10:46 pm 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Sat Nov 07, 2009 10:15 pm
Posts: 1
Guys this is not the right way. As infograf pointed out, you would have to mess with params files and the original template params are not actually used anymore.
I came across this article as I had a similar challenge on using multiple templates in one site. The way that templates are assigned is intrinsic wrong in J. There is only an option to choose a standard and then exceptions can only be assigned to specified menu entries.
J should actually use a session variable or cookie for the template and only if it is not set, try to determine again what to use. But alas that will take another version and it probably has not that high a priority.

A proper way in the current version would be to make a system plugin that first determines which template to use based on its parameters. A nice example is jfoobar re-Designer which allows to choose another template based on username.
In my situation I have solved the problem with some hard-coded entries, but actually I had hoped that someone had already taken the effort to create a plugin that offers the configuration in an official parameter list. If I cannot find such a plugin, I'll have to do it myself.


Top
  E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

Quick reply

 



Who is online

Users browsing this forum: shehbazbashir and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group