Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

template compiling problem for 'non-local' templates #627

Closed
craigh opened this issue Dec 24, 2012 · 18 comments
Closed

template compiling problem for 'non-local' templates #627

craigh opened this issue Dec 24, 2012 · 18 comments

Comments

@craigh
Copy link
Member

craigh commented Dec 24, 2012

I am working (with Jusuff) on scribite right now. As a hook-based module it needs to pull in templates that are not 'local' in the sense that they are not from the current top-level module. In order to do so, I've used the advanced functionality of Smarty and used template locations like this:

return $this->view->fetch("file:modules/Scribite/plugins/$editor/templates/editorheader.tpl");

see http://www.smarty.net/docsv2/en/template.resources.tpl#templates.from.any.dir

so this works fine* on linux/bsd based systems but completely fails in windows. Jusuff is the one to discover the problem with windows. The problem comes when the template is compiled and the location isn't correctly set. Then it cannot be rendered properly when sending to the browser. Jusuff was

*while it 'works' on my BSD (macos) machine, it does produce an odd structure. See the picture below where the "file/modules" has created a directory with a slash in the name somehow.

directorystructure

@jusuff @matheo

@craigh
Copy link
Member Author

craigh commented Dec 24, 2012

I also thought about setting the template location/path from within scribite Zikula_View does not have a method for doing so (manual override so to speak). I have also tried multiple other pathnames to get the template available but nothing works. only file:path/to/template.tpl works, but not on windows.

@ghost
Copy link

ghost commented Dec 24, 2012

Shouldn't you be using Zikula_View_Plugin and specifying paths just as you would in a module?

@craigh
Copy link
Member Author

craigh commented Dec 24, 2012

I'm investigating that now. It is being used from with the HookHandler though...

@ghost
Copy link

ghost commented Dec 24, 2012

Shouldnt matter. Use Zikula_View_Plugin::getPluginInstance($moduleName, $pluginName)

@craigh
Copy link
Member Author

craigh commented Dec 24, 2012

this works:

    $view = Zikula_View_Plugin::getPluginInstance("Scribite", $editor, Zikula_View::CACHE_DISABLED);
    return $view->fetch("editorheader.tpl");

and creates the following compile directories:

directorystructure

however, the compiling of non-local templates is still a problem. according to @Drak, Zikula does not support this because of problems with the vendor's handling of filenames/paths (Smarty) and therefore "there should be another way". I'm leaving this ticket open for now hoping that @matheo or @jusuff will have some thoughts on the matter....

@ghost
Copy link

ghost commented Dec 24, 2012

Unless there is a strong use-case for having to support file: at all, I see no reason to waste time on this issue - given this has not come up before, I'm -1 on even trying to support it.

@ghost
Copy link

ghost commented Dec 24, 2012

Even so, it's clear that windows is not a production target otherwise there would have been many bug reports about this.

@espaan
Copy link
Contributor

espaan commented Dec 24, 2012

As long as it works on linux it's fine for production environments, but for local testing this would be not convenient to say the least.

Within Content it might be that this was coded at some stage, since in earlier days I cannot remember that there was something like that in the code :-) I also don't know how to solve it actually.

In Content before upgrading to OO as it is now the getXtemplates function was not there afais in the code. This was just hard coded in the template for the calling module.

@ghost
Copy link

ghost commented Dec 24, 2012

What are the paths Content is trying to map with this notation?

@craigh
Copy link
Member Author

craigh commented Dec 24, 2012

I'm not sure I understand @Drak 's question.

for certain, I am the one that coded these methods when I refactored Content (v4.0.0). The problem as I recall, was that the template can come from anywhere (ContentTypes are in many different modules) and so I needed a way to get them from the document root. Or something like that. It's been a while since I did that and I don't remember exactly.

Content does things a bit wacky and there are multiple instances of Zikula_(Form_)View passing around making things even more complicated and memory intensive. I remember having to create and destroy instances of View to get the job done.

@espaan
Copy link
Contributor

espaan commented Dec 25, 2012

True, the view instances had to be destroyed in some places, I can also remember that.

I have not dived into those methods to be honest (should have done that probably back then ...), but they worked.
In the end they might not be necessary, but it had to do with the contenttypes and layouttypes that can be in any other
module and location indeed. Maybe in future this could be re-coded to other ways, especially since system/module plugins can now also have templates etc (or was that not a ticket also that was solved?).

@mazdev
Copy link

mazdev commented Mar 7, 2013

// Get the full path of the template.tpl template

$smarty->assign('one_var', dirname(FILE).'/template.tpl');
return $this->display(FILE, $this->name.'.tpl');

And the following code:
{include file=$one_var}

or something different like: (I don't know how to put this in php)

if substr( $string_n, 0, 7 ) === "file:///"

$filename = filename:

@damon18
Copy link

damon18 commented Sep 24, 2013

@espaan
Copy link
Contributor

espaan commented Jan 23, 2014

I just tried this in Zikula Core 1.3.4 build 35 and current github version of Content and News and there also the template is not found. So on Win xampp platform the template ath with file: resource and absolute paths don't work.
You get

WARN (4): E_USER_WARNING: Smarty error: unable to read resource: 
"http://localhost/zk134b35/file:C:\Apps\xampp182\htdocs\zk134b35/modules/News/templates/contenttype/newsarticles_edit.tpl" 
in C:\Apps\xampp182\htdocs\zk134b35\lib\vendor\Smarty\Smarty.class.php line 109

@espaan
Copy link
Contributor

espaan commented May 14, 2014

I now notice that going back to DataUtil of Zikula Core 1.3.4 build12 does work with on Windows systems. Apparantly the creating of the compiled version of the template uses FormatForOS, since that is the only difference I could find between 134 and 138 in this problem scope.

It's not an issue in production, but for testing it makes it so much easier when this works again. for instance for Content as it is now.

What does make it work is changing back again in DataUtil line 413:

            $dirty_array = preg_split('#[/\\\\]#', $var, -1, PREG_SPLIT_NO_EMPTY);

into

            $dirty_array = preg_split('#[:/\\\\]#', $var, -1, PREG_SPLIT_NO_EMPTY);

not sure why the : was excluded from the pregsplit.

The update was done here:
9e74470

espaan added a commit to espaan/core that referenced this issue May 15, 2014
| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | -
| Fixed tickets | zikula#627
| Refs tickets  | zikula-modules/Content#135
| License       | MIT
| Doc PR        | -

On windows test environments an absolute template path is not working currently. Compiled template gives errors, see ticket zikula#627 for more information.
During the change from 1.3.4 build 12 to 1.3.5 this part was changed in zikula@9e74470 

Removal of the : in the preg_split makes that win test environments don't work with absolute template paths any more. I cannot see a side effect of adding this : back in the preg_split.
It does solve windows testing for a number of modules.

ping @cmfcmf can you check as well ?
espaan added a commit to espaan/core that referenced this issue May 15, 2014
| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | -
| Fixed tickets | zikula#627
| Refs tickets  | zikula-modules/Content#135
| License       | MIT
| Doc PR        | -

On windows test environments an absolute template path is not working currently. Compiled template gives errors, see ticket zikula#627 for more information.
During the change from 1.3.4 build 12 to 1.3.5 this part was changed in zikula@9e74470.
This update reverts a part of that udpate.

Removal of the : in the preg_split makes that win test environments don't work with absolute template paths any more. I cannot see a side effect of adding this : back in the preg_split.
It does solve windows testing for a number of modules.

ping @cmfcmf can you check as well ?
@cmfcmf cmfcmf closed this as completed in dee130c May 21, 2014
@craigh
Copy link
Member Author

craigh commented May 21, 2014

thank you @cmfcmf Christian for fixing this elusive problem!

@espaan
Copy link
Contributor

espaan commented May 21, 2014

👍

@Guite Guite modified the milestone: Discarded Tickets Aug 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants