SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: Templating

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

    Templating

    Hi,

    I'm working on my own MVC project.

    I'm having trouble with templating... within my views(templates) i have the likes of $this->varname; which is output as varname; which obviously isnt what I want.

    This is the view:
    PHP Code:
    <p>this is the view for the homepage</p>
    <?= $this->test?>
    ...this is the class class calling the view, etc:
    PHP Code:
    public function _Body(){
            include 
    VOYAGER_SYSTEM_APP_VIEWS self::$_View '.php';
        } 
    and this is the controller calling and rendering the view:
    PHP Code:
    // create template and assign properties (stylesheets to load and such)
            
    $template = new Voyager_Template_Engine();
            
    $template->_View'pages/home' );
    $template->test 'test string';
            
    $template->_Render(); 
    Where am I going wrong?

  2. #2
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What makes you believe that you're doing something wrong?

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2008
    Posts
    455
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol, because the view example from my 1st post outputs:

    HTML Code:
    <p>this is the view for the homepage</p>
    test; ?>
    NOT

    HTML Code:
    <p>this is the view for the homepage</p>
    Test String
    Which is what the example should output.

  4. #4
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you making the assumption that short tags are enabled? Have you checked?
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  5. #5
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    That would be most likely, the <?= $this-> is seen as a tag, with test; ?> appended to the end.

  6. #6
    SitePoint Evangelist
    Join Date
    Jun 2008
    Posts
    455
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had the short tags turned on, but even so, then i replace <?= with <?php echo
    i still get nothing.

  7. #7
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    What output are you getting now? What is the contents of your templating class?

  8. #8
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Also, I'm intrigued as to why your properties and methods start with an underscore...


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
  •