Share » Forums » Setup & design » Redirect on first child

Redirect on first child

Redirect on first child

Monday 27 August 2007 6:01:45 am - 12 replies

Author Message

Guilherme Longo

Wednesday 29 August 2007 1: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?

Xavier Serna

Thursday 30 August 2007 2: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!

--
Xavier Serna
eZ Publish Certified Developer
Departament de Software
Microblau S.L. - http://www.microblau.net
+34 937 466 205

Daniele P.

Monday 03 September 2007 2: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

Gerhard Sletten

Thursday 19 June 2008 2: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

Triathlon, Webdev, Novels and Cooking..
http://www.gersh.no

Elena Ivanova

Monday 25 October 2010 3:33:36 am

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

Heath

Monday 25 October 2010 9:00:50 am

Hello Elena,

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

Cheers,

Heath

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

Elena Ivanova

Monday 25 October 2010 11:39:39 pm

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

Nicolas Pastorino

Tuesday 26 October 2010 12: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 !

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Elena Ivanova

Tuesday 26 October 2010 1: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.

Gaetano Giunta

Tuesday 26 October 2010 5:28:56 am

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

Principal Consultant International Business
Member of the Community Project Board

Elena Ivanova

Tuesday 26 October 2010 7:29:26 am

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.

Gaetano Giunta

Tuesday 26 October 2010 9:29:29 am

@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}

Principal Consultant International Business
Member of the Community Project Board

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

36 542 Users on board!

Forums menu