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

  • SEARCH
  • Home
  • 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 9115447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:26:05+00:00 2026-06-17T04:26:05+00:00

I have created a custom component in Joomla 2.5 . In this component I

  • 0

I have created a custom component in Joomla 2.5. In this component I want to fetch all the user ‘s are available in com_users.For this I want you to know, How can i use com_users model class in to my component. Any one have suggestion’s to how to do 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-17T04:26:07+00:00Added an answer on June 17, 2026 at 4:26 am

    Depending on where you want use the model you can simply ask Joomla! to load it for you.

    In a JController class or sub-class you can call getModel passing in the model name and the components prefix…

    e.g.

    JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_users/models/');
    $model = $this->getModel($name = 'User', $prefix = 'UsersModel');
    

    It may be necessary to add the path of the external model you want to load using JModel::addIncludePath() as show above.

    Or if you’re sure of the model name and the class prefix you could use JModel‘s getInstance() to create the desired model object… e.g.

    $model = JModel::getInstance('User', 'UsersModel');
    

    Alternatively in a view you could:

    $myModel = $this->getModel('myOtherModel');
    $this->setModel($myModel);
    

    N.B. In the first line we’re passing our desired models name, normally you call getModel without any params to load the default model for your components view controller. In the second line, as we’re only passing the model to setModel() it won’t make it the default model the view uses.

    When we want to use our model objects later on we can specify which we want to use like this:

    $item = $this->get('Item');
    $otherItem = $this->get('Item', 'myOtherModel' );
    

    The first line uses the view’s default model (because we have specified one in the optional parameter). The second line uses the getItem() from myOtherModel.

    That’s all works because JView (in libraries/joomla/application/view.php) has these methods:

    /**
     * Method to get the model object
     *
     * @param   string  $name  The name of the model (optional)
     *
     * @return  mixed  JModel object
     *
     * @since   11.1
     */
    public function getModel($name = null)
    {
        if ($name === null)
        {
            $name = $this->_defaultModel;
        }
        return $this->_models[strtolower($name)];
    }
    
    /**
     * Method to add a model to the view.  We support a multiple model single
     * view system by which models are referenced by classname.  A caveat to the
     * classname referencing is that any classname prepended by JModel will be
     * referenced by the name without JModel, eg. JModelCategory is just
     * Category.
     *
     * @param   JModel   &$model   The model to add to the view.
     * @param   boolean  $default  Is this the default model?
     *
     * @return  object   The added model.
     *
     * @since   11.1
     */
    public function setModel(&$model, $default = false)
    {
        $name = strtolower($model->getName());
        $this->_models[$name] = &$model;
    
        if ($default)
        {
            $this->_defaultModel = $name;
        }
        return $model;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built a custom component in joomla 2.5 and want to know how
I'm using Joomla 1.5. I have created a custom component that pulls data out
I have Created this code in a custom component that I made: $date =
I have created custom component and a route plugin for Joomla 1.5 to to
I have created a custom component (NumberFormattedTextField) of JFormattedTextField. This is the Formatter I
I have created a Popup that is custom component extends Canvas i want the
I have created custom posts and I want one page in my site to
I have created a custom control but I can't bind a property to the
I have created a Custom View component and my layout file consists of a
I have created a custom facelets component and I need to set some value

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.