SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2008
    Posts
    455
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    CodeIgniter: call a view within a model

    Hi,

    How do I call a view from within a model in CodeIgniter?

    Thanks.

  2. #2
    SitePoint Zealot Gman's Avatar
    Join Date
    Jan 2002
    Location
    Sarasota, FL
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    AFAIK you can only call them from the controller...

    http://codeigniter.com/user_guide/general/views.html

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,182
    Mentioned
    16 Post(s)
    Tagged
    4 Thread(s)
    Models should not reference views.
    The only code I hate more than my own is everyone else's.

  4. #4
    SitePoint Evangelist
    Join Date
    Jun 2008
    Posts
    455
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well partials then...
    To me it makes more sense to call a partial for the likes of a form within a model as opposed to having the form within a much larger html file which the controller calls.

  5. #5
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,182
    Mentioned
    16 Post(s)
    Tagged
    4 Thread(s)
    A form is a view that populates itself by consuming model data. Models should not be aware or rely on a views existence otherwise there is a flaw in the infrastructure considering models are completely decoupled from views in MVC.
    The only code I hate more than my own is everyone else's.

  6. #6
    SitePoint Zealot Gman's Avatar
    Join Date
    Jan 2002
    Location
    Sarasota, FL
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you think the html page is large then split it up on its own, and have it call the pieces.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •