{"id":3033,"date":"2017-10-27T10:26:02","date_gmt":"2017-10-27T08:26:02","guid":{"rendered":"https:\/\/www.nieuwsmarkt.nl\/?p=3033"},"modified":"2017-10-29T18:36:04","modified_gmt":"2017-10-29T17:36:04","slug":"conditional-placement-of-things-based-on-field-content","status":"publish","type":"post","link":"https:\/\/www.nieuwsmarkt.nl\/nl\/blog\/2017\/10\/27\/conditional-placement-of-things-based-on-field-content\/","title":{"rendered":"Conditional placement of &#8216;things&#8217; based on field content"},"content":{"rendered":"<p><strong>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.<\/strong><!--more--><\/p>\n<blockquote><p>The base of &#8216;getting things done&#8217; is Beaver Themer, Pods and the Pods Beaver Themer Add-on<\/p><\/blockquote>\n<p>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.<\/p>\n<p>When we started the first setup was very simple. Each exhibition was &#8216;just a page&#8217; (without a fixed content structure) and each page could be accessed through the menu. But as &#8216;things&#8217; 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 &#8216;came in&#8217;, with custom post types and custom fields. Each exhibition (we called the CPT base &#8216;event&#8217;) 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:<\/p>\n<ul>\n<li>more information link<\/li>\n<li>booking form link<\/li>\n<\/ul>\n<h3>Conditional<\/h3>\n<p>In our non-conditional approach we made these field &#8216;required&#8217;, since the button would have to go &#8216;somewhere&#8217;. In our conditional approach we had to deselect &#8216;required&#8217;, since we want to make a condition based on the fieldvalue itself.<\/p>\n<p><a href=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/10\/buttons-conditional.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3045 alignright\" src=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/10\/buttons-conditional.jpg\" alt=\"\" width=\"485\" height=\"238\" srcset=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/10\/buttons-conditional.jpg 485w, https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/10\/buttons-conditional-300x147.jpg 300w\" sizes=\"auto, (max-width: 485px) 100vw, 485px\" \/><\/a><\/p>\n<p>Without conditions these buttons would &#8216;always be there&#8217;, 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:<\/p>\n<ul>\n<li>In case of a past event, booking should not be possible anymore<\/li>\n<li>In case of a future event, where details are not there yet to either make a booking or to get more in-depth information<\/li>\n<\/ul>\n<p>The simple <a href=\"http:\/\/kb.wpbeaverbuilder.com\/article\/462-hide-row-or-module-when-field-connection-is-empty-themer\" target=\"_blank\" rel=\"noopener\">routine<\/a> 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.<\/p>\n<ul>\n<li>Look at this <a href=\"https:\/\/www.orange-management.com\/event\/gulfood-manufacturing-at-dubai-world-trade-centre-oct-31-nov-2-2017\/\" target=\"_blank\" rel=\"noopener\">custom post<\/a>.<\/li>\n<li>And look at <a href=\"https:\/\/www.orange-management.com\/event\/sial-interfood-nov-22-25-2017\/\" target=\"_blank\" rel=\"noopener\">this one<\/a>.<\/li>\n<li>Count the differences&#8230;.. \ud83d\ude09<\/li>\n<\/ul>\n<blockquote><p>Copy the routine and insert it into your functions.php file in your childtheme<\/p><\/blockquote>\n<div id=\"attachment_3047\" style=\"width: 410px\" class=\"wp-caption alignright\"><a href=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/10\/more-information-field.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3047\" class=\"wp-image-3047\" src=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/10\/more-information-field.jpg\" alt=\"\" width=\"400\" height=\"283\" srcset=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/10\/more-information-field.jpg 525w, https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/10\/more-information-field-300x212.jpg 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><p id=\"caption-attachment-3047\" class=\"wp-caption-text\">Do not select &#8216;Required&#8217; to be able to leave the field empty<\/p><\/div>\n<p>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 <a href=\"http:\/\/kb.wpbeaverbuilder.com\/article\/462-hide-row-or-module-when-field-connection-is-empty-themer\" target=\"_blank\" rel=\"noopener\">routine<\/a>, the beginning is there. In the BB facebook group\u00a0<a href=\"https:\/\/www.facebook.com\/groups\/beaverbuilders\/permalink\/886520558173961\/\" target=\"_blank\" rel=\"noopener\">Chinmoy Kumar Paul<\/a> 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.<\/p>\n<p><a href=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/07\/fieldsfilter.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft wp-image-2758\" src=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/07\/fieldsfilter.jpg\" alt=\"\" width=\"501\" height=\"269\" srcset=\"https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/07\/fieldsfilter.jpg 1024w, https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/07\/fieldsfilter-300x161.jpg 300w, https:\/\/www.nieuwsmarkt.nl\/wp-content\/uploads\/2017\/07\/fieldsfilter-768x413.jpg 768w\" sizes=\"auto, (max-width: 501px) 100vw, 501px\" \/><\/a><\/p>\n<p>We created a simple screenshot on how we think about a more interactive approach to set &#8216;<strong>field conditions<\/strong>&#8216; 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?<\/p>\n<p>Not all modules are very easy to configure with &#8216;just a simple&#8217; field condition. If you use the text editor module, have a look at &#8216;<a href=\"http:\/\/kb.wpbeaverbuilder.com\/article\/517-conditional-shortcodes-for-field-connections-themer\" target=\"_blank\" rel=\"noopener\">conditional shortcodes<\/a>&#8216; to get it done the right way. (This link thanks to Bernhard Gronau).<\/p>\n<p>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:<\/p>\n<pre><\/pre>\n<h3>Powerful<\/h3>\n<p>Field conditions will be for sure add a powerful value to real database publishing with WordPress.<\/p>","protected":false},"excerpt":{"rendered":"<p>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.<\/p>","protected":false},"author":1,"featured_media":3045,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[87],"class_list":["post-3033","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-test","tag-fieldconditions"],"_links":{"self":[{"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/posts\/3033","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/comments?post=3033"}],"version-history":[{"count":3,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/posts\/3033\/revisions"}],"predecessor-version":[{"id":3072,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/posts\/3033\/revisions\/3072"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/media\/3045"}],"wp:attachment":[{"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/media?parent=3033"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/categories?post=3033"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nieuwsmarkt.nl\/nl\/wp-json\/wp\/v2\/tags?post=3033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}