File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -202,24 +202,28 @@ models or forms.
202
202
To render the link field in a template, use the ``LinkDict `` property ``url `` or
203
203
the new template tag ``to_url ``. The ``type `` property returns the link type::
204
204
205
- {% load djangocms_link_tags %}
206
205
{# Variant 1 #}
207
206
{% if obj.link %}
208
- <a href="{{ obj.link|to_url }}">Link</a>
207
+ <a href="{{ obj.link.url }}">Link available </a>
209
208
{% endif %}
210
209
211
210
{# Variant 2 #}
211
+ {% load djangocms_link_tags %}
212
212
{% if obj.link %}
213
- <a href="{{ obj.link.url }}"
214
- {% if obj.link.type == "external_link" %} target="_blank"{% endif %}
215
- >Link available</a>
213
+ <a href="{{ obj.link|to_url }}">Link</a>
216
214
{% endif %}
217
215
218
216
{# Variant 3 #}
219
217
{% with url=obj.link|to_url %}
220
218
{% if url %}
221
219
<a href="{{ url }}">Link available</a>
222
220
{% endif %}
221
+ {% endwith %}
222
+
223
+ {% if obj.link.type == "external_link" %}
224
+ <a href="{{ obj.link.url }}">External link</a>
225
+ {% endif %}
226
+
223
227
224
228
To turn the ``LinkField ``'s ``LinkDict `` dictionary into a URL in python code,
225
229
use the ``url `` property. (It will hit the database when needed. Results are
You can’t perform that action at this time.
0 commit comments