eZ Community » Forums » Developer » Update template dinamicaly
expandshrink

Update template dinamicaly

Update template dinamicaly

Tuesday 03 July 2012 2:21:50 am - 5 replies

Hi guys,

I want to change my content when I click on a button. For example, I have a fetch function that fetch a couple of images from node 1 and if I click on a button I want to change that fetch function to fetch from node 2 and update my page in accordance.

Can anyone guide me on how to do that?

 

Thank you

Tuesday 03 July 2012 9:22:59 am

Hi Ricardo,

1. you will need a variable  e.g. '$fetch_parent_node_id' which you will use for the node id in your fetch

2. This variable has a default value

3. The variable should be possible to override by a  POST or GET variable

Example for a get variable you can easily send by a custom Form or a custom link

URL with get variable   ...?FetchParentNodeId=1234

 {def $fetch_parent_node_id = 2}
 
{if ezhttp_hasvariable('FetchParentNodeId')}
    {set $fetch_parent_node_id = ezhttp('FetchParentNodeId') }
{/if}
 
{def $node_list = fetch( 'content', 'list', hash( 'parent_node_id', $fetch_parent_node_id, ...))}

Hope this will help

Cheers Felix

Wednesday 04 July 2012 12:29:51 am

Hi Felix,

Thank you for your help:

I tried something like this:

 <form method="get">
<input type="text" name="FetchVariable">
 
    <input type="submit" value="submit"/>
</form>
 
{if ezhttp_hasvariable('FetchVariable', 'get')}
    <p>The Variable exist</p>
{else}
    <p>The variable dosen't exist</p>
{/if}

When I reload the page (URL without the get variable) it writes: "The variable dosen't exist". Everithing ok here. But when I write down somethin on the text field and hit the submit button (the URL updates to ...?FetchVariable=something) the message remains the same.

Is this normal? The message should change to "The Variable exist" right?

Wednesday 04 July 2012 1:00:54 am

BTW,

Using forms will cause my entire page to reload and I don't want that. I just need that the specific block where my gallerie is located reloads. Not all the page...

Wednesday 04 July 2012 8:18:39 am

If you do not reload the page you need ajax

1. a click performs an ajax call (php) the html result for example is insert into a fix html id

Have a look to this project which can do that

http://projects.ez.no/ezxajax

Modified on Wednesday 04 July 2012 8:19:23 am by Felix Woldt

Thursday 05 July 2012 1:19:45 am

Thank you for your tips and help.

Where can I found some documentation about the xajax extension?

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from