Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Name placeholder of static alias like the static alias #228

Open
fsbraun opened this issue Mar 5, 2024 · 4 comments
Open

[feat] Name placeholder of static alias like the static alias #228

fsbraun opened this issue Mar 5, 2024 · 4 comments
Labels

Comments

@fsbraun
Copy link
Sponsor Member

fsbraun commented Mar 5, 2024

This issue has been raised by Tow Cowan on Slack and @petrklus:

I used static_placeholder to allow site-wide content to be edited, and could control the plugins used in this with the CMS_PLACEHOLDER_CONF setting. I’m now using v4 for a new project - am I able to do something similar with the static_alias tag? I don’t seem to be able to do so with the configuration I’ve tried.
For example, if I have the following in my base.html template (outside of any blocks):

{% static_alias 'banner' %}

And then the following in my settings:

CMS_PLACEHOLDER_CONF = {
	"banner": {
		"plugins": ["BannerPlugin"],
	},
}

When I view the Alias (Django Admin -> Django CMS Alias -> Aliases -> Preview) and then try to add a plugin, it ignores the above placeholder config. If I add a key for a “content” placeholder in CMS_PLACEHOLDER_CONF it does allow me to configure the available plugins, but this would mean that all of my static_alias tags would have the same configuration.

@fsbraun fsbraun added the enhancement New feature or request label Mar 5, 2024
@aacimov
Copy link
Contributor

aacimov commented Mar 14, 2024

Also, when using the template system it would be very helpful to have the ability to contextually show different markup regarding the static_alias, as with static_placeholders in v3, e.g:

{% if static_alias_name == 'Static Alias 1' %}
    <div class="static_alias_1_wrap"></div>
{% elif static_alias_name == 'Static Alias 2' %}
    <div class="static_alias_2_wrap"></div>
{% else %}
    <div class="static_alias_default_wrap"></div>
{% endif %}

@aacimov
Copy link
Contributor

aacimov commented Mar 27, 2024

Hey @evill33t actually I did exactly the same to achieve the wanted behaviour but dealing with clients is the main cause I asked for the "old fashion" behaviour since they usually expect something to be added and just work OOTB (without selecting the actual template).

Thanks for the heads-up though.

@evill33t
Copy link

I deleted my comment, I was wrong about the template - imho it should be able to choose different slots which would solve this issue.

@fsbraun
Copy link
Sponsor Member Author

fsbraun commented Mar 27, 2024

There's a basic design problem here:

  • All aliases share a template (you can change templates for alias plugins, the render_alias tag within them calls the same common alias template, again.)
  • The way django CMS 4 core identifies the templates in a frontend-editable model is static (same template -> same placeholder names - always)

My best assessment is that one could:

  • Extend the core's way of identifying placeholder slots in frontend-editable models, and
  • Let the placeholder be called like the static_code or "content" if static_code is unset. (This is a breaking change, however, since the placeholder names of existing aliases changes, partly mitigable by a custom migration)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

3 participants