Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

RfC - make registration of placeholders possible independently from Templates - resolved ✅#7927

macolo started this conversation inGeneral
Discussion options

macolo
May 22, 2024
MaintainerSponsor

Intro

  • django CMS discovers placeholders by scanning (HTML / django) Templates.
  • django CMS uses this information to populate the structure sidebar (i.e. which placeholders can be accessed and edited in the sidebar on which page)
  • This works generally ok however there are some use cases where a more solid approach would be beneficial:

Possible solutions

  • a globalsettings.py configuration of placeholders (disadvantage: removing or adding a placeholder requires changes in two places, 1) the template and 2) insettings.py)
  • TBD
  • ...

Solution Approach

You must be logged in to vote

Replies: 2 comments

Comment options

fsbraun
May 22, 2024
MaintainerSponsor

I'd suggest a hierarchical approach:

  1. If templates are defined, through templates (CMS_TEMPLATES setting)
    • Backwards compatible
    • Only one place to change if using both django CMS' headand API
    • Allows for additional config, namely inheritance.
  2. If no templates are defined, fall back to a new setting, say,
    CMS_PLACEHOLDERS = (    ("home", ("content", "sidebar"), _("Home page")),  # Give slot names    ("products", ("intro", "ads", "disclaimer"), _("Product page")),)
  3. If no setting exists at all: Just one placeholder per page, called"content".

If inheritance is important for a headless solution, theCMS_PLACEHOLDERS could add an optional config, despite the fact it might look clunky:

CMS_PLACEHOLDERS = (    ("home", (        "content",  # Shorthand for {"slot": "content", "inherit": False}        {            "slot": "sidebar",            "inherit": True,        }    ), _("Home page")),    ...)

See here for an early test run:#7850 (comment)

You must be logged in to vote
0 replies
Comment options

fsbraun
May 24, 2024
MaintainerSponsor

On another note, allowing for an alternative method of placeholder declaration - besides within templates - will simplify certain use cases for app hooks:

  • Currently, app hooks need to define aget_template() method on their frontend-editable models to provide a template for placeholder scanning only. Often, it only lists the placeholders using the{% placeholder %} template tag.
  • Typically, a different template is used for actually displaying any model content using{% render_placeholder %} instead of{% placeholder %}

I suggest to also checking models for aget_placeholder_slots() method which will return a model's used slots. It will be evaluated in cases theget_template() method does not exist or returns a valid template.

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
General
2 participants
@macolo@fsbraun

[8]ページ先頭

©2009-2025 Movatter.jp