In the Beaver Builder Knowledge base there is a little but powerful routine which makes it possible to show or hide a row or a module based on the content of a field connector. That is the base of the power of conditional database publishing within WordPress. Website strip-down of orange-exhibition management.
The base of ‘getting things done’ is Beaver Themer, Pods and the Pods Beaver Themer Add-on
Orange-exhibition management is a dutch agency for exhibitions in the foodsector in amongst others Dubai, China, Indonesia and Canada. The main content is about detailed information around exhibitions at various locations and dates together with the possibility to reserve exhibition space for exhibitors. It is a business-to-business website, so no booking for visitors.
When we started the first setup was very simple. Each exhibition was ‘just a page’ (without a fixed content structure) and each page could be accessed through the menu. But as ‘things’ developed yhe number of exhibitions increaded and with that also the need for some more structure in managing past, present and future exhibitions. That is where a database approach ‘came in’, with custom post types and custom fields. Each exhibition (we called the CPT base ‘event’) would get a set of custom fields to get the job done. For making the right setup of fields, we needed to do an in-depth examination of the content which needed to be accessible by individual fields. We created two fields we used for our first conditional approach. Two fields were created for our conditional approach:
- more information link
- booking form link
In our non-conditional approach we made these field ‘required’, since the button would have to go ‘somewhere’. In our conditional approach we had to deselect ‘required’, since we want to make a condition based on the fieldvalue itself.
Without conditions these buttons would ‘always be there’, since we created the single custom post temple in Themer. However there are a couple of situations in which our customer did not want visitors to be able to choose one or both buttons:
- In case of a past event, booking should not be possible anymore
- In case of a future event, where details are not there yet to either make a booking or to get more in-depth information
The simple routine in the Beaver Themer knowledge base just gives the possibility to either display or not to display a row or module based on the specific field in that row or module. In our case the URL in the button setup is the only conditional field we could define, there is nothing else.
Copy the routine and insert it into your functions.php file in your childtheme
Until now we cannot yet make conditions based on other fieldvalues outside the row or module. And we cannot make any AND/OR combinations yet to combine conditions. But with the little routine, the beginning is there. In the BB facebook group Chinmoy Kumar Paul seems to be developing a more advanced fields conditions plugin to show or hide modules or rows based on multiple conditions. That would be of great value.
We created a simple screenshot on how we think about a more interactive approach to set ‘field conditions‘ with Themer. We are thinking about the areas on which such field conditions could work. Would it be useful to do this for either theme layouts, parts, rows and modules?
Not all modules are very easy to configure with ‘just a simple’ field condition. If you use the text editor module, have a look at ‘conditional shortcodes‘ to get it done the right way. (This link thanks to Bernhard Gronau).
If (for any reason) the address of the event location is not known (yet), in our case we inserted the following conditional in the text editor:
Field conditions will be for sure add a powerful value to real database publishing with WordPress.