Skip Navigation

[Resolved] Conditional output?

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.

This topic contains 2 replies, has 2 voices.

Last updated by thomasS-11 5 years, 9 months ago.

Assigned support staff: Waqas.

Author
Posts
#268522

Hi.

Im trying to output a image if there is no file uploaded in custom file field with types.

If there is a file uploaded in custom file field from types, i want the image to link to it.

I have tried viewing the conditional output documentation but i cant understand anything from it..
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

Where do i get the field that should be checked for a value?

#268745

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

You can use following short codes to just return the file path, which you can ultimately test for the availability in [wpv-if]. The supported short codes for displaying file field value are:

[types field="my-file" ouput="raw"][/types]
By default this outputs formatted file field, while output="raw" makes it to return the file path.

[wpv-post-field name=??wpcf-my-types-custom-field??] 
This by default outputs raw data and doesn't require the output="raw" attribute.

You can test for the field as below:

[wpv-if evaluate="'[types field="my-file" ouput="raw"][/types]' != ''"]
        [types field="my-file"][/types]
[/wpv-if]

The above code will output a formatted hyper link to the file, if it wasn't empty. Please notice the use of [types] field short code with and without output="raw" attribute.

For a complete list of available short codes for Types and Views, please see following user guides:

- https://toolset.com/documentation/views-shortcodes/#wpv-post-field
- https://toolset.com/documentation/functions/#file

Please let me know if I can help you with anything related.

#271447

Thank you very much 🙂 - eventhough the code shows red in the output editor it still works somehow.. is it suppose to show red? (thought that ment error in code)