|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
datenpunk Smarty Rookie
Joined: 17 May 2003 Posts: 6
|
Posted: Sat May 17, 2003 7:35 pm Post subject: User functions inside dynamic content + recursion |
|
|
Hello,
I'm just trying some template engines and ran into troubles with all of them.
Following problem:
A CMS. The editor adds content. This content may conain a user function like showArticle(artID)
Now this article has to be shown.
This article may also contain other user level functions like ShowImage(ImageID).
Problems with other engines:
phplib template engine support no user functions but supports showing undefined tags.
If I do a recursion through this undefined tags looking for certain strings "{showImage|234}" I am able to do what I want.
Con: Other template engines have a nicer api.
PEAR's IT[X], and Sigma support user functions but the content returned from this functions isn't parsed by the template engine as it seems.
So - my question:
Is it possible to do such things with smarty without problems?
Thanks in advance
Daniel Khan |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sat May 17, 2003 9:12 pm Post subject: |
|
|
yes, you can do such things. i don't know if "without problems": you give a lot of power to your editor if you let him add articles with full template-syntax.
see http://smarty.php.net/manual/en/plugins.resources.php if you want to treat content from a database as a smarty template, for example.
if you don't need that complex syntax, but just want to insert articles and images inside your {$content}, you can consider writing a modifier that searches for special markup and replaces it accordingly. that means less possibilities for the editor, but also less possibilities for errors.
see: http://smarty.php.net/manual/en/plugins.modifiers.php for that.
HTH
messju |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sat May 17, 2003 10:45 pm Post subject: |
|
|
To add to messju's comments, you can also separate the tasks of template layout and content insertion using different instances of Smarty to control each. That way you can use different security settings (which affects what is available to the template user) for each task. I actually do something similar to this since I like exploiting Smarty's capabilities for as many users as possible. |
|
Back to top |
|
datenpunk Smarty Rookie
Joined: 17 May 2003 Posts: 6
|
Posted: Mon May 19, 2003 10:11 pm Post subject: |
|
|
Thank's that helped a lot
Daniel Khan |
|
Back to top |
|
|
|
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
|