Last modified 6 years ago
Cms Template for an external Link
Sometimes you want to hve a document/folder that sends the visitor to an external site. Since you do not want it in the content, the normal way just dow not work out, you need a template to do it
the template
<corinis> <corinis-life> <script> var linkto = '<corinis-field name="linkto" type="show"/>'; <corinis-exist name="newWindow"> window.open(linkto, '_blank'); history.back(); </corinis-exist> <corinis-nonexist name="newWindow"> this.location.replace(linkto); </corinis-nonexist> </script> </corinis-life> <corinis-comment> Link location: <corinis-field name="linkto" type="edit" /> <br /> <corinis-field name="newWindow" type="checkbox" /> Open in new window </corinis-comment> </corinis>
What happens
The template consists of two parts:
- the corinis-comment part: this is for the editor, you can insert a link and set a checkbox if you want it to open in a new window
- the corinis-life part: this is a small javascript that sends the browser to the new page.
We use corinis-life/corinis-comment to hide parts of the code wether we are editing or viewing the template. With corinis-exist/corinis-nonexist we do a kinda-if statement for the checkbox The rest is simple javascript.
This template should NOT be pushed through the xml indenter of the amdin pages, this would testroy the javascript.
do not name ANY field 'link' this is used internally''
