Welcome Guest, Not a member yet? Register   Sign In
Loading modules per page using CI
#1

[eluser]Sillysoft[/eluser]
Ok getting confused on how to use CI to do this. Im planning to use CI for my next big project but trying to figure out how to do this in CI.

In my current non CI site I have a template that I use, inside that html template I specify sections like so:

Code:
<html>
<head></head>
<body>
<div id="column_left">&lt;?php echo $section1; ?&gt;</div>
<div id="column_middle">&lt;?php echo $section2; ?&gt;</div>
<div id="column_right">&lt;?php echo $section3; ?&gt;</div>
&lt;/body&gt;
&lt;/html&gt;

When a visitor visits my site I load this template and query the database to find all "modules" that I have assigned in the db to each of those sections above. All a module is, is a php script that specifically does a action such as read_rss.php. This php file reads an rss feed and displays the results. Or I could have a stories.php file that queries my db for stories that display the last 10. I simply grab those files and using output buffering do the following:

Code:
foreach($page_modules AS $curr_module)
    {

        $module_section = intval($curr_module->section);
        $module_file = $curr_module->modfile;
        $module_path = MODS .$module_file;

        if(is_file($module_path))
        {

            ob_start();
            include($module_path);
            ${'section' .$module_section} .= ob_get_contents();
            ob_end_clean();

        }

    }

This loops through each php script, includes it and gets the contents of the include and assigns it to the proper variable which could be $section1, $section2 or $section3 depending on where it was assigned to in the db. So $section1 might have 5 modules assigned to it then $section2 could have 10 modules assigned to it and so on. How could I do something like this in CI?


Messages In This Thread
Loading modules per page using CI - by El Forum - 06-20-2011, 05:44 PM
Loading modules per page using CI - by El Forum - 06-20-2011, 06:10 PM
Loading modules per page using CI - by El Forum - 06-20-2011, 06:15 PM
Loading modules per page using CI - by El Forum - 06-20-2011, 06:41 PM
Loading modules per page using CI - by El Forum - 06-20-2011, 07:13 PM
Loading modules per page using CI - by El Forum - 06-20-2011, 11:31 PM
Loading modules per page using CI - by El Forum - 06-20-2011, 11:34 PM
Loading modules per page using CI - by El Forum - 06-20-2011, 11:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB