0

I have a channel called articles to post image galleries or video's or both.

On the back-end there are two custom fields in that channel (1) a 'channel images' field to add multiple images to the post and (2) a matrix field to add multiple video by (a) adding a valid YouTube or Video URL into a 'video link' field OR (b) via adding the embed code into a textarea field, in which case there is a 3td field, an 'assets' field to add a thumbnail.

On the front-end every article is required to have a thumbnail image. In the source code, I first check if there is an image given in the 'channel images' field, and if so, grab the first image as a thumbnail. If not, I check to see if there is a matrix row and if the 'video link' field is not empty, and if so, grab the YT of Vimdeo thumbnail via that plugin. If that field is empty, I check to see if the embed code textarea field AND assets field are not empty, and grab the assets image as a thumbnail in that case.

This all works except that if the fields are NOT set, the entry is not shown on the page but it IS included in the pagination and number of rendered entries. So if I want to always display 9 entries per page (3 x 3 blocks), and one entry has OR no channel images input, OR no valid video link input, OR no embed code + assets input, I have 8 entries on the page + the pagination total entries does not add up.

You can not set the required field option conditionally when adding a custom field in the CP.

How do I pre-filter the entries based on conditional logic on multiple custom fields before they are rendered?

The search parameter is not sufficient.

0

If you're gonna use Low Search, then the only way to do this properly, is to use a custom filter.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.