eZ Community » Forums » eZ Publish 5 Platform » render_esi and ezpage:viewBlock
expandshrink

render_esi and ezpage:viewBlock

render_esi and ezpage:viewBlock

Wednesday 28 January 2015 2:23:17 pm - 7 replies

Hi, I am using varnish and render_esi with custom controllers for my footer for example and it is working fine.

but as soon as I am using the render_esi function with ez_page:viewBlock (in an ezflow layout), I have a blank page.

Is it compatible ? has someone the same issue ? 

Modified on Wednesday 28 January 2015 2:24:13 pm by fabien mas

Thursday 29 January 2015 10:08:04 am

I'm using render_esi too, but have no any problems. about blank page, i get them if i put varnish and forget to disable http cache in my virtual host configuration.

but normally render_esi works ok for me with blocks too. 

Thursday 29 January 2015 10:25:16 am

Hi Carlos,
 thanks for your answer 

I just found a working case, while I was writting this answer.

Without the block content, it is not working;
with the block it works 

 {% for block in zones[0].blocks %} 
 
 
{% block content %}
                  {{ render( controller("ez_page:viewBlock"{ 'block': block,   'cacheSettings': {'smax-age':15}   } )) }}
{% endblock %} 
{% endfor %}

              

Fabien

Modified on Thursday 29 January 2015 10:26:29 am by fabien mas

Thursday 29 January 2015 10:30:29 am

Wrong answer before, the block thing is not interacting.

I used render instead of render_esi (wrong copy-paste ... )

So, with another controller, like the controller footer it is working, but still not with the ezpage:viewBlock .. 

Thursday 29 January 2015 2:48:06 pm

Quote from fabien mas :

Wrong answer before, the block thing is not interacting.

I used render instead of render_esi (wrong copy-paste ... )

So, with another controller, like the controller footer it is working, but still not with the ezpage:viewBlock .. 

Fabien

You can't pass complex variables like objects via ESI. All parameters are serialized as GET parameters for that fragment and url size has some size limits. 

The confusing thing is that this work with the internal php reverse proxy but as soon as you use a real proxy it will not work.

Hence, use the ezpage:viewBlockById which my colleague Petar implemented exactly because of this happy.gif Emoticon

http://pubsvn.ez.no/doxygen/trunk...1_1Controller_1_1PageController.html

Thursday 29 January 2015 3:02:33 pm

Hi Ivo 

thanks a lot it is working now 

I get the philosophy now and I will try to adapt my controller to have some simple parameters in case of ESI rendering

BR,

Fabien 

Thursday 29 January 2015 3:40:30 pm

Another question, I can't get the params smax-age to work.

 {{ render_esi( controller( "ez_page:viewBlockById", {'id': block.id, 'cacheSettings':{'smax-age' : 11} } ) ) }}

when varnish is not activated smax-age is an integer, but as soon as varnish is used smax-age  is a string 

 

And there is a test on the type in the viewBlock function 

 public function viewBlock( Block $block, array $params = array(), array $cacheSettings = array() )

....

 if ( isset( $cacheSettings['max-age'] )  && is_int( $cacheSettings['max-age'] )   )

 

Is it a bug or do I need to make a different call in my twig file 

 

thx,

Fabien 

Thursday 29 January 2015 3:51:48 pm

Quote from fabien mas :

Another question, I can't get the params smax-age to work.

 {{ render_esi( controller( "ez_page:viewBlockById", {'id': block.id, 'cacheSettings':{'smax-age' : 11} } ) ) }}

when varnish is not activated smax-age is an integer, but as soon as varnish is used smax-age  is a string 

 

And there is a test on the type in the viewBlock function 

 public function viewBlock( Block $block, array $params = array(), array $cacheSettings = array() )

....

 if ( isset( $cacheSettings['max-age'] )  && is_int( $cacheSettings['max-age'] )   )

 

Is it a bug or do I need to make a different call in my twig file 

 

thx,

Fabien 

$cacheSettings thing is handled inside ViewBlock (viewBlockById is just fetching the block and calling viewBlock). Might be some bug in there :/

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from