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 3660816
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:14:33+00:00 2026-05-19T01:14:33+00:00

So far I’ve been enjoying using CodeIgniter to create some simple web apps (really

  • 0

So far I’ve been enjoying using CodeIgniter to create some simple web apps (really just learning the framework), but I can’t figure out an easy way to create a block/module.

I would like to have have “Recent Images” block that I can drop on any page on the site without duplicating the query in each page’s controller and passing it to the template with $vars.

2 questions:

  1. I am using partials in the views
    already, but how do I write a
    partial that pulls from a controller
    other than the one specified by the
    url.
  2. How can I cleanly create a
    controller that pulls the data for
    that block and does not create a
    page for it.

This seems like it should be simple enough, I’m just not having any luck finding the proper solution on own. Thanks in advance.

  • 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-19T01:14:34+00:00Added an answer on May 19, 2026 at 1:14 am

    Okay, here’s my take on “widgets”, “modules”, “partial views” or whatever you want to call them. Either way we mean reusable items for pages.

    There are a bunch of different ways to do this so my way may not be for you – then again it might be just what you’re looking for!

    Firstly, I make the widgets as views, let’s say the paths would be like: views/widgets/myview.php

    I make the decision of what widgets I’m planning to use in my controller. My method is to put the paths to the views I want in an array like:

    $data['widgets'] = array('widgets/myview', 'widgets/myview2');
    

    Then when I load my main view (still in my controller) I do this:

    $this->load->view('main_view', $data);
    

    Now the widgets array is passed to the main view.

    Then in my main view when I get to the place where the widgets go, I loop through my array like this:

    foreach ($widgets as $widget)
    {
        $this->load->view($widget);
    }
    

    This loop is run in my main view. Conveniently, all the data you passed to the main view will be available in the nested views you load.

    I’ve made many widgets in Codeigniter this way and it’s the method I use in my CMS’s as well.

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

Sidebar

Related Questions

As far as I can tell, this is isn't possible, so I'm really just
So far, I'm using $(this).attr('class'); But I worry about compatibility because I know some
So far I have been using in tutorials, examples and sample code only packages
So far, my experience in web design has been with very small scale sites
As far as I know, they are absolute equal. However, browsing some django docs,
So far I haven't been able to find the specifications for the iPhone screenshots
As far as I know, function foo() { aaa(); } is just var foo
As far as I know, foreign keys (FK) are used to aid the programmer
So far I have encountered adjacency list, nested sets and nested intervals as models
As far as I know, Flash has to pass info off to another external

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.