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

#11
[eluser]ppwalks[/eluser]
right i will post my code for you to look at:

if you use the index to swap files you can do it like this:
index.php - all views are in sub folder "main"
Code:
<?php $this->load->view('main/header'); ?>
     <div id="main-page">
         &lt;?php $this->load->view("main/".$main); ?&gt;
            </div>
            <br />
  </div>


&lt;?php $this->load->view('main/footer'); ?&gt;


So as I load the view say products my controller still loads the 960 wide view but I have split it as you would with html treat them indepentantly so my products page I simply call another view within the view.

so here is my products view

Code:
<ul id="venus-stone-products">
<li class="menu_sidebar">
     &lt;?php $this->load->view('main/main_sidebar'); ?&gt;
</li>
<li class="all_products">
  <h1 class="products-h1">All Products</h1>
         <ul id="all-product-view">
  &lt;?php
   if (count($products) > 0){
    foreach ($products as $key => $product){
    echo "<li class=\"product\"> \n";
    echo "<ul>";
    echo "<li class=\"left\">\n";
    echo "<img src=' ".base_url() .$product[' alt='".$product[' title='".$product['/><br /> \n";
    
    echo "<h2>".$product['name']."</h2>\n";
    
    echo "<span class=\"style\"><b>Style/ Colour:</b> " . $product['style'] . "</span><br />\n";
    echo "<span class=\"price\">Price: £" . $product['price'] . "</span><br />\n";
    echo "</li>\n";
    echo "<li class=\"right\">\n";
    echo "<h3>Quick Overview</h3>";
    echo  "<p>" .word_limiter($product['longdesc'], 50). "</p><br />\n";
     $moreInfo = array (
        'src' => base_url().'images/more-info-btn.png',
        'alt' => 'More Product Information',
                'class' => 'more-info-btn',
        );
    echo anchor('paving_stone/' . $product['id'] , img($moreInfo), array('title' => $product['name'], 'class'=>'more-info' ))."\n";
    ?&gt;
                <br />
                &lt;?php
                  $addCart = array (
        'src' => base_url().'images/add-to-cart-btn.png',
        'alt' => 'Add Product to Shopping Cart',
                'class' => 'shopping-cart',
        );
     echo anchor('cart/'.$product['id'],img($addCart), array('alt' => 'Add To Cart', 'class'=>'add-to-cart'));
        
        
    echo "</li>\n";
    echo "</ul>\n";
    echo "</li>\n";
    }
    } else {
     echo "<p class=\"no-records\">No Records found</p>";
     }
  ?&gt;
  </ul>
        <div id="pagin">
        &lt;?php echo $this->pagination->create_links(); ?&gt;
        </div>
</li>
</ul>

As you can see i have just loaded the view inside of the curent view
and will only load on that page providing you load the views dynamically like i previously have shown you

#12
[eluser]the_unforgiven[/eluser]
OK sweet, thanks for the help...makes much more sense now!!!

#13
[eluser]CroNiX[/eluser]
Code:
if ($this->uri->segment(1) == 'home' OR $this->uri->segment(1) === FALSE)
{
  //display something unique for homepage
}
else
{
  //display regular content
}

#14
[eluser]the_unforgiven[/eluser]
[quote author="CroNiX" date="1335378129"]
Code:
if ($this->uri->segment(1) == 'home' OR $this->uri->segment(1) === FALSE)
{
  //display something unique for homepage
}
else
{
  //display regular content
}
[/quote]

Works to a certain extent, but in my main controller called store the index function is the home page like so:
So segment(1) == 'home' doesnt work so what should i do based on what i said.
Code:
$data['title'] = 'Site Title';
$data['h1'] = 'Title';
$data['frontend'] = 'home';
$this->load->view('template', $data);

#15
[eluser]CroNiX[/eluser]
In your template view, would
Code:
if ($frontend == 'home')
work?

#16
[eluser]the_unforgiven[/eluser]
Chronix, cheers works a treat....


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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