Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Changing "header.php" with multiple language


Recommended Posts

Hi there. It's my first post on OsCommerce.org


Let me give you a brief idea of who am I. I'm a 24 years old webdeisgner (yes, I've not say programmer ;) ) and I've begun to work with OScommerce for my first time now.


It's been more than 2 weeks now that I'm working on my current company : LiveFood.ca


It's a website to buy online live feeders for reptiles. Everything is alright since this major bug I have right now.


Here it is:

I have two language: french and english.


Since I don't really like the basic design of OSCommerce, I've begun to customize it. Now here is my problem:


I want to customize the header and bottom part with new buttuns (links) who will jump out the catalog...and if someone want to "order online" he just have to click the "Online Store " option (top menu) to get back into the catalog....since now, everything is ok...but I realised that I need to have 2 different header and bottom...one in french and one in english...I've begun to duplicate all the .php pages of the catalog (one in french and one in english) and modify all links on the website... IT REALLY BEGIN TO BE A PAIN IN THE *** ! :blink:


So now I'm thinking that the best way to do it, is to create a new "database" into my catalog who will say something like: "when you switch to french, show the french header and bottom and when you switch to english, switch to the english header and bottom" ... Do you understand what I mean ? (by the way, sorry for my porr english,,, :unsure: )



If someone can give me a hand on this matter, it will be MORE THAN APPRECIATE :)


Feel free to try the http://livefood.ca website....and I already know that almost everything dosnt work ;) ... if I can first fix this problem, I will continue working on the website again ;)


I hope wake up tomorrow morning and get some help from "masters of OSC"


Have a nice night all ! :)



Felix Bourque, Canada

Link to comment
Share on other sites

osCommerce already has multi-language capability. I think you might need to load one of the French language contributions before going any further ...


Any additional changes you make to osCommerce will then need to be duplicated in both languages, eg new buttons (text and images). Product descriptions are made via Admin in both languages. Whenever a user selects a language from the Language box, all text and associated prices, etc, switches to the desired language.

Regards, Wizzud

"It is better to remain silent and be thought a fool, than to open your mouth and remove all doubt."

Link to comment
Share on other sites

Thx Wiz to paid attention to my problems...basically, everything on the french/english language work fine...my main question is how custom "header.php" of http://www.livefood.ca/catalog/index-eng.php?language=en can be switch to french or english ... This new "top menu" header that you see on my website is currently an extra feature I want to incorporate into my website...it dosnt come with the current OSC MS2. It's a new menu that I incorporate into the website.


Now, I just want a way to let the website do:


"When you are in english mode, display the english header.php included in the includes/languages/english/ and When you are in french mode, display the french header.php included in the includes/languages/french/ "


Of course, 2 differents header.php need to be created.... I just need some quick tips to reprogram these redirections into my OSC index.php and all other places were it will be required...


Do you understand better what I mean ?

Maybe I'm just not enough clear...


Tell me if you need more specifications or if you get the global idea


Thanks man ! :)

Link to comment
Share on other sites

Ok. I see what you are trying to achieve. Unfortunately, I think you have gone about it in such a way as to make life very difficult for yourself.


As I understand it:

You have a Home page at www.livefood.ca/index.php.

Below that you have your store, at www.livefood.ca/catalog/index.php.

'Out of the box' your store is already multi-lingual - important point!

You are changing the header of your store by

  • having your own icon, linking back to your Home page - which should then be in the current language of the store
  • providing a 'Bookmark Us' link, the text of which should be in the current language
  • removing the breadcrumb trail
  • replacing the header navigation with your own links - Contest, Support, Forum, etc, which should also be in the current store language
  • providing a definite Home button, linking back to your Home page - which should then be in the current language of the store

There may also be some changes to the footer of your store.



Ignoring your Home page for a moment, all the above changes should really be made within the existing structure of osCommerce, ie. not by creating index-eng.php and index-fr.php, but by changing header.php (and footer.php) and keeping the front page of your store as index.php.


Where you have language-dependent text - for example the 'Bookmark Us' link - add a define to each of your main language files, eg.

define ('HEADER_TITLE_BOOKMARK', 'Click here to Bookmark us');

in /includes/languages/english.php, and a corresponding entry in /includes/languages/french.php. Then change header.php to use the new define. You should also do this for any text that goes with new images in your header.


Use the same technique to define the text for your Contest/Forum/Support text (in both English and French), then simply comment out the breadcrumb trail in header.php and change the header navigation to your own version instead of the My Account, Basket, Checkout, etc that osCommerce provides by default.

You can do similar things for the footer, since the defines for the footer are also held in the same main language file (look for 'FOOTER_TEXT' as an example).


All of this means that by keeping to a single index.php and making changes to header.php and footer.php, your store itself will navigate perfectly (which it currently doesn't) and you will not have to change links. You must revert your changes to the links in the Language selection box, so that they point to index.php!


The 2 buttons in the top right hand side of your header are intended to jump the user out of the store and back to the Home page - similar to the first item of the breadcrumb trail. You have provided 2 buttons, one for each language, taking the user to 1 of 2 different Home pages (www.livefood.ca/index.php or www.livefood.ca/index_fr.php). I would suggest that you change this to a single icon/button that clearly indicates that it is a link to Home page. You have 3 choices for handling the Home page(s), using either another language-dependent define, or the $languages_id variable when you construct the link in header.php:

  • Either, keep your existing index.php and index_fr.php home pages, and add another new define to your main language files, for example define HEADER_TITLE_HOME_PAGE as 'index.php' in /includes/languages/english.php, and as 'index_fr.php' in /includes/languages/french.php; then in header.php build your link along the lines of
    $homelink = 'www.livefood.ca/' . HEADER_TITLE_HOME_PAGE;
  • Or, keep your existing index.php and index_fr.php home pages, and in header.php construct a link along the lines of
    if ($languages_id == 'en') { $homelink = 'www.livefood.ca/index.php'; } else { $homelink = 'www.livefood.ca/index_fr.php'; }
  • Or, you could build www.livefood.ca/index.php to take a language parameter, defaulting to, for example, English if no parameter is provided, and then construct the link in header.php along the lines of
    $homelink = 'www.livefood.ca/index.php?language=' . $languages_id;
    This makes for a more complex index.php home page file because it would have to check for a passed parameter and build its page accordingly, including the link back to the Online Store

The first 2 options both have advantages in that you could have straightforward html pages in your home directory if you wish, instead of the php ones, and it means you have a default page and language (English in the above examples) for visitors to your main site.


In all cases the link back to the Online Store should include the current language, eg. either href = /catalog/index.php?language=en or href = /catalog/index.php?language=fr


I'm sorry this appears to be so long-winded but its very difficult to explain in a clear and precise manner. The one important point to remember is that because osCommerce is fully multi-lingual it is far, far easier to modify existing files than it is to add new ones.


I hope at least some of the above makes sense, and possibly helps a little bit.

Regards, Wizzud

"It is better to remain silent and be thought a fool, than to open your mouth and remove all doubt."

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...