Skip to content

feat: set a CMS menu link to open in new tab - via data#1151

Draft
wesleyboar wants to merge 6 commits into
mainfrom
fix/WP-1230-allow-forcing-cms-menu-link-to-open-in-new-tab--via-db
Draft

feat: set a CMS menu link to open in new tab - via data#1151
wesleyboar wants to merge 6 commits into
mainfrom
fix/WP-1230-allow-forcing-cms-menu-link-to-open-in-new-tab--via-db

Conversation

@wesleyboar

@wesleyboar wesleyboar commented Apr 22, 2026

Copy link
Copy Markdown
Member

Overview

Let CMS admin set a nav menu link's target attribute per page.

  • Controlled by CMS admin; no dev required.
  • Stored in the database.

Previously, only external links got target="_blank" (via custom Core-CMS JavaScript).

Related

Changes

  • added PageNavOptions page extension (model + migration)
  • added NewTabModifier for node.attr['target']
    adds data for template to read
  • added PageNavOptionsAdmin and PageNavOptionsToolbar
    exposes field via CMS toolbar Page menu → Page Options → Nav Options
  • updated target_blank tag
  • updated cms_menu.html

Testing

  1. make start
  2. Navigate to any internal page in edit mode.
  3. Change nav target:
    1. Open Page menu in CMS toolbar → Page OptionsNav Options
    2. Set Target to "Open in new window"
    3. Save.
  4. Verify the nav link has target="_blank".
  5. Verify external redirect links still open in a new tab (existing behavior).

UI

Toolbar.Option.mov
Admin.URL.mov
Old Solution (from 196496c)
how.you.could.change.whether.page.opens.in.new.window.mov
/admin/ UI
admin ui

Notes

The field lives in the CMS toolbar's Page menu under Page Options → Nav Options, not in Page settings. That is the only officially supported injection point for page extensions in Django CMS 3.11.

PageExtensionAdmin hides the model from the Django admin index by design, so it is not discoverable by browsing. Direct URLs:

  • Add: /admin/taccsite_cms/pagenavoptions/add/?extended_object=<page_pk>
  • Change: /admin/taccsite_cms/pagenavoptions/<extension_pk>/change/

The CMS toolbar item generates these URLs automatically.


Made with Cursor. Directed and scrutinized by @wesleyboar.

Add PageMenuTarget page extension with a target CharField (choices:
_blank, _self). A menu modifier stamps node.attr['target'] in one
query; target_blank tag outputs it directly. CMS toolbar and Django
admin expose the field per page.

Made-with: Cursor
Add __str__ returning page title (replaces "PageMenuTarget object (N)"),
set verbose_name, and document the hidden admin URLs in a comment.

Made-with: Cursor
@wesleyboar wesleyboar added the alternative Alternative solution(s) exist(s) label Apr 22, 2026
@wesleyboar wesleyboar requested a review from taoteg April 22, 2026 23:30
@wesleyboar wesleyboar changed the title feat(nav): allow CMS menu links to open in a new tab via DB feat(nav): let CMS menu links open in new tab - via DB Apr 22, 2026
@wesleyboar wesleyboar changed the title feat(nav): let CMS menu links open in new tab - via DB feat: set CMS menu link to open in new tab - via DB Apr 22, 2026
@wesleyboar wesleyboar changed the title feat: set CMS menu link to open in new tab - via DB feat: set a CMS menu link to open in new tab - via DB Apr 22, 2026
@wesleyboar wesleyboar marked this pull request as ready for review April 22, 2026 23:40
@wesleyboar wesleyboar changed the title feat: set a CMS menu link to open in new tab - via DB feat: set a CMS menu link to open in new tab - via data Apr 22, 2026

@taoteg taoteg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as advertised.

@wesleyboar wesleyboar marked this pull request as draft May 19, 2026 03:23
@wesleyboar

wesleyboar commented May 19, 2026

Copy link
Copy Markdown
Member Author

Important

I like this, but I have not merged yet, because I consider changing it's name and form to suggest we can add more (e.g. pagemenutargetpagemenuoptions), so that future features do not each require a new menu item.

Update: Done.

@wesleyboar wesleyboar added the priority ▼ Low priority label May 19, 2026
…ons submenu (#1163)

## Overview

Renames `PageMenuTarget` to `PageNavOptions` and adds a "Page Options"
flyout submenu in the CMS toolbar to house it — and future per-page
options — without cluttering the Page menu.

## Related

- [WP-1230](https://tacc-main.atlassian.net/browse/WP-1230)
- merges into #1151

## Changes

- **renamed** `PageMenuTarget` → `PageNavOptions` (model, admin,
toolbar, modifier)
- **replaced** migration `0003_add_page_menu_target` →
`0003_add_page_nav_options`
- **added** "Page Options ▶" submenu in CMS toolbar Page menu
- **moved** "Nav Options" modal item under that submenu

## Testing

1. `make start`
2. Navigate to any internal page in edit mode.
3. Open **Page** menu in CMS toolbar → **Page Options** → **Nav
Options**.
4. Set **Target** to "Open in new window" and save.
5. Verify the nav link has `target="_blank"`.
6. Verify external redirect links still open in a new tab (existing
behavior).

## UI


https://github.com/user-attachments/assets/7cfdb6cb-eea2-488c-9a14-67b6d3ddec67


https://github.com/user-attachments/assets/80573b30-f714-4348-8fce-ab78f93635ee

Made with [Cursor](https://cursor.com)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
@wesleyboar

Copy link
Copy Markdown
Member Author

Polished. Future additions would not further increase size of main menu.

Might not use, because WP-1290 has simpler solution: add sub-domain to URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

alternative Alternative solution(s) exist(s) priority ▼ Low priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants