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

What is the correct way to reference language file?

Started by venablc on 7 Jul 2012, 8:34 AM · Views: 707

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

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

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?

20 years a Zencart User

7 Jul 2012, 1:29 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
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)

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.