Skip Navigation

[Resolved] Views – Append content to field if shown?

This thread is resolved. Here is a description of the problem and solution.

Problem:
Views - Append content to field if shown?

Solution:
The workaround would be to wrap your custom field with the Div that holds specific class name and then target the classname with CSS selectors to append the content.

You can find the proposed solution in this case with the following reply:
=> https://toolset.com/forums/topic/views-append-content-to-field-if-shown/#post-1999015

Relevant Documentation:

This support ticket is created 3 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 4 replies, has 2 voices.

Last updated by michaelA-13 3 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#1998961

Tell us what you are trying to do?

Hello! Rather than writing several Conditonals is it possible to append/add text to a views field.

E.g. [types field="broadcast-author"][wpv-conditional if="( $(wpcf-broadcast-author) ne '' )"].[/wpv-conditional]

The conditional is only to display the . if "broadcast-author".

Is there a way to do this directly with the view field.

Like [types field="broadcast-author" append="."]

Thanks

#1999015

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

The workaround would be to wrap your custom field with the Div.
For example:

<div class="append"> [types field="broadcast-author"]</div>

Ad then add the following CSS to the CSS section of your content template or view.

div.append:not(:empty)::after{
content: ".";
}

I think the above solution will help you to resolve your issue.

#1999019

Hi Minesh!

Thx for the CSS solution. But since the content will be different for different fields and cases this is no viable solution.

Michael

#1999023

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I'm afraid that there is no other native solution available. This is the best and short workaround I can think of. 🙂

#1999165

My issue is resolved now. Thank you!