0

I'd like to add a link to an outside site to my {exp:structure:nav} output. Can I do this? In Taxonomy I'd add a node and set it to "Custom Link," but it appears I can only add actual entries within EE to Structure's trees.

1

Only EE entries can live inside the Structure tree, because Structure is built off of the Pages module. There is a way to do this, though it requires a little bit of a work around.

Create a channel called something like External Links or Menu Links or something, and have only one single custom field for that channel called something like Link URL. And then you can create a template for that channel that looks something like this:

<?php
header( "Location: {exp:channel:entries}{link_url}{/exp:channel:entries}" );
exit;
?>

Then you can create entries in that channel, assign it where you want in the Structure tree, and make sure you use that template for those pages. It'll get the job done.

Pretty sure I learned this from the Structure documentation, so look there thouroughly and you may get a cleaner version of this answer.

0

Another option is to add a typical entry so it appears in the nav tree, then in Apache set up a redirect.

0

In the templates, create a template group for redirects, and the template "my-offsite-link" and just use a regular meta redirect in the template:

<!DOCTYPE HTML>
<html>
<head>
<title>My offsite link</title> 
<meta http-equiv="REFRESH" content="0;url=http://www.my-offsite-link/">
</head>
<body>
</body>
</html>

Then create an entry in the Structure tree wherever you want, and point it to the template for redirection:

entry -> Structure (in the tabs) -> Structure Template -> redirects/my-offsite-link

  • I can see some faults in this answer; it is now browser vendor dependent, as well as possibly device connection dependent, and other strange factors I can't even fathom. Redirecting from the server skips a browser render, and depending on the browser to act appropriately. This also allows response codes in case of special conditions (301/302/whatever code you want to send). And in this case, I think if you go back one position in your browser history, you won't go back to the previous page you were on; you'd just go back to this render page that always forwards you again. – jrothafer Jan 8 at 1:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.