Forums / Setup & design / External redirect to parent node

External redirect to parent node

Author Message

Marc Boon

Thursday 16 March 2006 1:35:18 pm

Is it possible to do an automatic redirect to the parent node by a template override or otherwise?
I want to have clients redirect to the parent node if they type in a url of a folder which does exist, but where no viewable content is stored, and I want to prevent to give the client a default folder view of that node. So I want them to move up one level by external redirect, until a node is reached which contains viewable content.

Betsy Gamrat

Friday 17 March 2006 6:26:30 am

You could use <b>/error/kernel/20.tpl</b> and then have javascript handle the redirect.

Basically, assume the parent is valid and strip off the last element of the current url (in location.href), then you can use location.href="new url" to handle the redirect.

(Starting point - code in <b>/error/kernel/20.tpl</b>)


{literal}
<script>alert(location.href);</script>
{/literal}

Marc Boon

Friday 17 March 2006 6:50:12 am

The error template would never be used, because there is no error.

I want the default (not overridden by my node templates) Folder view to do the redirect.
So I should probably have a override for the Folder class as the last line in my override.ini.append. But what do I specify there, that is the question.

I would rather not use javascript, but generate a HTTP 301 redirect to the parent node.
How to do that?

Matthew Carroll

Thursday 09 November 2006 8:52:53 pm

A little late to the party, but I was looking for something else and found this. On the off-chance this is still useful Marc, the way to do this would be to use the RedirectOperators extension:

http://ez.no/community/contribs/template_plugins/redirect_operators

I do this kind of redirect to a child node, but the principle is the same - see this thread:

http://ez.no/community/forum/setup_design/auto_redirect_to_a_sub_item

Matthew

http://carroll.org.uk