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

Resource plugins can't get compile_id?

 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
Okamura
Smarty n00b


Joined: 24 May 2011
Posts: 3
Location: Tokyo/Japan

PostPosted: Tue May 24, 2011 10:34 am    Post subject: Resource plugins can't get compile_id? Reply with quote

I make resource plugin now.
But plugin can't get compile_id???
How I get compile_id from {include} in resource plugin?


example)

a.php-----
$smarty->compile_id=111;
$smarty->fetch('a.tpl');
------------

a.tpl-------
{include file='example:b.html' compile_id=222}
------------

resource.example.php--------
function smarty_resource_example_source($tpl_name, &$tpl_source, $smarty)
{
// How I get compile_id from {include} at here?
// $smarty->compile_id is 111
}

----------------------------------
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Tue May 24, 2011 6:34 pm    Post subject: Reply with quote

Currently the compile_id of the {include} is not available in the resource as the template object isn't passed to the resource plugin.

For what reasion do you need it in the resource?
Back to top
View user's profile Send private message
Okamura
Smarty n00b


Joined: 24 May 2011
Posts: 3
Location: Tokyo/Japan

PostPosted: Wed May 25, 2011 2:14 am    Post subject: Reply with quote

Thank you for the reply.

I make CMS like Movable Type now.
There is blogs in a CMS, and each blog has other templates.
I want to make that each blog can include template of other blog.

Example:
Blog A template------------------
compile_id approach
{include file='CMS:header.html'} -> blog A's template
{include file='CMS:header.html' compile_id='a'} -> blog A's template
{include file='CMS:header.html' compile_id='b'} -> blog B's template

Other approach 1...
{include file='CMS:header.html'} -> conflict in template_c/
{include file='CMS:A:header.html'} -> ":" causes file output error
{include file='CMS:B:header.html'} -> ":" causes file output error

Other approach 2...
{include_cms file='header.html'} -> blog A's template
{include_cms file='header.html' blog='A'} -> blog A's template
{include_cms file='header.html' blog='B'} -> blog B's template
{* {include_cms} calls {include} internally. *}
---------------------------------

I think approach 2 is better.
But I don't know way to call function {include} in Template Function Plugin, excluding {function}.
Therefore, I try compile_id approach.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Wed May 25, 2011 4:47 pm    Post subject: Reply with quote

To get the output of a template with a plugin use the fetch() method.
Back to top
View user's profile Send private message
Okamura
Smarty n00b


Joined: 24 May 2011
Posts: 3
Location: Tokyo/Japan

PostPosted: Fri May 27, 2011 10:48 am    Post subject: Reply with quote

Thank you.
I will try to do.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins 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