Skip to content

How to Open "External Link" in New Window via CMS? #7

@wesleyboar

Description

@wesleyboar

In GitLab by @tacc-wbomar on Jan 21, 2020, 12:52

Deliverables

Tickets:

Solutions:

Goal

Any link to an external website should open in an external window. Especially:

Requirements

  1. Any link to external website should open in a new window when clicked*.
  2. This feature should not require configuration by CMS user.

* When clicked without modification key from user. (Cmd+ click on Mac browsers opens link in new window.)

Background

Django CMS does not manage this by default. Maybe the CMS user can do this per link. Or maybe not.

This should be a high priority ticket, because the original issue was created too long ago (GL-1), and it is the first request Hedda made fo me for CMS, and she has re-requested a few times.

Direction

See Direction in tickets listed in Deliverables.

Archived

CMS Menu & Article Listing

Use a Django filter "templatetag":

  1. (Python) Parse any known URL before rendering a link.
  2. (Python) Conditionally render target="_blank" attribute in link.
  3. (Template) Apply the filter to CMS menu markup.
  4. (Template) Apply the filter to article listing template/s (or a shared partial)

Text Plugin

Unsure. Ideas:

  • A. Find a way for CMS user to set link with target="_blank" and document this step as a requirement.
  • B. Author JavaScript to conditionally add target="_blank" after render for any links whose domain is different.
    • Gotcha: This is not possible for old CMS sites, because they do not use the external URL directly—they filter a redirect through a local slug. To remedy this, an array of such "redirect slugs/paths" may be provided to the script.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingeffort SSmall effort task (~½ a week) — does not include review timepriority ▼Low priorityresearchInvestigation is required

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions