Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Access custom block from custom function

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
SlowFox
Smarty Regular


Joined: 02 Oct 2006
Posts: 55

PostPosted: Sun Aug 04, 2013 4:15 pm    Post subject: Access custom block from custom function Reply with quote

I have a template like:

Code:
{inputform layout=Layout::Table}
   {formfield field=$field layout=Layout::Table}
{/inputform}


which does pretty much the obvious (i.e. creates an HTML form with a single input field according to the object $field and with a table layout).

Now the "layout" Parameter for smarty_function_formfield() - which adds some <tr><td></td></tr> - could be omitted, as it is content must always identical to the one used for smarty_block_inputform() - which creates a <table></table> infrastructure. The question is: how can I access the value of the surrounding block functions parameter from within the custom function? Is this possible at all? Up to now I only found the _tag_stack, which tells me the name of the surronding block, but this alone does not help.
Back to top
View user's profile Send private message
SlowFox
Smarty Regular


Joined: 02 Oct 2006
Posts: 55

PostPosted: Wed Aug 14, 2013 9:07 am    Post subject: Reply with quote

Hm. Stupid question? Stupid problem? Stupid else?
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Wed Aug 14, 2013 8:01 pm    Post subject: Reply with quote

It is not possible to get access to attributes of the surounding block in a direct way.

The {inputform} plugin could assign the layout attribute to a Smarty variable $layout.
{formfield} could read it with getTemplateVars()
See http://www.smarty.net/docs/en/api.get.template.vars.tpl
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General 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