New Zenner
- Join Date:
- Sep 2008
- Posts:
- 59
- Plugin Contributions:
- 0
how to override template file according to language?
I have setup a local testing site with zen cart 1.3.8 in a winxp environment, using wamp server (with mysql 4.1.22 and php 5.2.6). The site is bilingual. I use a commercial template which is made for a previous zen cart version and I am trying to modify it in order to work ok. It has hard-coded some english link headings in the tpl_main_page.php file in the includes\templates<mytemplate>\common dir (e.g. "Customer Login", "Specials").
I want to do some modifications so these headings are output in both languages when a visitor selects one of these languages correspondingly. The template supports only english (as I wrote above the header string are hard-coded, i.e. are literal strings and not variables).
I guess I cannot override the tpl_main_page.php file itself, since it is located in a different dir than the** \includes\languages** directory where overrides can be implicated. Instead, I replaced the hard-coded strings with constant variables (the ones with the capital letters defined in the language files) which themselves get overriden language-wise since they are defined in files located in overridable directories.
So, for example one of the strings is the "Specials" heading for which the original code in the tpl_main_page.php was: ```
<td class="txt_content"><a href="index.php?main_page=specials">Specials</a></td> ``` and I replaced that with: ``` <td class="txt_content"><a href="index.php?main_page=specials"><?php echo BOX_HEADING_SPECIALS; ?></a></td> ```. Now, the BOX_HEADING_SPECIALS constant is defined as two alternative strings in each corresponding language file (**english.php** and **<2nd language.php**> under each **\includes\languages\<language>** directory, and indeed it works ok.-
Is the above method correct and compatible with the override system, or there is another alternative?
-
Now, my problem is that I attempted to do the same for another string but I cannot find a constant to replace it with (in the tpl_main_page.php file) so I read in the wiki about adding one's own definition files. So, I created two <myfile>.php definition files with just this code:
<?php DEFINE('MY_CUSTOM_CONSTANT', '<english string>'); ?>and ```
<?php DEFINE('MY_CUSTOM_CONSTANT', '<2nd language string>'); ?>
I hope I made myself clear, and I appreciate any tips...