Skip Navigation

[Resolved] If custom field is blank, how do I remove the space?

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 7 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 6 replies, has 2 voices.

Last updated by Christian Cox 7 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#580012

Tell us what you are trying to do? I'm using Beaver Builder with views to display staff members. If they have a custom field value in the special title, I'd like it to display, otherwise I'd like the space created removed.

Is there a similar example that we can see?

This is what I've got. hidden link The special title in this case is "Founder of White & Co" for Ivan White. Tom White and James Eric do not have a special title but you can see there is a blank space visible where the results would display if the field had been completed.

#580401

Hi, I'll try to help. I assume the fields are placed in a Content Template, and you're editing that with Beaver Builder. Is that accurate? If so, you may need to use Conditional HTML to hide the line break. In the Content Template, if you use the "Text" tab instead of the "Visual" tab, you may see something like this:

...other stuff before your special title field
<br />
[types field="yourfieldslug"][/types]
<br />
...other stuff after your special title field

If your field is empty, then this results in two line breaks back to back, leaving an empty space. You can prevent this by surrounding the field and following break tag with conditional HTML:

...other stuff before your field
<br />
[wpv-conditional if="(NOT(empty($(wpcf-yourfieldslug))))"]
  [types field="yourfieldslug"][/types]
  <br />
[/wpv-conditional]
...other stuff after your field

Let me know if I've guessed incorrectly about how your code is set up. If possible, please show me a screenshot of the special title field shortcode, and how it's placed in the wp-admin area.

More about conditional HTML here:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/

#581255

I'm still having some trouble with the output. It's putting extra <br> tags even when there is no content to output and I've used the conditional in multiple areas. Example: Greg Vandertop has no professional accreditations so I've left that field blank. I added the conditional html and now I'm getting 3 <br> tags after his email address.

Similar for the button. For the first 3 entries, it's added an extra <br> tag even though the rest are not.

hidden link

#581293

Hi, it might be easiest for me to take a look in your wp-admin area to recommend some changes. If that's okay with you, please provide login credentials in the private reply fields here.

#581720

Also, I don't know if you can help me with this but for staff members who are assigned to the category finance, I need those to display with a custom template header/navigation I've set up.
Okay I'd recommend creating a separate ticket for this, because it's a bit more complex than a one or two sentence answer. Let's investigate it separately please.

You can see the difference accounting page:
I think I have the line spacing on these two pages more consistent now, can you confirm? It had to do with the line breaks and conditionals.

Where I can't figure it out is for the single view of the finance staff, how can I assign it to a custom page template?
In the Content Template dashboard, you can see that the "Staff Members (single)" Content Template is assigned to all Staff Member single posts. If you want to modify that for specific posts, you can either:
- Set a different Content Template in each individual Staff Member's post editor (top right corner of the editor screen)
- Force a specific Content Template with some custom code utilizing the wpv_filter_force_template filter API. More information here -https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_force_template

#581722
2017-10-24_1057.png

The display is definitely better but there is still differences in the buttons. Please see the attached image for reference.

#581740

Different issue here, because the button code is rendered completely by Beaver Builder and we don't have the ability to place conditional HTML inside the button output. Another ticket includes a response from Beda that describes the problem:
https://toolset.com/forums/topic/content-template-adding-extra-p-and-br-tags-with-beaver-builder/#post-540027

As a workaround, please try adding the following code to both pages using the "Body Scripts" field in the page editor:

jQuery(document).ready(function(){
  jQuery('.fl-button br:first-child').each(function(index, item) {
    jQuery(item).slideUp();
  });
});

The forum ‘Types Community Support’ is closed to new topics and replies.