How can a additional language file be loaded by an own/customized page?

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
RobiX
Registered User
Posts: 97
Joined: Thu Oct 05, 2017 9:59 am

How can a additional language file be loaded by an own/customized page?

Post by RobiX » Sun Feb 25, 2018 1:52 am

how can i load an additional language file, path is, e.g., "language\<current language>\<my custom page>\languagefile.php"

current language is, e.g., 'en'
<my custom page> can be any directory name, e.g., myhp
=> "language\en\myhp\languagefile.php"

how can i load/access this file directly in a php file and/or html file?

User avatar
kasimi
Extension Customisations
Extension Customisations
Posts: 3394
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: How can a additional language file be loaded by an own/customized page?

Post by kasimi » Sun Feb 25, 2018 9:43 am

Use the language service:

Code: Select all

$this->language->add_lang('myhp/languagefile', 'vendor/extname');
Also see here: https://area51.phpbb.com/docs/dev/3.1.x ... -extension

RobiX
Registered User
Posts: 97
Joined: Thu Oct 05, 2017 9:59 am

Re: How can a additional language file be loaded by an own/customized page?

Post by RobiX » Sun Feb 25, 2018 10:38 am

hi kasimi,
tnx for your answer.
i already found that link but the language file is here in 'ext\<module>\language\en' and not 'language\en'

maybe to copy the files in ext is a better/cleaner solution because of not touching the core system

User avatar
mrgoldy
Jr. Extension Validator
Posts: 753
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: How can a additional language file be loaded by an own/customized page?

Post by mrgoldy » Sun Feb 25, 2018 10:49 am

RobiX wrote:
Sun Feb 25, 2018 10:38 am

maybe to copy the files in ext is a better/cleaner solution because of not touching the core system
You answered your own question there ;)
Formerly known as posey.
''Proud member of the Studio"

RobiX
Registered User
Posts: 97
Joined: Thu Oct 05, 2017 9:59 am

Re: How can a additional language file be loaded by an own/customized page?

Post by RobiX » Sun Feb 25, 2018 10:50 am

i changed the structure and ... it is definitely better :) tnx!

RobiX
Registered User
Posts: 97
Joined: Thu Oct 05, 2017 9:59 am

Re: How can a additional language file be loaded by an own/customized page?

Post by RobiX » Mon Feb 26, 2018 11:02 pm

An additional question:

Currently i have my html templates in 'root\styles\prosilver\template\myhp'.

Is it also possible to load it from, e.g,. 'root\ext\<mod>\<mod>\template'?

So the templates are also in the ext directory?

i used https://www.phpbb.com/support/docs/en/3 ... -to-phpbb/ to create a customized page.
So far i understood, the html template is loaded via

Code: Select all

$template->set_filenames(array(
    'body' => 'myhp/yourpage_body.html',
));

User avatar
mrgoldy
Jr. Extension Validator
Posts: 753
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: How can a additional language file be loaded by an own/customized page?

Post by mrgoldy » Tue Feb 27, 2018 12:17 am

To clarify: an extension is completely self-contained.
Meaning all language files, template files, etc are ALL within the extension directory.

So the answer is yes, your template files should be within your extension folder.
vendor/extname/styles/all/template
vendor/extname/styles/all/theme
Or if they are specific for a style:
vendor/extname/styles/prosilver/template
etc..

Then you can 'request' this specific template by adding your extension path infront:

Code: Select all

$template->set_filenames(array(
    'body' => '@vendor_extname/yourpage_body.html',
));
This will look in the folders /vendor/extname/styles/all/template/
and in the currently active style /vendor/extname/styles/prosilver/template

I would suggest you have a read through here, eventhough it's a bit of a long read, it's worth your while:
https://area51.phpbb.com/docs/dev/3.2.x/index.html
https://area51.phpbb.com/docs/dev/3.2.x ... index.html
https://area51.phpbb.com/docs/dev/3.2.x ... late-files
https://area51.phpbb.com/docs/dev/3.2.x ... uage-files
https://area51.phpbb.com/docs/dev/3.2.x ... nsion.html
etc .. ;)
Formerly known as posey.
''Proud member of the Studio"

RobiX
Registered User
Posts: 97
Joined: Thu Oct 05, 2017 9:59 am

Re: How can a additional language file be loaded by an own/customized page?

Post by RobiX » Tue Feb 27, 2018 7:16 pm

many tnx posey! :)

RobiX
Registered User
Posts: 97
Joined: Thu Oct 05, 2017 9:59 am

Re: How can a additional language file be loaded by an own/customized page?

Post by RobiX » Tue Feb 27, 2018 8:13 pm

i have the following structure now

ext\<mod name1>\<mod name2>\styles\all\template\mytemplate.html
ext\<mod name1>\<mod name2>\styles\all\template\anothertemplate.html

how can i load anothertemplate.html in mytemplate.html

content of mytemplate.html
<!-- INCLUDE anothertemplate.html -->

does not work

it works in root\styles\prosilver\template (but that is not the ext-directory and i want them all in the ext-directory now :)!)

RobiX
Registered User
Posts: 97
Joined: Thu Oct 05, 2017 9:59 am

Re: How can a additional language file be loaded by an own/customized page?

Post by RobiX » Tue Feb 27, 2018 8:18 pm

i found it now - also with @name_name - greeeeeeeeeeeeat :)

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: No registered users and 4 guests