CakePHP links in same page
I am trying to build a FAQ page, with table of contents on top and answers below it. I would like to click on a question from the table of开发者_JS百科 contents and link on the same page to the corresponding answer. How can I do this in CakePHP, by using $this->Html->link()
method?
Thank you!
use something like this for the link:
$this->Html->link($question_title, $this->here . '#question-' . $question_id);
and then for later down the page put the answers in something like
<div id="question-<?php echo $question_id; ?>"><?php echo $answer_text; ?></div>
obviously the vars will be something like $question['Question']['title']
in cake and the Html->link url could be done with an array like
$this->Html->link($question_title, array('action' => 'faq', '#' => 'question-' . $question_id));
just as long as the url part before the # exactly matches the current url.
精彩评论