Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom liquid func for GetContentTypeByDeveloperName #113

Closed
apexdodge opened this issue Apr 3, 2023 · 1 comment
Closed

Custom liquid func for GetContentTypeByDeveloperName #113

apexdodge opened this issue Apr 3, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@apexdodge
Copy link
Contributor

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:

@apexdodge apexdodge added the enhancement New feature or request label Apr 3, 2023
@apexdodge apexdodge added this to the v1.0.5 milestone Apr 3, 2023
@apexdodge
Copy link
Contributor Author

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 %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant