• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
if page is equal to home

Hi all,

I am wanting to know how to achieve this:

If the home page in views home.php is been displayed show something if it's not the home page then done dont show.

BUt with it not coming a database and just using view file how would this be acheived?

You can load other pages via functions if thats what your after for instance


function about_us() {



This will load a file called about.php in the views and will be accesible through domain such as


Is that what you was after or switching views via variable

Thats what im doing already so want to know if i do something e=like this:


if ($this->function->home_page() == true) {
echo 'this';
else {
do this

Whats the reason for this, i'm struggling to understand your logic, if you want a process on the home page create a model and load it then call it on the view, sorry just not quite getting what your after.

Are you on about using the index.php as a controller and switching templates from there if so you would have something like this:


$data['main'] = 'home';


<?php $this->load->view("main/".$main); ?>

then you can switch the pages:

So for the first example it will load home.php through $main declared in ['main']

You would then load a function from the model to do what you want on the homepage - so say you want a random feature to display you would then:

$data['your_variable_to_load_to_view'] = $this->ModelName->ModelFunction();

Then that will run any logic you want if its unique to the home page

Is this correct?

My logic is to basically saying if its the home home page show the right side navigation if its not the home page then dont show anything

Ahh with you now its really easy actually,

when I load the views in the index.php I switch them like I have shown you, I have created a site which I think is what you are after, on my home page I have no sidebar but on displaying products I do and I have done that using the method above:

As I load $main in the index.php it has the full width of the page and then in other pages (views) I simply use $this->load-view('view-name'); and load it as a sidebar but declare it in my controller by switching variables.

the logic above will work do you want me to provide an example?

So if i do
if($this->load->view($frontend) == 'home') {
show something
else {
show nothing

and in my controller i have the var $frontend like so:

public function index()
  $data['title'] = 'Page Title';
  $data['h1'] = 'Welcome';
  $data['frontend'] = 'home';
  $this->load->view('template', $data);

Have a look at this site to see if i'm right by what you want


the home page has no sidebar but if you click on the products tab at the top you will see that this page has one, have a look and see if thats what you are after..

If so i'll help you..

it is still in development

Yes exatly that....can you shed some light on how you acheived it?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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