开发者

show different views for different users with different permissions

i'm developing a social net like website and i have some trouble in how to manage views for different kind of users. i have several pages that it's开发者_如何学编程 content and resulting views depends on the users permissions. for example if user is a member of a group(has membership credential) can see so many things in that group page , but if he is not, the template should be so many different.

the simplest way is to control each part of the page with IF structure . but it's kind of nasty and i don't like it.

do you have any better idea or ifs are best solutions for these kind of situations.

thanks for your help.


It kind of depends on how you would like to create your templates. :-)

  1. Combine slots, partials and components. This is probably the easiest and most 'readable' solution. It separates the logic in easy reusable blocks.
  2. You could create seperate layouts, and call <?php decorate_with('template_user'); ?> in your template (add the if-statements to a partial and include the partial)
  3. or create your own base actions class, which in the preExecute() sets the template (this->setLayout('template_user'))
  4. Create separate actions, and forward the user based on it's permissions.

I'd go for the first :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜