• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wanted to verify syntax.

<?php if (($this->uri->uri_string() == '' || $this->uri->uri_string() == '/homepage') && $intranetContest == 'on') { ?>

Basically, the homepage is either http://intranet/ or http://intranet/homepage ... so if the contest is "on" and either statement is true, the above works. I just wanted to verify the syntax.

Did I get it right or is the a better way to write it?

Your syntax should be right (maybe you need to remove the leading / at '/homepage' though, I'm not quite sure).

However, I'd recommend using

<?php if ( $this->uri->rsegment(1) == 'homepage' && $intranetContest == 'on' ) : ?>

since it's easier readable, faster written and less error prone.

This will work if and only if we're assuming that 'homepage' is your default_controller as set in config/routes.php and all requests to that page aren't routed any further. The 'r' in front of 'segment' is wanted to use the routed segments, otherwise, if there was no URI given, 'segment(1)' would return an empty string while 'rsegment(1)' returns 'homepage'.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.