Skip to main content

Custom Data

CleanSlate Theme Development Tutorial Series
Video #21 Custom page data

Custom data attributes act like text attributes for your page or site. You can use them for any number of uses including structuring text content on a faculty profile, adding a class to a <div> that is easily editable by a content author, or for entering a site-wide calendar category. These are just a few examples among many of what you could do with Custom Data for your page or site.

How to use Custom Page Data attributes

We’ll first look at how custom data interacts with pages:

  1. Add a custom_data_attributes entry to the theme config.yml file:

    config.yml Example:

    custom_data_attributes:
     - key_1
     - key_2
     - example_3
     - some_word_4
    

    The attribute keys can be named anything you want and include spaces, but we reccommend avoiding crazy punctuation—treat them more like programming variables.

    Data attributes defined in the config.yml will be available to all pages. Attributes defined in a template will only be available to pages that are assigned that template, in addition to the global attributes defined in config.yml—if any.

  2. Maintain the data via the Custom Data tab on the Page Properties form.
  3. Consume the data via the <r:page:data name="key_1"/> tag within your templates.

    Example:

    <r:page:data name="key_1" />
    

Now that you understand the basics of custom page data, check out how to specify options for your Custom Page Data attributes.

How to use Custom Site Data attributes

CleanSlate Theme Development Tutorial Series
Video #22 Custom site data

Sometimes, you may want page attributes, but you want them to be “global”. This is where Custom Site Data attributes are helpful. They follow most of the same rules as Custom Page Data. The only difference is that they cannot be defined via a template.

  1. Define the values in config.yml.

    config.yml file:

    custom_site_attributes:
      - site_1
      - cal_code
      - special_id
    
  2. Call the Custom Site Data in your template:
    <r:site:data name="site_1" />
    
  3. Once you have the values defined in config.yml, push and sync your theme, then enter the data in Manage > Settings > Data:

    Screenshot of Manage > Settings > Data

Custom Page Data in Liquid behaves almost identically to how it does in Radius—with one key difference: how you call the custom data in your template:

Radius: <r:page:data name="key_1"/>

Liquid: {{ page.data.key_1 }} OR {{ page.data["key_1"] }}

Custom site data

Again, custom site data in Liquid behaves almost identically to how it does in Radius—it just has a slightly different syntax when included in templates:

Radius: <r:site:data name="site_1" />

Liquid: {{ site.data.site_1 }} OR {{ site.data["site_1"] }}

Last updated on July 20, 2022.

We welcome all questions, feedback and bug reports. If you're having an issue, we usually need the following information:

  • A brief description of the issue
  • A link to the page where you saw the issue
  • Screenshots that illustrate the problem - How do I take a screenshot?

Kindly email CleanSlate@mail.wvu.edu for help or use the form on the request help page.