RaythaHQ/raytha

Custom liquid func for GetContentTypeByDeveloperName

Closed this issue · 1 comments

We should add a new custom liquid function for getting content type by developer name.

Example usage:

{% assign contentType = get_content_type_by_developer_name('posts') %}
{{ contentType | json }}

This would be very useful if you want to create dynamic sidebar menus for things like filtering and sorting by the different field types. Otherwise you have to hardcode the values.

To be added here:

This code would pull out the categories field on the posts content type and loop through the choices in the drop down box and gets the developer name and outputs links accordingly.

{% assign contentType = get_content_type_by_developer_name('posts') %}
{% assign categoriesField = contentType.ContentTypeFields | where: "DeveloperName", "categories" | first %}
{{ contentType | json }}
<hr/>
{% for choice in categoriesField.Choices %}
	<a href="{{ PathBase }}/{{ category.DeveloperName }}">{{ choice.Label }}</a>
{% endfor %}