开发者

Zend Framework - creating a smart back button

I would like to have a button that depending开发者_高级运维 on where the user was on the site, it calls the appropriate controller and action.

I have a page with a back button.

People can arrive on that page trough:

a) link on the homepage. OR b) trough a link on another page (inside the same site).

If the user comes from the homepage, the back button should point to that controller and action.

If, however, the user comes from that other page, the back button should point to another controller and action.

How can we accomplish something like this?

Thanks a lot,

MEM

ps - History Back is of no use, because we cannot allow that button to link to an external site.


Well, if you can't use javascript to go back in the history, then you have an undefined case when some external site leads directly to the page. Let's assume that if the user arrived at the page via an external site, the back button should simply not appear.

Consider checking the $_SERVER['HTTP_REFERER'] and constructing the back button link based on that. Inspect the referer (parse_url() may be of particular service here), if it's not your domain, don't display the button, otherwise, pick someplace to send the user "back" to (probably just the whole referer URL).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜