So I decided to give codeigniter a chance and convert my existing site which is all custom php to the codeigniter framework. But trying to figure out how to do this best in codeigniter that I was doing from my original site. In the original site a person would visit a page such as index.php. In the index.php code its broken into sections like so (This is just a very simple example):
index.php:
Then in my main php file that is included in every single page I run a query that grabs all "modules" that are assigned to each section above for the index.php page. So give me all modules that are assigned to {$SECTION1}, {$SECTION2} and {$SECTION3} for index.php. A module in my original system is simply a php file that does a specific job so I might have a module called latest_story.php and in the script it gets the last 10 stories from the database and display the results.
latest_story.php
Then using output buffering I execute each module then take the outputted information from each module assigned to each section and replace that section with the outputted data.
Can this be done in codeigniter? If so can someone point me in the right direction in doing this in codeigniter?
<strong>EDIT</strong>
To give a more clear view of what Im doing in the original system I run a query on every single page to determine what "modules" to grab for the current page the person is viewing then run this code
Then I simply take each variable created for each section and replace {$SECTION[n]} with that variable in the template.
<strong>ADDITIONAL EDIT</strong>
What Im trying to do is be able to create "modules" that do specific tasks and then in the backend be able to dynamically place these modules in different sections throughout the site. I guess you can say its like wordpress, but a more simplier approach. Wordpress you can add a module and then assign it to your pages either in the left column, middle or right column. Im trying to do pretty much the same thing.
index.php:
Code:
<html>
<head></head>
<body>
<div id="top">{$SECTION1}</div>
<div id="main">{$SECTION2}</div>
<div id="bottom">{$SECTION3}</div>
</body>
</html>
Then in my main php file that is included in every single page I run a query that grabs all "modules" that are assigned to each section above for the index.php page. So give me all modules that are assigned to {$SECTION1}, {$SECTION2} and {$SECTION3} for index.php. A module in my original system is simply a php file that does a specific job so I might have a module called latest_story.php and in the script it gets the last 10 stories from the database and display the results.
latest_story.php
Code:
include('class/story/story_class.php');
$story = new Story($databaseconn);
$latest_story = $story->findLatestStory(10);
//If results back from $latest_story loop through it
//and display it however I want
Then using output buffering I execute each module then take the outputted information from each module assigned to each section and replace that section with the outputted data.
Can this be done in codeigniter? If so can someone point me in the right direction in doing this in codeigniter?
<strong>EDIT</strong>
To give a more clear view of what Im doing in the original system I run a query on every single page to determine what "modules" to grab for the current page the person is viewing then run this code
Code:
foreach($page_modules AS $curr_module)
{
$module_section = intval($curr_module->section);
$module_file = $global_function->cleanData($curr_module->modfile);
$module_path = MODS .$module_file;
if(is_file($module_path))
{
ob_start();
include($module_path);
${'global_pagemod' .$module_section} .= ob_get_contents();
ob_end_clean();
}
}
Then I simply take each variable created for each section and replace {$SECTION[n]} with that variable in the template.
<strong>ADDITIONAL EDIT</strong>
What Im trying to do is be able to create "modules" that do specific tasks and then in the backend be able to dynamically place these modules in different sections throughout the site. I guess you can say its like wordpress, but a more simplier approach. Wordpress you can add a module and then assign it to your pages either in the left column, middle or right column. Im trying to do pretty much the same thing.