doupian6118 2010-11-13 10:59
浏览 69
已采纳

在symfony中设置自定义错误重定向?

I am using Symfony 1.4 with Propel as ORM. I Have created a login system for my frontend page, where user can login and edit there account details.The page is set with Permission ="user" and Group ="user". But on loging in with a user which doesnot belong to this group, redirects to the symfonys default page(showing user dont have credentials to view this page). can these pages be customized and set our own custom messages..and how can we set custom error pages??

the code that i have used,

if($this->getContext()->getUser()->hasCredential("user"))
{
    $user_name=$this->getUser()->getGuardUser()->getUsername();
    $this->name=$user_name;
}
else
{
    $this->forward("userlogin", "error");
}

but i dont know this is the best way..

  • 写回答

2条回答 默认 最新

  • dph19153 2010-11-13 11:14
    关注

    You can change templates by overwriting them in Your app: apps/<appname>/modules/default/templates/error404Success.php

    To see list of possible templates look at: lib/vendor/symfony/lib/controller/default/templates/

    Now about credentials. At file apps/<appname>/config/settings.yml:

    # ...
    
    all:
      # ...
    
      .actions:
        login_module:           sfGuardAuth   # Change this to whatewer You want.
        login_action:           signin        # Change this to whatewer You want.
    
        error_404_module:       default       # Change this to whatewer You want.
        error_404_action:       error404      # Change this to whatewer You want.
    

    So if You want to change just template -- change just template. But if You want something more powerful -- change settings.yml and write custom code.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向