django-cms / djangocms-alias

Other
8 stars 23 forks source link

`static_alias` renders only if you have a block named "content" #212

Closed aacimov closed 5 months ago

aacimov commented 7 months ago

I am not sure if this should be a feature request but I usually have a block named _basecontent instead of content since I sometimes have a different base.html file for different purposes.

static_alias can be edited only if a block named content exists in the template. I suppose it's by design and by best practices but just a thought.

I was struggling for a few minutes why I cannot edit my static_alias so maybe it will be helpful to others.

Or just adding a note to the docs as an indicator it is actually a dependency in the template.

Python 3.10.6 Django 4.2.9 Django CMS 4.1.0 djangocms-alias 2.0.0

fsbraun commented 7 months ago

Hi @aacimov !

The default setup of django CMS Alias assumes you have a block called "content" in your base.html. You can, however, change that:

In your project, create a template called djangocms_alias/base.html with the following content:

{% extends "base.html" %}
{% load i18n static sekizai_tags %}

{% block title %}{% trans "Aliases" %}{% endblock %}

{% block breadcrumb %}{% endblock %}
{% block footer %}{% endblock %}

{% block base_content %}
    <div class="aliases">
        {% block aliases_content %}
        {% endblock aliases_content %}
    </div>
{% endblock base_content %}

Make sure that the new template is loaded instead of the default one (e.g. by looking at the order of apps in INSTALLED_APPS).

aacimov commented 7 months ago

Hi @fsbraun,

Thanks for the quick answer and a suggestion. That would be somewhat of overriding any of the default plugin templates, am I correct?

Just consider adding a note that {% block content %} should be used for the default, out of the box behaviour to the documentation. There could be people naming the main content block in their own names.

It's just a suggestion from my end.

Thanks a lot.

fsbraun commented 7 months ago

@aacimov Can I encourage you to add this information to the readme file?

aacimov commented 7 months ago

@aacimov Can I encourage you to add this information to the readme file?

Of course. No problem. Just point me to the process on how to do it properly.