Jump to content

Problem with prependTemplateFile/appendTemplateFile and PW-language-localized-URL


Recommended Posts

Posted

Hi,

if I try to use prependTemplateFile and appendTemplateFile in a site with multi language on and PW-language-localized-URL, _init and _out files are parsed many times:

<?php echo "Prepend...<br />";

and

<?php echo "Append...<br />";

/ (it, default language):

Prepend...
Append...

/en/

Prepend...
Prepend...
Prepend...
Append...
Append...
Append...

/fr/

Prepend...
Prepend...
Prepend...
Append...
Append...
Append...

/some-it-pages/or-children

Prepend...
Prepend...
Append...
Append...

Some problem with language-gateway?

Marco

Posted

Loaded templates:

/it/

Prepend... home;
Append... home;

/en/

Prepend... language-gateway;
Prepend... language-gateway;
Prepend... home;
Append... home;
Append... home;
Append... language-gateway;
Posted

The LanguageLocalizedURL module uses gateway pages that "render" (as it is a page), in there it then will "render" the content of a page evaluated by the parser. The gateway template example provided uses $page->render();. So you got 2 render. To avoid it you could change the render to include the template that would originally be used.

<?php
$page = $modules->get('LanguageLocalizedURL')->parseUrl();
include($config->paths->templates . $page->template . ".php");

I'm not sure again about the drawbacks of this approach, but should work.

Posted

Nope :(

/en/

Prepend... language-gateway;

[b]Warning[/b]: include(/site/templates/language-gateway): failed to open stream: No such file or directory in [b]/path/site/templates/language-gateway.php[/b] on line [b]5[/b]

[b]Warning[/b]: include(): Failed opening '/site/templates/language-gateway' for inclusion (include_path='.:/Applications/MAMP/bin/php/php5.4.4/lib/php') in [b]/path/site/templates/language-gateway.php[/b] on line [b]5[/b]
Append... language-gateway; 

Thanks

Posted

Look at my corrected code, you was too fast. $page->template only returns name without ".php".

Posted

Maybe because you got PW in a subfolder of webroot?

It could also be written like this

<?php
$localizedpage = $modules->get('LanguageLocalizedURL')->parseUrl();
include("./{$localizedpage->template}.php");
Posted

Webroot installation.

Yes, with the last snippet it works. :)

Are in dev branch, I've seen these in this Ryan's post.

Thanks Soma!

Posted

Just looked like it's in a subfolder, in your error "/path/site/templates/language-gateway.php" /path/site/...

So the first example doesn't work with urls which was wrong. It should be $config->paths->templates instead.

<?php
$page = $modules->get('LanguageLocalizedURL')->parseUrl();
include($config->paths->templates . $page->template . ".php");

Ah yes I see, this was added recently, somehow missed it or couldn't remember.

Posted

Sorry.. I removed full path and replace it with "path" only for the post.. :-[

Yes, it works.

Eh, eh.. I tried new skyscrapers profile.

Posted

Not a big problem, but for the next release: now it works but cannot use this features (in _init.php of skyscrapers profile)

/***************************************************************************************
* SHARED VARIABLES
*
* These are the variables we've decided template files may choose to populate.
* These variables are ultimately output by _out.php. Here we are establishing
* default values for them.
*
*/

$browserTitle = $page->title; // what appears in the <title> tag
$headline = $page->title; // primary h1 headline
$content = $page->body; // bodycopy area

Or better.. we have to overwrite this variables in all templates because language-gateway is the first template loaded so title is "ITALIAN" (e.g.) and body is empty.

Posted

Yeah, I noticed while trying the prependTemplateFile with LanguageLocalizedURL module.

I found a solution to avoid the issue and also the double render issue it had before with render method.

I commited an update to 0.1.1 and will update the module thread later.

  • Like 2
Posted

Mmmm.. it's all ok for the double render problem, but same issue with the "pre" declared variables.

Posted

Yes.. but the problem is bigger here. No translations, no content for any page. Try to investigate.. :(

Posted

Have you named the template "language_gateway" or changed the new configuration to match your gateway template name?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...