开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜