Jump to content

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


maba
 Share

Recommended Posts

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

Link to comment
Share on other sites

Loaded templates:

/it/

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

/en/

Prepend... language-gateway;
Prepend... language-gateway;
Prepend... home;
Append... home;
Append... home;
Append... language-gateway;
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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");
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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