eZ Community » Forums » eZ Publish 5 Platform » Ezpublish 5 current node id inside...
expandshrink

Ezpublish 5 current node id inside ezflow twig block template

Ezpublish 5 current node id inside ezflow twig block template

Thursday 07 July 2016 5:47:19 pm - 3 replies

Hi all,
I'm currently working in a project using the ezpublish legacy admin and the new stack for final user. I'm having problems using ezflow blocks as I need to get the current landing page node id inside the block twig template. I have tried to print available variables using {{dump(var)}} but I get a white screen as the php allowed memory is exhausted. I also made a {{dump(_context|keys)}} to get the available variables and printed them individually but I also get white screen for some of them. Is there a template function to get the current node id or should I make a new controller to get it?.

Thank you,

Julian Mancera

Friday 08 July 2016 2:33:55 am

Hi

 

You need to pass it to the controller using params:

             {{ render_esi( controller( 'ez_page:viewBlockById', {
                'id':         ezblock.id,
                'cacheSettings': { 'smax-age': 7200 },
                'params': {
                    'location_id':  caller_location.id,
                }
            } ) ) }}

Then in the controller you have access to it and then you can do whatever you want and finally pass to the template:

 

     public function topicsPageAction( Block $block, array $params = array(), array $cacheSettings = array() )
    {
        ... use the params, you can add more variables to it
        $response = $this->get( 'ez_page' )->viewBlock( $block, $params, $cacheSettings );

Friday 08 July 2016 2:46:58 pm

Hi Thiago,

First of all, thank you for you amazing youtube videos, they have been really help full in my learning process. 

Your advice worked like a charm!

Julian

Friday 08 July 2016 6:12:54 pm

Hi Julian

Glad to see the videos helped you and also good to see you solved the node id issue!

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from