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

#1
[eluser]the_unforgiven[/eluser]
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?

#2
[eluser]ppwalks[/eluser]
You can load other pages via functions if thats what your after for instance

[code]

function about_us() {

$this->load->view('about');

}
[code]

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

localhost/your_site/index.php/welcome/about_us

Is that what you was after or switching views via variable

#3
[eluser]the_unforgiven[/eluser]
Thats what im doing already so want to know if i do something e=like this:

Code:
<?php

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

#4
[eluser]ppwalks[/eluser]
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:

Controller

Code:
$data['main'] = 'home';
  $this->load->vars($data);
  $this->load->view('index');

index.php

Code:
<?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:

Code:
$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?

#5
[eluser]the_unforgiven[/eluser]
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

#6
[eluser]ppwalks[/eluser]
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?

#7
[eluser]the_unforgiven[/eluser]
So if i do
Code:
if($this->load->view($frontend) == 'home') {
show something
}
else {
show nothing
}

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

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

#8
[eluser]ppwalks[/eluser]
Have a look at this site to see if i'm right by what you want

http://www.venusstone.co.uk

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..

#9
[eluser]ppwalks[/eluser]
it is still in development

#10
[eluser]the_unforgiven[/eluser]
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.