1. This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.
  2. In order to post messages and view attached files in this forum, you must be a licensed XenForo customer.
    If you can't post, enter your forum username in the Associated Forum Users form in your customer area.

Calling Models

Discussion in 'Development Tutorials [Archive]' started by ragtek, May 28, 2011.

  1. ragtek back2life

    (my english is horrible and i'm not a author, so it's a minimalistic text;)

    Even some Coders are using this, you should NEVER use
    PHP:
    $foo = new ModelName;
    to create model instances!
    If you do it this way, your model instances won't be using the xenforo plugin system (proxy classes)
    which could cause problems

    This are the ways how to call a model:

    From Controller:
    PHP:
    $foo $this->getModelFromCache('ModelName');
    From Model
    PHP:
    $foo $this->getModelFromCache('ModelName');
    From all other parts:
    PHP:
    $foo XenForo_Model::create('ModelName');
    ceribik, Hoffi, DarkSign and 2 others like this.
  2. KozmoK Active Member

    Ragtek,

    I hate to dirty up your post with this stupid question! Can I call a 3rd party (already a working add-on) model from within another controller, or model?
    I'm going to edit the paypalProcessor to call my custom model and do a db function.

    Thanks,

    Koz
  3. bobster65 Well-Known Member

    Yes
  4. Liam O'Neill New Member

    ANyone tell me where I can find a list of models and the functions within, specifically need to access user data from an external script
  5. Hoffi Active Member

    Directory library/XenForo/Model
  6. ragtek back2life

    I would suggest to search for a good PHP IDE and to learn how to use it;)


    XF_Model_User diagramm:
    diagram.png

    Hope this helps;)

    Or you could use http://www.phpdoc.org/ or an alternative to get a nice API documentation

Share This Page