Good day!
The man went to the friends page, then went online, chose a friend there, you need to make links like Friends-> Online-> Ivan Ivanov, that is, you need to form a return path, write links on each page, or how? Tell me please. And if you do this? for example in GET - action=friends§ion=online;

 $action = array("friends"=>"Друзья","setting"=>"Настройка"); $other = array("section"=>array("online"=>"Онлайн","offline"=>"Оффлайн")); echo '<a href="?action="{$_GET['action']}">{$action[$_GET['action']]}</a> / <a href="">?action="{$_GET['action']}>{$action[$_GET['section']]}</a>'; 
  • Offtop you yourself will be so comfortable? For example, I read the code - and already forget what is where. About MVC heard? It will be useful to hear)) - BOPOH

1 answer 1

To form a return path, you can connect the tree structure of the site. From there, pull out the "bread crumbs" - just what you have depicted.

The simpler the tree and the fewer dependencies, the easier it is to automatically generate this navigation item.

example:

 array( 'friends'=>array( 'online', 'offline' ), 'settings'=>array( 'security', 'profile', ) ); $_SESSION['path'] .= '/'.$current_page; //$current_page получаем так или иначе из get, например, при использовании mod_rewrite для ЧПУ. 
  • See addition - angers777
  • one
    If you keep the navigation path in the session, it is definitely not a string, because after FRIENDS-ONLINE-FRIENDS-ONLINE, etc. you yourself will not be happy. If stored in a session, then store the array - where they were and where they came from. And on each page to remove not only the loop, but also the "invisible" loop. Those. for example, they got MAIN - FRIEND - ONLINE, and then went through the menu to the settings. The path must not be MAIN - FRIEND - ONLINE - OPTIONS, but MAIN - OPTIONS, since OPTIONS refers to MAIN, not ONLINE - BOPOH
  • about additions: this is possible if the path in the address bar exactly matches the positions in the crumbs. I will give an example:? Section = catalog & product = 255 & model = 2 Should appear as> Catalog / Vacuum cleaners / Without-Bag-For-Dust-collecting / MANUFACTURER_NAME / MODEL (255) / VARIATION (2) So if everything is as you describe, then you lucky. Otherwise, I already asked about it. Approximately here: hashcode.ru/questions/182384/php- random- menu-site in brief: the site needs at least 4 independent menus for acceptable display flexibility. - knes