Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Smarty 3 -> compiling under windows problem?

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
gardiol
Smarty Rookie


Joined: 08 Mar 2010
Posts: 12

PostPosted: Thu Jun 10, 2010 1:01 pm    Post subject: Smarty 3 -> compiling under windows problem? Reply with quote

While on linux everything works fine... on Windows, instead I get thi error:

Code:

An error has occured:

rename(C:\xampplite\htdocs\templates_c\wrtBE5.tmp,C:\xampplite\htdocs\Engine\..\templates_c\50e5b01ac27770754bed172a46f08ffbb6fbe33c.inline.{include file="core:box" atom_id=$data.contents}.php) [function.rename]: No such file or directory (2)
At position:

C:\xampplite\htdocs\Engine\Libs\Smarty\libs\sysplugins\smarty_internal_write_file.php, 41.


Template code is:

Code:

{include file="core:box" atom_id=$atom_id}


Where "core" is my own resource defined as follow:

Code:

function smarty_resource_core_source($tpl_name, &$tpl_source)
{
   if ( $tpl_source = file_get_contents( BASEPATH."Templates".DIRECTORY_SEPARATOR."$tpl_name.tpl" ) )
      return true;
   return false;
}


I think the problem is related to the very strange filename (the one with {} inside) which is NOT a valid windows filename, i believe...

What can i do to fix this?

(ps: this is from SVN).

This is fairly important... i do not use Smarty 3 on production yet, but on a new project that is supposed to be multi-platform... so if this cannot be solved i have to ditch Smarty3, and i need to know sooner than later!

thanks!
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7365
Location: Lincoln Nebraska, USA

PostPosted: Thu Jun 10, 2010 1:45 pm    Post subject: Reply with quote

something isn't right here. In side your resource function, what is the value of $tpl_name ? it should be "box"
Back to top
View user's profile Send private message Visit poster's website
gardiol
Smarty Rookie


Joined: 08 Mar 2010
Posts: 12

PostPosted: Thu Jun 10, 2010 1:52 pm    Post subject: Reply with quote

Yes, i can confirm, it is "box"...

Quote:

var_dump( $tpl_name ); == gives output to ==> string(3) "box"
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5067
Location: Hamburg / Germany

PostPosted: Thu Jun 10, 2010 6:05 pm    Post subject: Reply with quote

Yes, the file name is strange and incorrect.

Did you define another custom resource with name "inline"?

From what type of template resource is {include file="core:box" atom_id=$atom_id} called?
Back to top
View user's profile Send private message
gardiol
Smarty Rookie


Joined: 08 Mar 2010
Posts: 12

PostPosted: Fri Jun 11, 2010 6:50 am    Post subject: Reply with quote

Yes, i had a resource called "inline"... now i have renamed it to "hardcoded", to avoid any clashes.

Unfortunately, the problem is still there, absolutely identical.

In my application i have defined three type of resources:
- core (for main templates, in a specific folder)
- box (for plugins, in a different folder)
- hardcoded (for inline very short templates)

And i _only_ use these resources to call templates.

It is basically a "core" template calling another "core" template.

The "core:html" is this:

Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="{$lang}" xmlns="http://www.w3.org/1999/xhtml" xml:lang="{$lang}">
<head>
<meta http-equiv="content-language" content="{$lang}" />
<meta http-equiv="Content-Type" content="text/html" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta name="robots" content="all" />

<meta name="description"  content="{$description}"   />
<meta name="keywords"  content="{$keywords}"   />

<link hreflang="{$lang}" />
<link rel="stylesheet" href="{$stylesheet}" type="text/css" />
<link rel="stylesheet" href="Theme/default/jquery-ui-1.8.custom.css" type="text/css" />

<title>{$title}</title>

{foreach from=$head_scripts item=xxx}
<script type="text/javascript"  src="{$xxx}"></script>
{/foreach}

</head>
<body>

<span class="management">
   <input type="checkbox" id="mgm" />
   <label for="mgm">Management</label>
<div id='mgm_tabs' style="display:none;">
<div>
   <h3><a href="#">{$login_caption}</a></h3>
   <div>
   {include file=$login_template}
   </div>
   {foreach from=$management_tabs item=tab}
      <h3><input type="hidden" value="{$tab.data}" /><a href="#">{$tab.caption}</a></h3>
      <div></div>
   {/foreach}
</div>
</div>
</span>

{include file="core:box" atom_id=$content}

<script type="text/javascript">
{$jquery_init}
</script>

</body>
</html>


And "core:box" is:

Code:

{if $atom_id}
{getAtomData atom_id=$atom_id}

   {if $atom_valid}
      <div class="box" style="{$atom_data[$atom_id].css_text}">
      {if $atom_data[$atom_id].auth === true}
         <input type="hidden" value="{$atom_id}" />
         {if $atom_data[$atom_id].edit_type == "inline"}
            <div class="edit_inline" style="position: relative;">
            {$atom_data[$atom_id].title.text}
            </div>
         {/if}
         {if $atom_data[$atom_id].edit_type == "popup"}
            <div class="edit_popup" style="position: absolute; display:none;">
            {$atom_data[$atom_id].title.text}
            </div>
         {/if}
      {/if}

      {if $atom_data[$atom_id].title.show === true}
      <h1>{$atom_data[$atom_id].title.text}</h1>
      {/if}

      {include file=$atom_data[$atom_id].template
            data=$atom_data[$atom_id].data
            children=$atom_data[$atom_id].children
            auth=$atom_data[$atom_id].auth}

      </div>
   {/if}
{/if}



I call the "html:core" with a
Code:
 $smarty->display("core:html");


(btw, you can download the entire source code from

http://code.google.com/p/wysee-web/downloads just download 2010 june 11 tarball)
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5067
Location: Hamburg / Germany

PostPosted: Fri Jun 11, 2010 1:07 pm    Post subject: Reply with quote

I looks like that there is a problem when templates get call by nested different custom resources.

Thanks for your provided coded. If will try to fix this ASAP.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5067
Location: Hamburg / Germany

PostPosted: Fri Jun 11, 2010 2:45 pm    Post subject: Reply with quote

The problem was caused by your resource plugin "hardcoded" which should handle strings as template source.

Smarty3 does expect a resource name and template name in a call of a custom resource like

Code:
{include file='resource_name:template_name'}


In your case template_name is a template source string. Smarty3 did try to build a file name for a compiled template from it, which failed.

For string resources Smarty3 has a buildin resource "string". Use that instead of your hardcoded plugin.

Code:
{include file='string:template_source'}
Back to top
View user's profile Send private message
gardiol
Smarty Rookie


Joined: 08 Mar 2010
Posts: 12

PostPosted: Fri Jun 11, 2010 2:48 pm    Post subject: Reply with quote

Ok, thanks!

pity on me, then, ouch!

I didnt read about the string resource. Always trying to reinvent the weel, here...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3 All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP