Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Pagination HTML is escaped
  • I'm currently trying to use the pagination but when i put the html on the page this is escaped (I use twig template parser).
    I have something like this:
    public function action_index($page = 1)
        {
            $config = array(
                'pagination_url' => static::$data['base_url'].'admin/testing/',
                'total_items' => 2,
                'per_page' => 1,
                'uri_segment' => 3,
            );
            
            // Config::set('pagination', $config); // you can use this too!
            Pagination::set_config($config);
            
            static::$data['pagination_links'] = Pagination::create_links();
    // I fetch only one post 'cause i'm just testing
            static::$data['posts'] = Post::get($page);
            return Response::forge(View::forge('home/index.twig', self::$data));
        }
    

    And my template is something like this:
    {% from "structures/post.twig" import postbody%}
    {% for post in posts %}
          {{ postbody(post) }}
    {% endfor %}
    {{ pagination_links }}
    
    I also tryed to use {{ pagination_links|raw }} to prevent html escape but still not working (Sorry bad english)
  • as a security measure, FuelPHP escapes on output. That means everything you send to a view gets escaped, unless you explicitly tell it not to. So do
    // Config::set('pagination', $config); // you can use this too! Pagination::set_config($config); 
    
    static::$data['posts'] = Post::get($page); 
    return Response::forge(View::forge('home/index.twig', self::$data)->set('pagination_links', Pagination::create_links(), false));
    
  • Now works, thanks dude!

Howdy, Stranger!

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

In this Discussion