2012-09-09 48 views
1

我想知道如何在沒有被轉義的情況下向cakephp url添加一個「#」。我試過'逃避'=>虛假,但沒有成功。我這樣做是爲了嘗試鏈接到包含註釋的頁面的id =「comments」部分。這裏是我的代碼鏈接:

<?php echo $this->Html->link($post['Post']['total_comments'].' comments', array('controller' => 'posts', 'action' => 'view', $post['Post']['slug'].'#comments'),array('class' => 'comments-icon')); ?> 

任何幫助,將不勝感激。

回答

6

試試這個:

echo $this->Html->link($post['Post']['total_comments'].' comments', array(
     'controller' => 'posts', 
     'action' => 'view', 
     $post['Post']['slug'], 
     '#' => 'comments' //Or #comments only without key 
    ), array('class' => 'comments-icon')); 
+0

感謝偉大的工作我都試過只是一切。 – Cameeob2003