get_content_by_fields
The get_content_by_fields function can be used on any Aurora front-end template to return a Content field value, or even an array with all Content fields and values, based on the parameters provided.
This article describes how to use this function and its various options.
Overview
This is an Aurora template function which allows the embedding of content into templates.
One common use of this is to retrieve a content URL, for example a Buying Guide content page, for a particular group of products. For this example, the content page must have the Custom Fields specified for the content page you wish to retrieve. In the image below, you see the content page has a Custom Field Name of "Buying Guide" and a Custom Field Value of "Tables":

Once these have been saved, you will be able to use this smarty function to retrieve the content page that match the Custom Field Name and Custom Field Value.
Parameters
Parameter | Example Value | Mandatory | Explanation |
---|---|---|---|
custom_field_name | Buying Guide | Y | The Content Custom Field Name you would like to call, as specified on one of your content pages. |
custom_field_value | Tables | Y | The Content Custom Field Value you would like to call, as specified on one of your content pages. |
content_field_name | content_complete_url | N | If provided, it will return the Content Field Value for the content page that matches the parameters above. Other possible content_field_name values are: id count_views page_filename title meta_title meta_description meta_keywords page_canonical page_content content_complete_url |
content_details | OUTPUT | N | If provided, it will return all the content field values in an array. |
default_value | /buying_guide_generic | N | In case the "custom_field_name" and "custom_field_value" don't match a content page, then the function will return the default value set by default_value. |
Usage
Returning the Content Buying Guide URL Using Static Values
This is an example that can be used if you would like to return the content URL using static values
Example
{get_content_by_fields custom_field_name="Buying Guide" custom_field_value="Tables" content_field_name="content_complete_url" default_value="/generic_buying_guide"}
Returning the Content Buying Guide URL Using Product Fields
In this example, you would create a product field called "Buying Guide". For each product, you can specify the field value to that of the content page (in this case Buying Guide) that you would like to reference.
For example: For product "Table XYZ", the "Buying Guide" field value should be "Tables". The smarty function will then return the URL of the content page which has a custom_field_name of "Buying Guide" and a custom_field_value of "Tables".
Example
{get_content_by_fields custom_field_name="Buying Guide" custom_field_value=$product_fields.buying_guide content_field_name="content_complete_url" default_value="/generic_buying_guide"}
Returning Content Values in an Array
This is an example that can be used to return all content values in an array:
Example
{get_content_by_fields custom_field_name="Buying Guide" custom_field_value="Tables" content_details="content"}
and then:
{$content.content_complete_url}
Updated over 2 years ago