CodeIgniter Forums
Any integrated way in CodeIgniter how to check if I am on a homepage? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Any integrated way in CodeIgniter how to check if I am on a homepage? (/showthread.php?tid=51728)



Any integrated way in CodeIgniter how to check if I am on a homepage? - El Forum - 05-15-2012

[eluser]term25[/eluser]
I mean I am looking for CI equivalent of WP is_home() or is_front_page() function?

Is there something like that? I mean I would like to do something simple such as:

Code:
<?php if(is_home()) echo 'This is homepage'; ?>

Thanks in advance.



Any integrated way in CodeIgniter how to check if I am on a homepage? - El Forum - 05-15-2012

[eluser]Aken[/eluser]
There's no specific function for that, but you can create a helper to do it. You'd use something like $this->uri->uri_string() to see what the current URL is, and compare that to what your homepage URL woud be (typically an empty string, or "index.php").


Any integrated way in CodeIgniter how to check if I am on a homepage? - El Forum - 05-15-2012

[eluser]term25[/eluser]
Thanks it is working Wink :

Code:
if($this->uri->uri_string() == '') echo 'This is homepage');


I will create a helper for future use.