Skip to content

Conversation

@neildcuk
Copy link

Hi there,

I've found this function useful on a site we've built - it essentially lets you build up a params object and use it as an object instead of chaining methods into blocks(). Example template use below:

{% set blocksParams = {
	fieldId: showings.id,
	type: 'time',
	limit: 1000
} %}

{% if accessibilityFilter and accessibilityFilter != 'audio-described' %}
	{% set blocksParams = blocksParams|merge({
		relatedTo: accessibilityFilter
	}) %}
{% endif %}

{% set showingsBlocks = craft.lowblocks.blocksParams(blocksParams) %}

Seems to work well enough for us - although I'm not sure what the id method is for and whether or not bypassing $this->criteria for the new method will cause a problem. Either way, feel free to either pull or implement in your own way - would appreciate you letting us know if you manage to do this without the extra method or you change its name!

This method allows for the use of object-based parameters when
fetching block data. Feel free to rewrite into the class if you
think it adversely affects the workings of the id() method!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant