Sidebar navigation display changes depending on which page the user comes in from?

Permalink
OK, I'm trying to set up navigation on a site that will, as the post title suggests, display a differnt set of links depending on which page the user comes in from.
I am new to C5 but I know some PHP(slightly beyond the basics), & I think I know in theory what needs to be done. It should be similar to a breadcrumb trail, but I'm not sure which files I need to alter.
Anyone any tips for this, I would be much obliged.

 
jordanlev replied on at Permalink Reply
jordanlev
When you say "a different set of links", do you mean something like "if they came from these pages, show set of links A, and if they came from other pages show set of links B", or do you mean that you want the nav menu to be entirely constructed of their browsing history on your site?
(Or something else entirely)?
michaelPassion replied on at Permalink Reply
Apologies for the ambiguity.
Exactly... '"if they came from these pages, show set of links A, and if they came from other pages show set of links B"'.
jordanlev replied on at Permalink Best Answer Reply
jordanlev
I would probably just put an "If" statement in your page type templates, like this:

<?php
$special_pages = array('http://domain.com/some-special-page', 'http://domain.com/another-special-page', 'http://domain.com/yet-another-page');
$is_special = in_array($_SERVER['HTTP_REFERER'], $special_pages);
if ($is_special || $c->isEditMode()) {
    $a = new Area('Nav 1');
}
if (!$is_special || $c->isEditMode()) {
    $a = new Area('Nav 2);
}


Note that I've put in a check for "isEditMode" so you can see both areas when you edit the page (so you can put the appropriate autonav blocks in them or whatever it is you want to show up for different people).
michaelPassion replied on at Permalink Reply
Thanks for the prompt reply.
I thought it was an if statement but didn't know where to put it.
I'm still trying to come to terms with C5's PHP, which incidentally, is some of the tidiest PHP I've ever seen.
Thanks again Jordan...