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

Icons aren't rendered / API mismatch with djangocms-icon #124

Open
Xiphoseer opened this issue Oct 24, 2020 · 7 comments
Open

Icons aren't rendered / API mismatch with djangocms-icon #124

Xiphoseer opened this issue Oct 24, 2020 · 7 comments

Comments

@Xiphoseer
Copy link

Xiphoseer commented Oct 24, 2020

As explained in #101 (comment), the Bootstrap4LinkPlugin currently uses djangocms_icon Icon fields for left_icon and right_icon. These are special CharFields, so the following part in the link/default/link.html template sets instance to a string:

{% with icon_class=instance.icon_left instance=instance.icon_left %}
    {% include "djangocms_icon/includes/icon.html" %}
{% endwith %}

This is not consistent with the implementation of djangocms_icon, specifically the includes/icon.html template, which expects, instance to be an instance of the Icon model. As strings have neither an icon field nor an attributes field, nothing is actually rendered and the icon is missing on the site.

Is this a holdover from some old version? Are the two plugins not supposed to be compatible at their respective latest versions? Was this plugin simply not updated (yet)? What is the intended behavior?

Should Bootstrap4Link switch to a foreign key or change the template to just use the css class string from the Icon field? If you want, I can send a PR that's effectively the solution from the comment on the other issue mentioned above.

@crydotsnake
Copy link
Contributor

Is the issue still current, or can the issue be closed?

@rastytheamateur
Copy link

It seems to be still current with no fix.

@svandeneertwegh
Copy link

svandeneertwegh commented Feb 8, 2022

Problem is still. When i choose icon left and/or icon-right when using bootstrap-link plugin and save plugin. It renders the link and all of it options except no icon: <i area-hidden="true"></i> This missed the fontawesome classes.

@fsbraun
Copy link
Member

fsbraun commented Feb 8, 2022

A work around would be to provide your own includes/icon.html template, e.g.,

<i class="{{ icon_class }}"></i>

You might want to think about adding some spacing to avoid the icon being right next to your link text.

@svandeneertwegh
Copy link

@fsbraun But now you'l break icon plugin. With an if else it is solved.
{% if icon_class %}{{ icon_class }}{% else %}{{instance.icon }} {% endif %}

@fsbraun
Copy link
Member

fsbraun commented Mar 10, 2022

I've taken the above approach in djangocms-frontend (https://github.com/fsbraun/djangocms-frontend) which supports Bootstrap 5. 😄

@i-salameh95
Copy link

i-salameh95 commented Dec 24, 2022

should this workaround fix that the icon not appear when use with link inside django_ckeditor ?

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

No branches or pull requests

6 participants