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

block function

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


Joined: 05 May 2004
Posts: 1

PostPosted: Wed May 05, 2004 8:11 pm    Post subject: block function Reply with quote

hi,
i'm writing a CMS in which some users have permission to do all, some others can only read the content (lol, great idea, isnt'it? =)..
users have a level from 0 (guest) to 3 (admin), so i was thinking to define something like a block whose content is shown only if your level is > 2, for example:

bla bla bla...
{block level="}
this is seen only by people with level >=2
{/block}
bla bla bla...

i'm new to smarty, so i didn't understand if i have to do this with blocks or it is completely wrong, can anyone put me on the right way?
i've tryed defining function_block_level($parms, $content, &$smarty) but i see always what i have between {block} and {/block}...
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed May 05, 2004 8:33 pm    Post subject: Reply with quote

[php:1:e913ca6abb]
function_block_level($params, $content, &$smarty, &$repeat) {
global $user;
if (isset($content)) {
return $content;
} elseif ($params['level'] > $user->level) {
$repeat = false;
}
}
[/php:1:e913ca6abb]

and, of course, register it with $smarty->register_block('block', 'function_block_level');
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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