Welcome Guest, Not a member yet? Register   Sign In
Help with linking categories
#1

[eluser]the_unforgiven[/eluser]
Hi all,

I'm building a site all is good so far but just com across a little problem....

I have some code grabbing the categories from the database which work just fine, but now I need the code to not only make a page dynamically but also use the path the user types in.

Here's a picture of the db table/row
http://www.imageupload.co.uk/files/3qd3i...a2s76c.png

And here's the code:

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {

// Construct Method
function __construct()
{
      parent::__construct();
   $data['cat'] = $this->MCats->getAllCategories(); //This is  the line getting the categroies

   $data['mainf'] = $this->products_model->getMainFeature();
   $skip = $data['mainf']['id'];
   $data['sidef'] = $this->products_model->getRandomProducts(1,$skip);
  
   $this->load->vars($data);
}
// Index
function index()
{
  $data['metadesc'] = '';
  $data['metakeywords'] = '';

  $data['content'] = 'home';
  $data['title'] = "Welcome";

  $this->load->view('template', $data);
}
// Pages
function pages($path){
  
     $page = $this->MPages->getPagePath($path);
  
  $data['title'] = $page['name'];

  $data['metadesc'] = $page['description'];
  $data['metakeywords'] = $page['keywords'];

  $data['page'] = $page;

  $data['content'] = 'page';
  $data['title'] = ucfirst($page['name']);

  $this->load->view('template', $data);
}


}

Model
Code:
function getAllCategories(){
     $data = array();
     $this->db->order_by('name','asc');
     $Q = $this->db->get('categories');
     if ($Q->num_rows() > 0){
       foreach ($Q->result_array() as $row){
         $data[] = $row;
       }
    }
    $Q->free_result();  
    return $data;
}

So based on this i have this then in my header:

Code:
<ul class="cats">
    <li class="cathead"><a href="">categories</a></li>
    &lt;?php foreach ($cat as $row) : ?&gt;
    <li class="subcats"><a href="&lt;?php echo base_url().strtolower($row['path']); ?&gt;">&lt;?php echo ucfirst($row['name']); ?&gt;</a></li>
    &lt;?php endforeach; ?&gt;
   </ul>

which shows the path from the URL but need it to make a dynamic page now, so i would one achieve this based on my code


Messages In This Thread
Help with linking categories - by El Forum - 05-01-2012, 12:40 PM
Help with linking categories - by El Forum - 05-01-2012, 01:04 PM
Help with linking categories - by El Forum - 05-01-2012, 01:15 PM
Help with linking categories - by El Forum - 05-01-2012, 01:36 PM
Help with linking categories - by El Forum - 05-01-2012, 01:41 PM
Help with linking categories - by El Forum - 05-01-2012, 01:53 PM
Help with linking categories - by El Forum - 05-01-2012, 01:55 PM
Help with linking categories - by El Forum - 05-01-2012, 02:03 PM
Help with linking categories - by El Forum - 05-01-2012, 02:07 PM
Help with linking categories - by El Forum - 05-01-2012, 02:11 PM
Help with linking categories - by El Forum - 05-01-2012, 02:17 PM
Help with linking categories - by El Forum - 05-01-2012, 02:19 PM
Help with linking categories - by El Forum - 05-01-2012, 02:21 PM
Help with linking categories - by El Forum - 05-01-2012, 02:22 PM
Help with linking categories - by El Forum - 05-01-2012, 02:24 PM
Help with linking categories - by El Forum - 05-01-2012, 02:27 PM
Help with linking categories - by El Forum - 05-01-2012, 02:28 PM
Help with linking categories - by El Forum - 05-01-2012, 02:31 PM
Help with linking categories - by El Forum - 05-01-2012, 02:34 PM



Theme © iAndrew 2016 - Forum software by © MyBB