0%

Attributes ID: PRFL-DEV-ATTR

Marketpath CMS Profiles allow you to set up Custom Settings that are validated when saved. These are the “friendly” settings that content editors and site admins update, when necessary.

Profile Attributes are an entirely different type of setting for Profiles. Typically, attributes should only be modified by the code on Live websites. Under normal circumstances, they should not be modified by editors and site admin. For example, if you build a customer portal and give your users a choice for what to show on their dashboard, you can store that preference in an Attribute. And it’s incredibly easy to do so.

Attributes do not have validation and cannot be required fields. They are a free-form dictionary of key/value pairs (fig 1).


Figure 1 - Profile Attributes group

Attributes Liquid Code

To access Attributes in Liquid, you can use any of the following syntax:

{{ profile.attribute_name }}
{{ profile[“attribute_name”] }}
{{ profile.attributes.attribute_name }}
{{ profile.attributes[“attribute_name”] }}

To update an attribute during authentication, use the auth set_setting method:

{% auth set_attribute attribute_name:”Some value” %}

To update an attribute of the currently-logged-in profile, use the set_profile method:

{% set_profile attribute_name:”Some value” %}

You can also remove an attribute:

{% auth unset_attribute attribute_name %}
{% unset_profile attribute_name %}

Attributes in Forms

You can use attributes to pre-fill form fields as well as saving values from submitted forms to profile attributes. To do this, edit the form fields that you want to map and set the “Map to Profile Attribute” (fig 2).

 



Feedback?

Please fill out the form below with your feedback or any questions you may have after working through the "Attributes" lesson.

Your Name
Email 
Feedback / Questions