开发者

cakephp back button issue

i am working on social network website where user can navigate to the album view page in many ways. for example.

  1. myprofile>> Gallery index page >> Album view page.
  2. myprofile>> Gallery details page >> Album view page.

In first case bac开发者_如何转开发k button should go to gallery index page and In second case it should go to Gallery details page.

Is there any way to add link to back button path dynamically in cakephp?


You could try using a breadcrumb-like session array. With every view you can pop a path onto the stack, and access the stack in the view (via the Session Helper) and construct the back button that way.

The stack could be as simple as a single parameter, or an array of controller, action and parameter variables to construct the path, depending on how much detail you need.

Edit: You could also use Neil Crookes' History Component: https://github.com/neilcrookes/cakephp-bits/blob/master/history_component/controllers/components/history.php


Use the breadcrump methods in the Html helper.

In your layout:

 echo $this->Html->getCrumbs(' > ','Home');

In your view:

$this->Html->addCrumb('Users', '/users');
$this->Html->addCrumb('Add User', '/users/add');

In each of your views, you can add in a new crumb, or the chain of crumbs to be able to see a history of your actions.

More here: http://book.cakephp.org/view/1653/Creating-breadcrumb-trails-with-HtmlHelper

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜