PAGES

Pages - Accessing Page Data

6min
discover liquid tags that you can use to output and capture data globally available on pages page content you can customise content on pages by navigating to your page within cms / pages and then scrolling to the code editor section at the bottom of the page from here you can use the toolbox to add in custom content sections change the order of sections by copying the liquid tags and then pasting them in the desired order liquid tags url parameters {{context location pathname}} outputs the full url path such as "/first part/second part" {{context params slug}} outputs the first part of your url path such as "/first part" {{context params slug2}} outputs the second part of your url path such as "/second part" {{context params myparam}} outputs the value of ?myparam=true page data {{context | json}} outputs the full array of page data {{context page metadata}} outputs the metadata of the page, though meta fields are usually automatically outputted for you {{context page metadata name}} outputs the name field of the page example page header in this example, we check to see if the page name exists or not, as webapp pages output their name differently if there is a page name, it will display it, if not it will output the webapp name instead {% if context page metadata name != undefined %} {{context page metadata name}} {% else %} {{context exports webapp 1 data result items\[0] name}} {% endif %} example of url based breadcrumbs this takes the url path of the page, splits it based on / and titleizes the items {% assign slugsplit = context location pathname | remove first '/' | split '/' %} home {% for item in slugsplit %} {% if forloop last == true %} {{item | titleize}} {% else %} {{item | titleize}} {% endif %} {% endfor %}