Welcome Guest, Not a member yet? Register   Sign In
Include();
#11

[eluser]WebbHelp[/eluser]
aha, I think i put the code in my index function, if I did, wouldn't they be loaded directly?
#12

[eluser]WebbHelp[/eluser]
But waite waite waite....

My question was how to use the same design, and only change the contents, so I don't need to add the design code in every view document...
#13

[eluser]n0xie[/eluser]
It would still be easier if you actually showed us what you did...

Anyway they will load directly if you go to the the URL 'http://domain.tld/blog' or 'http://domain.tld/index.php/blog'
#14

[eluser]WebbHelp[/eluser]
Controller:
Code:
function Blog()
    {
        parent::Controller();
        
        $this->load->helper(array('form', 'url'));
        $this->load->library('form_validation');
    }
    
    function index()
    {
        
        $generalquery = $this->db->query("SELECT title,header FROM general ORDER BY id DESC LIMIT 1");
        if($generalquery->num_rows() > 0)
        {
            $row = $generalquery->row();
            
            $data['title'] = $row->title;
            $data['h1'] = $row->header;
            
        }
        
        $data['postquery'] = $this->db->get("inlagg");
        if($data['postquery']->num_rows() == 0)
        {
            echo 'Inga poster i databasen';
        }

        
        $this->load->view('blog_view', $data);
        
    }
    
    
    function add()
    {
        
        if ($this->form_validation->run() == FALSE)
        {
            
        }
        else
        {
            $insert = array(
               'rubrik' => $_POST['subject'] ,
               'message' => $_POST['message']
            );
            $this->db->insert('inlagg', $insert);
            
        }
        
        $this->load->view('add_view');
        
    }

showblogg:
Code:
<h1>&lt;?php echo '<h1 align="center">'. $header .'</h1>'; ?&gt;</h1>

&lt;?php

foreach ($postquery->result() as $row)
{
    echo '<h1>'. $row->rubrik . '</h1>';
    echo nl2br($row->message);
    echo '<hr />';
    
}

?&gt;

addblogpost:
Code:
&lt;?php echo validation_errors(); ?&gt;

&lt;?php echo form_open('form'); ?&gt;


Rubrik: &lt;input type="text" name="subject" /&gt;
<br><br>
Meddelande:<br> &lt;textarea name="message" cols="50" rows="7"&gt;&lt;/textarea>
<br>
<br>
&lt;input type="submit" value="Lägg till" /&gt;


&lt;/form&gt;




Theme © iAndrew 2016 - Forum software by © MyBB