【问题标题】:Pass variable to CakePHP Helper inside the options array将变量传递给选项数组中的 CakePHP Helper
【发布时间】:2012-12-09 07:01:43
【问题描述】:

这是设置面包屑,但可以用于我假设的任何助手。我正在尝试链接到我在面包屑中查看的当前文章,但不确定如何在视图/ URL 之后添加帖子 ID,就像在它之前添加新闻标题一样?

$this->Html->addCrumb($news['News']['title'], array('controller' => 'news', 'action' => 'view/'$news['News']['id']));

【问题讨论】:

    标签: php cakephp helper


    【解决方案1】:

    我通常更喜欢 CakePHP 格式 :)

    $this->Html->addCrumb(
        $news['News']['title'], array(
            'controller' => 'news', 
            'action' => 'view',
             $news['News']['id']
        )
    );
    

    【讨论】:

      【解决方案2】:

      你的意思是:

      $this->Html->addCrumb(
          $news['News']['title'], array(
              'controller' => 'news', 
              'action' => 'view/' . $news['News']['id']
          )
      );
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-02-17
        • 1970-01-01
        • 1970-01-01
        • 2020-11-10
        • 2021-03-19
        • 2017-11-23
        相关资源
        最近更新 更多