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

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

Redirect on first child

Redirect on first child

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

Hello,

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

Thanks

Jean

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

Hi,

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.

hth!

Monday 03 September 2007 11:03:27 am

Hi,
you could use a template plugin:
http://ez.no/community/contribs/template_plugins/redirect_operators

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}
    {redirectrelative($red)}
{/if}

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}
   {redirectrelative($red)}
{/if}
 
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

Hello,

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 (http://ez.no/community/contribs/template_plugins/redirect_operators) . Could someone point me to the accurate location of the operator.

Thanks.

Kind regards,

Elena

Monday 25 October 2010 6:00:50 pm

Hello Elena,

Try this instead, http://auth.ez.no/community/contribs/template_plugins/redirect_operators

Cheers,

Heath

Tuesday 26 October 2010 8:39:39 am

Hello Heath,

Thanks for that link, but it redirects me to http://share.ez.no/(from)/ez.no/. Anyway, I found another solution to my problem. I used:

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

in my template.

Greetings,

Elena

Tuesday 26 October 2010 9:59:42 am

Elena,

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 projects.ez.no, 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?

Thanks.

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)}
    {redirect_to_operator($module_result.content_info.persistent_variable.redirect_target)}
{else}
    ... Rest of page ...
{/if}
expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from