maba Posted January 6, 2013 Share Posted January 6, 2013 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 More sharing options...
maba Posted January 6, 2013 Author Share Posted January 6, 2013 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 More sharing options...
Soma Posted January 6, 2013 Share Posted January 6, 2013 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 More sharing options...
maba Posted January 6, 2013 Author Share Posted January 6, 2013 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 More sharing options...
Soma Posted January 6, 2013 Share Posted January 6, 2013 Look at my corrected code, you was too fast. $page->template only returns name without ".php". Link to comment Share on other sites More sharing options...
maba Posted January 6, 2013 Author Share Posted January 6, 2013 Replaced all the code in language-gateway.php with your, same error (on line 3). Link to comment Share on other sites More sharing options...
Soma Posted January 6, 2013 Share Posted January 6, 2013 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 More sharing options...
Soma Posted January 6, 2013 Share Posted January 6, 2013 BTW what is prependTemplateFile appendTemplateFile? There's no such API method in PW. Link to comment Share on other sites More sharing options...
maba Posted January 6, 2013 Author Share Posted January 6, 2013 Webroot installation. Yes, with the last snippet it works. Are in dev branch, I've seen these in this Ryan's post. Thanks Soma! Link to comment Share on other sites More sharing options...
Soma Posted January 6, 2013 Share Posted January 6, 2013 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 More sharing options...
maba Posted January 6, 2013 Author Share Posted January 6, 2013 Sorry.. I removed full path and replace it with "path" only for the post.. Yes, it works. Eh, eh.. I tried new skyscrapers profile. Link to comment Share on other sites More sharing options...
maba Posted January 6, 2013 Author Share Posted January 6, 2013 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 More sharing options...
Soma Posted January 6, 2013 Share Posted January 6, 2013 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. 2 Link to comment Share on other sites More sharing options...
maba Posted January 6, 2013 Author Share Posted January 6, 2013 Mmmm.. it's all ok for the double render problem, but same issue with the "pre" declared variables. Link to comment Share on other sites More sharing options...
Soma Posted January 6, 2013 Share Posted January 6, 2013 It's working fine here. Have you removed any code from gateway template? Link to comment Share on other sites More sharing options...
maba Posted January 6, 2013 Author Share Posted January 6, 2013 Yes.. but the problem is bigger here. No translations, no content for any page. Try to investigate.. Link to comment Share on other sites More sharing options...
Soma Posted January 6, 2013 Share Posted January 6, 2013 Have you named the template "language_gateway" or changed the new configuration to match your gateway template name? Link to comment Share on other sites More sharing options...
maba Posted January 6, 2013 Author Share Posted January 6, 2013 Yes! It works. Some problems with other template, my mistake. Link to comment Share on other sites More sharing options...
Soma Posted January 6, 2013 Share Posted January 6, 2013 Ok good to know, thanks for report. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now