Jump to content

Hiding menu based on URL


madsovenielsen

Recommended Posts

Hey.

<?php								// Remember to change this when the page goes live!!	// Show or hide the privat / erhverv menu based on URL								 	$protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';	$protocol = $protocol . '://'. $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];	if($protocol !== "http://www.alarm-selskabet.dk/drupal/" || "http://alarm-selskabet.dk/drupal/")	{			$privatErhverv = "";	}	if($protocol == "http://www.alarm-selskabet.dk/drupal/" || "http://alarm-selskabet.dk/drupal/")	{			$privatErhverv = '<div id="privat_erhverv"><div class="static_menu"><h2>Privat</h2><a href="node/3"><img src="themes/alarmselskabet/images/privat.jpg" alt="" /></a></div><div class="static_menu"><h2>Erhverv</h2><a href="node/4"><img src="themes/alarmselskabet/images/erhverv.jpg";" alt="" /></a></div></div>';	}						?>

I echo out the $privatErhverv variable further down the page.But it doesent work. the $privatErhverv variable gets echoed no matter what./mads

Link to comment
Share on other sites

   // Remember to change this when the page goes live!!	// Show or hide the privat / erhverv menu based on protocol									$bHTTPS = $_SERVER['HTTPS'] == 'on';if ($bHTTPS)			$privatErhverv = '<div id="privat_erhverv"><div class="static_menu"><h2>Privat</h2><a href="node/3"><img src="themes/alarmselskabet/images/privat.jpg" alt="" /></a></div><div class="static_menu"><h2>Erhverv</h2><a href="node/4"><img src="themes/alarmselskabet/images/erhverv.jpg";" alt="" /></a></div></div>';		else			$privatErhverv='';

Another solution would be to use a RewriteCond and RewriteRule to redirect all HTTP requests to HTTPS.RewriteEngine OnRewriteCond %{HTTPS} !onRewriteRule http://(.*)$ https://$1 [L,R=303]Not testedhttp://httpd.apache.org/docs/2.1/mod/mod_r...tml#rewritecond

Link to comment
Share on other sites

Hi!Try This Code:<?php // $_SERVER["HTTPS"] It'll Work Only On FTP Server, Not Local Web Server. May Be, But Not 100% Sure.// Try This Another Method To Get SERVER PROTOCOL To Check HTTP Or HTTPS Versions.// I Just EXPLODE It's Version To $_SERVER['SERVER_PROTOCOL'].// And Return PROTOCOL (https or http).$protocol = explode("/", $_SERVER['SERVER_PROTOCOL']);$protocol = $protocol[0];$protocol = $protocol . '://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];if($protocol !== "https://www.alarm-selskabet.dk/drupal/" || $protocol !== "http://www.alarm-selskabet.dk/drupal/" || $protocol !== "https://alarm-selskabet.dk/drupal/" || $protocol !== "http://alarm-selskabet.dk/drupal/"){$privatErhverv = '$privatErhverv Is Blank.'; // I Set Default Text// For Testing, Printprint $privatErhverv;}else{$privatErhverv = '<div id="privat_erhverv"><div class="static_menu"><h2>Privat</h2><a href="node/3"><img src="themes/alarmselskabet/images/privat.jpg" alt="" /></a></div><div class="static_menu"><h2>Erhverv</h2><a href="node/4"><img src="themes/alarmselskabet/images/erhverv.jpg";" alt="" /></a></div></div>';// For Testing, Printprint $privatErhverv;}?>Thnx & Regards: Hungry Mind (http://hungrymind.tk/)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...