My CraftCMS Notes

I've decided to keep this as my own Wiki as I go along learning Craft CMS and hopefully this would help anyone who is new to Craft CMS ( just like myself).

Once you have installed Craft CMS , install "Inspector" plugin [ ], this is very helpful to inspect method that in use in the template.

I personally find that this Craft CMS cheat sheet is very helpful in terms on understanding the syntax.

To get fields' values to the Craft CMS template.

Assets - Files uploaded in the entry

{# Retrieve Images from this entry. #}

{% if entry.featureImage|length %} {# To check if value is not NULL. #}

{% for asset in entry.featureImage %} {# ForLoop for entry assets. Assigning entry.featureImage to asset (this will act as KEY) #}

{{asset.url }} {# To retrieve the Image URL #}

{{dump(asset)}} {# this will act like var_dump() in PHP #}

{% endfor %}

{% endif %}


Concatenating strings with value. This is very useful for when you want to have a dynamic value showing.

~" , "~ : you can replace the comma with any strings that want . E.g.: ~" - "~

{% set imageUrl = siteUrl ~" / " ~ asset.url %}