Open Enkil11 opened 2 months ago
I've found a workaround. I replaced "spritePath": "sprites/icons.svg" with "spritePath": "/static/sprites/icons.svg" in the json file. I created a custom filter:
@register.filter(name='patch_icon')
def patch_icon(value, arg):
spaced_prefix = '{} '.format(arg)
text = value.replace(spaced_prefix, '')
return text
which I used in my template:
{% load cms_tags static extra_filters %}
<span class="icon {{ instance.attributes.class }}"> <svg role="presentation"> <use xlink:href="{% static 'sprites/icons.svg' %}#{{ instance.icon|patch_icon:'svg-icon' }}"></use> </svg> </span>
I hope this helps!
I am attempting to utilize the djangocms-icon module to incorporate my own SVG icons into my Django CMS project. Following the documentation, I have successfully added Material Design icons. However, I encounter issues when adding my custom SVG icons.
In my settings.py, I added the following code:
I have created an iconset.json file at the root of my project:
I have also created my icons.svg file in static/sprites/icons.svg:
Additionally, I created templates/djangocms_icon/svg/icon.html:
The issue arises in the generated markup. In the icon addition widget inspection, there is a missing /static/ before sprites/icons.svg#svg-icon-card. Additionally, in the page render, there is an extra svg-icon class after the # in the xlink. The generated markup looks like this:
There is a missing /static/ before sprites/icons.svg#svg-icon-card.
There also an issue in my rendered page with an extra "svg-icon " after the # in the xlink.
How can I resolve these issues?