Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / What is the correct way to reference language file?

What is the correct way to reference language file?

Views: 700

Results 1 to 4 of 4
7 Jul 2012, 8:34 AM
#1
venablc avatar

venablc

New Zenner

Join Date:
Apr 2012
Location:
Norwich, Norfolk
Posts:
5
Plugin Contributions:
0

What is the correct way to reference language file?

In the new pages I am creating what is the proper way and place to reference the appropriate language file?

At the moment I have

include(DIR_WS_LANGUAGES . '/english/products_all.php'); 

in the template file (/includes/templates/template_default/templates/tpl_product_credential_default.php)

I'm sure this isn't correct as "english" shouldn't be hardcoded in like this.

Regards,

Chris V

7 Jul 2012, 9:40 AM
#2
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: What is the correct way to reference language file?

venablc:

In the new pages I am creating what is the proper way and place to reference the appropriate language file?

At the moment I have

include(DIR_WS_LANGUAGES . '/english/products_all.php');

> 
> in the template file (/includes/templates/template_default/templates/tpl_product_credential_default.php)
> 
> I'm sure this isn't correct as "english" shouldn't be hardcoded in like this.
> 
> Regards,
> 
> Chris V

Try this:  (untested) 
```php
$template =  $GLOBALS['template_dir'];
include(DIR_WS_LANGUAGES . $template.'/products_all.php'); 

Cheers
Rod

7 Jul 2012, 12:37 PM
#3
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: What is the correct way to reference language file?

/includes/templates/template_default/templates/tpl_product_credential_default.php

Not a core ZC file, so

  1. What's it doing in /template_default/?
  2. Who put it there?
  3. What is its purpose?
7 Jul 2012, 1:29 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: What is the correct way to reference language file?

Your business logic should be in the /includes/modules/pages/PAGE_NAME_HERE/header_php.php file.
And that's where the language files are loaded.

See the About Us addon for an example of adding your own custom page as you seem to be trying to do.
(You can skip the html_includes folder content if you're not needing the define-page part of it)