This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Setup & design » Redirect on first child

Redirect on first child

Redirect on first child

Monday 27 August 2007 3:01:45 pm - 12 replies


I have a site :
folder 1
------------>page 1
------------>page 2

I wan't that when I click on folder 1, I be redirected on page 1.

If I had a new page page 0, I be redirected on page 0



Wednesday 29 August 2007 10:12:02 am

I did'nt understand correctly.

If you have page like: page(x) where (x) is your first number or your less number, when u access your folder you want be redirect to your less (x) page?

Am i right?

Thursday 30 August 2007 11:36:39 am


if I understand right, the fact is that you don't want to display the full view of the folder, thus when anyone clicks on the folder you want the first child displayed.
If this is right, you can made the system to behave as you want creating a tpl for the full view of your folder, and in it make a fetch of their childrens and output a node_view_gui of the first child.


Monday 03 September 2007 11:03:27 am

you could use a template plugin:

and something like:

{def $red=fetch(content, list, hash( parent_node_id, $node.node_id,
                                     limit, 1,
                                     sort_by, $node.sort_array ) )[0].path_identification_string|ezurl(no)}
{if $red}

Sorry, there isn't any child available

Thursday 19 June 2008 11:24:23 am

Hi, thanks that was exactly what I was looking for!

Did modified the template code a little, to make it a little more understandable:

{*?template charset=utf-8?*}
{def $redirect_node=fetch(content, list, hash( parent_node_id, $node.node_id,
                                    limit, 1,
                                    sort_by, $node.sort_array ) )
$red = $redirect_node[0].path_identification_string|ezurl(no)}
{if $red}
Sorry, there isn't any child available

Modified on Thursday 19 June 2008 11:25:52 am by Gerhard Sletten

Monday 25 October 2010 12:33:36 pm


I need very much this 'Redirect to a sub node' functionality and would like to use this redirect_operators, but I cannot find the exstension, mentioned above - the given link is not valid anymore ( . Could someone point me to the accurate location of the operator.


Kind regards,


Monday 25 October 2010 6:00:50 pm

Hello Elena,

Try this instead,



Tuesday 26 October 2010 8:39:39 am

Hello Heath,

Thanks for that link, but it redirects me to Anyway, I found another solution to my problem. I used:

<script type="text/javascript">
window.location = {/literal}"{$redirect_url}"{literal};

in my template.



Tuesday 26 October 2010 9:59:42 am


About the redirection : we are in the process of migrating all contributions of the former 'contribs' section (to where the URL Heath gave you is leading) to, the central forge. This will soon all be available again there.

Cheers !

Tuesday 26 October 2010 10:27:15 am

O, I see, this is a good news, thanks for update.

Do you plan also to return to the old way of presenting the search results - in a table with columns for date, author, type of content, etc. This table gave a lot of information of the returned results, user doesn't need to go link by link to see the date of the matched pages.

Tuesday 26 October 2010 2:28:56 pm

I cannot comment on the redirect_operators extenion code, since I cannot find it, but please bear in mind, that since the introduction of the stale cache (eZP 4.1), having a redirect operator in your node template has become a Very Bad Idea (TM).

You are very much at risk of boiling your database with never-ending cache-generating processes (there is an issue in wit I cannot find right now with great details).

The correct way to do that is to, at least,

- set the target for redirection into the persistent_variable in the node template

- use an http redirect operator in the pagelayout

Tuesday 26 October 2010 4:29:26 pm

Gaetano, thanks for your answer. What I need to do is to redirect from a folder to its first child. Firstly I fetch this child and after redirect to $child.url_alias. This is my $redirect_url in the code snippet I provided above. So, this $redirect_url changes dynamically according to the selected folder and thus I cannot use a persistent variable. Do you see any other way of achieving that?


Tuesday 26 October 2010 6:29:29 pm

@elena: in fact you can

Short snippets (real code might need more error checking)

In the node template:

{set $persistent_variable = hash('redirect_target', $node.children.0.url_alias)}

Then, in the pagelayout

{if is_set($module_result.content_info.persistent_variable.redirect_target)}
    ... Rest of page ...

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

36 542 Users on board!

Forums menu

Proudly Developed with from