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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:49:19+00:00 2026-06-15T04:49:19+00:00

In a controller class I have this function: public function index(){ $this->load->helper(‘url’); $data[‘title’] =

  • 0

In a controller class I have this function:

public function index(){
    $this->load->helper('url');
    $data['title'] = 'News archive';
    $this->load->view('news/index', $data);
}

I load helper url because I’m using anchor() in news/index. So seems like it’s enough to load helper in the parent function, and I don’t have to load it inside news/index.

So my question is what’s going on underneath CI that lets me do this? Is load->view a function, or is it pasting the result of executing news/index on $data? How is load->view aware of helper url having been loaded in index? I’m still trying to make sense of how the CI framework works.

Also what would be the best place to load helper, in the constructor, or in each function as we need it?

  • 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-06-15T04:49:21+00:00Added an answer on June 15, 2026 at 4:49 am
    Also what would be the best place to load helper, in the constructor, or in each function as we need it?
    

    As a rough rule of thumb;

    • If you use the helper once in a controller – place it in that specific function
    • If you use the helper in multiple places in a controller – place it in that controllers constructor
    • If you use the helper in multiple places in multiple controllers – place it in the ‘autoload’ section once.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this controller: public class StandingsController : Controller { public ViewResult Index(int id)
This is what I have: class Calendar extends CI_Controller { public $extension; function __construct()
I have a controller that looks like this: public class PageController : Controller {
I have a Controller with syntax like this: public class CrudController<TEntity> : Controller Now
I have a MY_Controller class with this property: class MY_Controller extends CI_Controller { public
I have this controller in Code Igniter that begins with class MyController extends CI_Controller
I have a class like this: abstract class CrudResource extends Controller { type ResourceIdType
Say I have a class ObjectA (a view controller for example), that does this
I have a controller with a action similar to this class EventsController < ApplicationController
Given I have a controller class as such: public class ResourceController : AuthorizedController {

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.