CodeIgniter Forums
Creating a Basic CMS system - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Creating a Basic CMS system (/showthread.php?tid=12448)



Creating a Basic CMS system - El Forum - 10-19-2008

[eluser]edwin87[/eluser]
Hello CI!

First of all, i love the way CI stuck so much time in developing this framework.

I just started with CI, so i am very new in this. (Excuse me for my bad englishWink )

What i want is a basic cms system. I have already created a login script and every time my page load it will check if the session still exists.

This option i've built with a own controller, named: MY_Controller.

If i am logged succesfully, the page includes an header, so i don't have to include it in every specific controller.

But for now, i want to built a page module. So i can create/edit/delete pages. Here for i have a page controller what includes al the functions i need.

But this controller loads above the MY_Controller i think. When i want to show a basic text like 'hello world', then that text is above the included header file.

What did i do wrong in this matter?

I'm from Holland and my english is very very bad, so i hope that a fool can help me Wink


Edwin


Creating a Basic CMS system - El Forum - 10-20-2008

[eluser]Aken[/eluser]
Any content you want to display on a page should be inserted into a view, instead of directly from the controller. You insert any content via an array, and then pull the data inside the view.

Controller:
Code:
// Your header view would go here.

$data['text'] = "Hello, world!";

$this->load->view('view.php', $data)

view.php:
Code:
<p>&lt;?php echo $text; ?&gt;</p>



Creating a Basic CMS system - El Forum - 10-20-2008

[eluser]Mirage[/eluser]
Quote:Any content you want to display on a page should be inserted into a view, instead of directly from the controller. You insert any content via an array, and then pull the data inside the view.

That's not the only way. You can also draw the view data from the Model directly and via View helpers.


Cheers-
m


Creating a Basic CMS system - El Forum - 10-20-2008

[eluser]edwin87[/eluser]
I already tried that before. But still that content echo's above the included header.
Maybe i don't understand the procedure of CI but here's a example.


In the folder libaries i have the following file: MY_Controller.php

Code:
&lt;?php
class App_Controller extends Controller {

    
    function App_Controller()
    {
        parent::Controller();
        
        $this->load->helper('url');
        $this->load->helper('form');
        
        $allowAcces      =     false;    // Zet standaard op false
        $remoteAdress    =    NULL;
        
        $allowAcces        = $this->session->userdata['logged'];    // Haal sessie op
        $remoteAdress    = $this->session->userdata['ipAdress'];    // Controleer of sessie wel gebruik maakt van het zelfde IP wanneer het werd aangemaakt.
                
        if($allowAcces === true && $remoteAdress == $_SERVER['REMOTE_ADDR']){        
            
            $data['userInfo']    =    $this->getUserInfo($this->session->userdata['userID']);
                
            $this->load->view('header',$data);
            
            
            
        }else{
            $this->load->view('main/login_view');
        }
        
        
    }

?&gt;


The header file look like this:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Webmanager&lt;/title&gt;
&lt;link rel="stylesheet" type="text/css" media="all" href="&lt;?php echo base_url();?&gt;system/application/resources/css/stylesheet.css" /&gt;
&lt;/head&gt;

&lt;body&gt;

<div id="container">
    <div id="header"><div class="logged">Ingelogd - &lt;?php echo $userInfo; ?&gt;<br />&lt;?php echo anchor('main/logout', 'Afmelden');?&gt;</div></div>
    
    
    <div id="menu">
        <ul>
            <li>&lt;?php echo  anchor('','Home');?&gt;</li>
            <li>&lt;?php echo  anchor('page/view','Pagina');?&gt;</li>
            <li>&lt;?php echo  anchor('menu/view','Menu');?&gt;</li>
        </ul>
    
    </div>
    
    <div id="content">

So if i click on 'Pagina' in the menu structure. I want to open that page view beneath <div id="content"> but it now opens above the source.

Like

Code:
[b]I want to open the page file[/b]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Webmanager&lt;/title&gt;
&lt;link rel="stylesheet" type="text/css" media="all" href="&lt;?php echo base_url();?&gt;system/application/resources/css/stylesheet.css" /&gt;
&lt;/head&gt;

&lt;body&gt;

<div id="container">
    <div id="header"><div class="logged">Ingelogd - &lt;?php echo $userInfo; ?&gt;<br />&lt;?php echo anchor('main/logout', 'Afmelden');?&gt;</div></div>
    
    
    <div id="menu">
        <ul>
            <li>&lt;?php echo  anchor('','Home');?&gt;</li>
            <li>&lt;?php echo  anchor('page/view','Pagina');?&gt;</li>
            <li>&lt;?php echo  anchor('menu/view','Menu');?&gt;</li>
        </ul>
    
    </div>
    
    <div id="content">

You see 'I want to open the page file' above the source, now i want it beneath <div id="content">

How can i make this happen? Maybe im wrong with the whole structure but can somebody help me with this?