Jump to content

Recommended Posts

Posted (edited)

So I'm trying to create a little page builder of sorts for the project section of a porfolio site using a section repeater.
The repeater includes fields for creating various section options to build out a page (1xfull-width screen image, image+txt, txt+image, 2ximages, triptych, etc.).
I added a "section-type" radio field with layout options so I can use if statements in the code to change what markup will be created in the template.

The screenshot below shows my repeater as it is now, but I'd like to use field dependencies to hide fields that are not required for the chosen layout type.
The problem is - I just can't manage to get the "Show this field only if..." to work for partial text matches or OR statements.

Taking the heading field as an example -- I only managed to hide the heading field with the following, and only for that one case: section_type%=heading_txt
I tried using OR statements, but this didnt work either: section_type%=heading_txt|txt_heading
Partial matching like this doesnt seem to work: section_type%=heading

Am I missing something obvious?
Would really appreciate any help.


1=single_image
2=two_images
3=three_images
4=txt_image
5=image_txt
6=heading_txt
7=txt_heading
 

PageBuilder.jpg

showonlyif.jpg

Edited by ai_slop
Posted (edited)

Thanks @monollonom I feel silly now 😅 I thought I had tried using values. I had used a round about way of getting the text values to work like an OR statement by elimination. I've updated to use numbers instead. Still not entirely sure why "section_type<=5" didnt work though.

I've included what worked below in case other PW newcomers find it useful:

heading
section_type!=single_image, section_type!=two_images, section_type!=three_images, section_type!=txt_image, section_type!=image_txt
section_type=6|7

text_area
section_type!=single_image, section_type!=two_images, section_type!=three_images
section_type=4|5|6|7
  
project_image_1
section_type!=txt_heading, section_type!=heading_txt
section_type<=5 (doesn't work)
section_type=1|2|3|4|5
  
project_image_2
section_type!=single_image, section_type!=txt_image, section_type!=image_txt, section_type!=heading_txt, section_type!=txt_heading
section_type=2|3
  
project_image_3
section_type!=single_image, section_type!=two_images, section_type!=txt_image, section_type!=image_txt, section_type!=heading_txt, section_type!=txt_heading
section_type=3


By the way, do you think using a large repeater in this way (like a mini page builder) is bad practice or performant enough?
I know ProFields exists but I'm not sure how different this is performance wise

Edited by ai_slop
Posted
6 hours ago, ai_slop said:

I know ProFields exists but I'm not sure how different this is performance wise

Given RepeaterMatrix is based on Repeater there are no differences performance wise. Actually I did it exactly this way for a project before I purchased ProFields so there’s nothing wrong with that. It’s (mostly) about convenience.

 

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...