user772900
user772900

Reputation: 431

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 back 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?

Upvotes: 2

Views: 2182

Answers (2)

Wil
Wil

Reputation: 540

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

Upvotes: 0

Arno
Arno

Reputation: 1253

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

Upvotes: 1

Related Questions