Skip to content

feat: Add generic floating shortcut tab with PIRANHA Params configuration - #81

Closed
Pince-Rioux wants to merge 5 commits into
axuno:mainfrom
Pince-Rioux:feature/floating-shortcut-tab
Closed

Pince-Rioux wants to merge 5 commits into
axuno:mainfrom
Pince-Rioux:feature/floating-shortcut-tab

Conversation

@Pince-Rioux

Copy link
Copy Markdown
Contributor

Summary

Adds a floating shortcut tab widget to the ClubSite PIRANHA CMS. The tab appears as a vertical button fixed to the right edge of the screen and is configurable entirely through PIRANHA Manager → Settings → Params — no code changes required per use case.

Motivation

The club needs a persistent "Mitglied werden" call-to-action visible on every page. Rather than hardcoding a specific registration page, this solution makes the tab generic so admins can repurpose it for tournaments, PDF downloads, external links, etc.

Changes

New file: Pages/_FloatingRegisterTab.cshtml

A partial view that:

  • Reads 5 PIRANHA Params at render time via WebApp.Api.Params.GetByKeyAsync()
  • Renders a fixed-position vertical tab (right edge, 40% from top)
  • Supports configurable: link, text, color, and mobile visibility
  • Falls back silently when params are missing (tab disappears)
  • Self-contained: inline <style>, no SCSS dependencies, no DI registration

Configurable Params:

Key Example Purpose
shortcut-tab-enabled true Master toggle
shortcut-tab-link /mitglied-werden Link target (page, PDF, external URL)
shortcut-tab-text 🏐 Beitreten Button text
shortcut-tab-color #dc3545 Background color (any hex)
shortcut-tab-hide-mobile false Hide on small screens

Modified: Pages/_Layout.cshtml

  • Added <partial name="_FloatingRegisterTab" /> after the footer
  • Resolved merge conflict with upstream _CookieConsent.cshtml addition (both partials are now included)

Modified: WebAppStartup.cs

  • Wrapped the HTTPS redirect (AddRedirectToWwwPermanent / AddRedirectToHttpsPermanent) in if (!env.IsDevelopment()) guard
  • Reason: In production, HTTPS is handled by the reverse proxy. In development (local testing on arbitrary ports), the redirect makes the site unreachable without a proper certificate. This is a standard pattern in ASP.NET Core projects.

How to Test

  1. After deployment, go to Manager → Settings → Params
  2. Create the 5 params listed above with your desired values
  3. Visit any page on the site — the floating tab appears on the right edge
  4. Delete or disable shortcut-tab-enabled to remove the tab

Design Decisions

  • Params over Page Type: Initially implemented as a ShortcutTabPage custom page type, but PIRANHAs StringField deserialization proved unreliable for programmatically-inserted data. Params are simpler, have no deserialization issues, and are fully editable through the Manager UI.
  • Inline CSS over SCSS file: Keeps the feature self-contained in one file. CSS is minimal (~25 lines).
  • No media queries: The tab is visible on all screen sizes. Mobile hiding is optional via the hide-mobile param (applies d-none d-sm-block Bootstrap class).

Pince-Rioux and others added 2 commits August 2, 2026 22:04
…tion

Adds a floating shortcut tab (fixed right edge, vertical text) to the
ClubSite. The tab is configured entirely through PIRANHA Manager Params,
making it reusable across any purpose without code changes.

Key changes:
- New _FloatingRegisterTab.cshtml partial view reads 5 PIRANHA Params:
  shortcut-tab-enabled, shortcut-tab-link, shortcut-tab-text,
  shortcut-tab-color, shortcut-tab-hide-mobile
- _Layout.cshtml includes the new partial after the footer
- WebAppStartup.cs skips HTTPS redirect in Development environment
  (needed for local testing without HTTPS)

The tab appears automatically when the Params are configured in
Manager -> Settings -> Params. When Params are deleted, the tab
disappears. Zero code changes needed per use case.
Corrected Neusäß special characters
@axunonb axunonb added the enhancement New feature or request label Aug 3, 2026
@axunonb

axunonb commented Aug 3, 2026

Copy link
Copy Markdown
Member

go to Manager → Settings → Params

Looks like there's something missing in this PR that makes the Params visible for editing in Manager
(i.e. maybe as described here)

Adds a dedicated Piranha Manager page under Settings → Shortcut Tab
to configure the floating shortcut tab. This replaces the earlier
instruction to manually create Params in Manager → Settings → Params,
which was not discoverable and required knowing exact key names.

Changes:
- New Manager page at ~/manager/settings/shortcut-tab with a form
  for all 5 Params (enabled, link, text, color, hide-mobile)
- Menu item registered in the Settings group for discoverability
- Params are created/updated/deleted via IApi.Params on save
- Follows Piranha Manager UI patterns (breadcrumb, card, list-group)

This addresses PR review feedback that custom Params need a
proper Manager UI to be usable by site admins.
@Pince-Rioux
Pince-Rioux force-pushed the feature/floating-shortcut-tab branch from 3ab55d5 to 2090fea Compare August 3, 2026 14:48
@Pince-Rioux

Copy link
Copy Markdown
Contributor Author

Good point — having admins hunt through the generic Params section wasn't great. I've added a proper Manager page at Settings → Shortcut Tab so the 5 Params can be configured through a form instead.

Removes the Piranha Manager settings page and Params-based configuration
in favor of a simple hardcoded tab in _FloatingRegisterTab.cshtml.
The tab links to /mitglied-werden with minimal CSS, no database or
configuration required.
Replaces hardcoded PDF link with dynamic lookup from Piranha media
library by folder name and filename. Reads FolderName/FileName from
AppSettings.json, resolves the PublicUrl via Piranha API, and caches
it in-memory.

- _FloatingRegisterTab.cshtml: looks up folder by name, then file by
  filename in Piranha_Media, caches the PublicUrl
- AppSettings.json: adds FloatingRegisterTab section with FolderName
  and FileName
- Falls back silently with error log if document not found
- Full CSS positioning (no Bootstrap-only dependency) for reliable
  right-side fixed placement on mobile Safari
@Pince-Rioux
Pince-Rioux deleted the feature/floating-shortcut-tab branch September 14, 2026 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants