1

What is the different between url() and getUrl()

Ex:

   {% set solutionIcon = solution.solutionIcon.one() ?? null %}
   <div class="img-wrapper mt--3 mb-2 mx-auto">
      {% if solutionIcon %}
         <img src="{{ solutionIcon.getUrl() }}" alt="{{ solutionIcon.title }}">
      {% endif %}
   </div>

   {% set solutionIcon = solution.solutionIcon.one() ?? null %}
   <div class="img-wrapper mt--3 mb-2 mx-auto">
      {% if solutionIcon %}
         <img src="{{ solutionIcon.url() }}" alt="{{ solutionIcon.title }}">
      {% endif %}
   </div>
1

They do the same thing. url() is an alias of getUrl(). This is the link from the Craft 2 docs: https://docs.craftcms.com/v2/templating/entrymodel.html#url.

It works the same way in Craft 3, but I can never find anything in the Craft 3 docs.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.