Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Forced rendering encodes html
  • Hello,
    I've been trying to get the hang of forced rendering in FuelPHP, as in the documentation. Unfortunately, the follow code actually encodes the html, so than rather than being html, the code is displayed on page. /**
    * get the current user and their organisation.
    * @see /app/classes/model/users.php
    */
    $user = \Model\Users::all($primary); //
    $data = $user;
    $data = $person;
    $data = 'Profile'; $views = array(); $views = View::forge('meta',$data);
    $views = View::forge('header',$data);
    $views = View::forge('footer',$data); return View::forge('account/index',$views)->render(); and the output becomes <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Welund · Profile</title> <link rel="stylesheet" href="/public/assets/css/bootstrap.css" type="text/css" /> <link rel="stylesheet" href="/public/assets/css/bootstrap-responsive.css" type="text/css" /> <link rel="stylesheet" href="/public/assets/css/welund.css" type="text/css" /> [removed][removed] [removed][removed] [removed][removed] [removed]try{Typekit.load();}catch(e){}[removed] </head> <body> <div class="container"> <div class="row"> <div class="header span12"> <div class="row"> <div class="span8"> <h1 id="portal"><a href="/home">Cyber Security <strong>Portal</strong></a></h1> </div> <div class="span4"> <h1 id="logo">Welund</h1> </div> </div> </div> </div> <div class="navbar"> <div class="navbar-inner"> <div class="container"> <ul class="nav pull-left"> <li ><a href="/home">Home</a></li> <li ><a href="/articles/category/news">News</a></li> <li ><a href="/articles/category/alerts-and-warnings">Alerts & Warnings</a></li> <li ><a href="/articles/category/vulnerabilities">Vulnerabilities</a></li> <li ><a href="/articles/category/tools">Tools</a></li> <li ><a href="/articles/category/summaries">Summary</a></li> <li ><a href="/articles/category/tips">Tips</a></li> </ul> <ul class="nav pull-right"> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> George Robinson<b class="caret"></b> </a> <ul class="dropdown-menu"> <li><a href="/settings/account">Profile</a></li> <li><a href="/settings/notifications">Notifications</a></li> </ul> </li> <li><a href="/logout">Logout</a></li> </ul> </div> </div> </div> except this is displayed onscreen, rather than parsed as HTML by the browser. Why is this?
  • FuelPHP encodes on output as a security measure. When you pass your partials (containing HTML) to you page view, they will be encoded, giving you this output. So you have to disable encoding manually when you pass HTML to a view:
    return View::forge('account/index',$views, false)->render();
    

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion