Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6062093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:00:42+00:00 2026-05-23T09:00:42+00:00

So I decided to give codeigniter a chance and convert my existing site which

  • 0

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:

<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

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?

EDIT

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

    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.

ADDITIONAL EDIT

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:00:43+00:00Added an answer on May 23, 2026 at 9:00 am

    Basically, Codeigniter is an MVC framework. To use it, you really want to embrace that rather than include files. You can rejig your code as:

    In your controller:

    function example()
    {
    
      $this->load->model('story_model','story');
      $data['section1'] = $this->story->latest();
      $data['section2'] = $this->story->top_stories(5);
      $data['section3'] = $this->story->most_popular();
      $this->load->view('example', $data );
    }
    

    In your model:

    function latest()
    {
      return $this->db->limit(1)->get('stories');
    }
    etc.
    

    In your view:

    <html>
    ....
    <div id="latest">
    <h2><?php echo $section1->title; ?></h2>
    <?php echo $section1->body; ?>
    </div>
    <div id="top">
    <?php foreach $section2 as $popular { ?>
    <h2><?php echo $popular->title; ?></h2>
    <?php echo $popular->body; ?>
    <?php foreach} ?>
    </div>
    </html>
    

    If you wanted a second page, with different content but the same layout, you’d add this to your controller:

    function second_page()
    {
    
      $this->load->model('tags_model','tag');
      $this->load->model('authors_model','author');
      $data['section1'] = $this->tag->latest();
      $data['section2'] = $this->tag->top_tags(5);
      $data['section3'] = $this->author->most_popular();
      $this->load->view('example', $data );
    }
    

    and add in new models etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to WPF programming and decided to give it a shot by trying
I have decided to take up f# as my functional language. My problem: Give
I decided to install APC to speed up the site that I work for.
I decided to give Nokogiri a try, and copied the following program straight from
I decided to give CodeRush/Refactor a go (after a rial of Resharper) and one
[I've decided to give IntelliJ another go (to replace Eclipse), since its Groovy support
I am new to Silverlight and have decided to give it a go. I
I'm new to python an I decided to give it a try with TG2
I've been reading about Happstack and decided to give it a shot. I'm running
When does OS X decide to give your app a spinning beach ball? What

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.