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.
Hi, I'm using this code in a View that you can see here
The first conditional works correctly and returns the URL of the resource file.
The second conditional does not work, and the link returns the URL of the current page.
<div class="resource"> [wpv-conditional if="( NOT(empty($(resource-title))) )"] <a href="[types field="resource-file" link="true" output="raw"][/types]" target="blank"> [wpml-string context="wpv-views"] Download [/wpml-string] [types field="resource-title" output="raw"][/types] </a> [/wpv-conditional] [wpv-conditional if="( $(resource-title) eq '' )"] <a href="[types field="resource-file" link="true" output="raw"][/types]" target="blank"> [wpml-string context="wpv-views"] Download this resource [/wpml-string] </a> [/wpv-conditional] </div>
Please excuse me if this is a stupid question, I must be tired at the end of the long week, but I can't seem to see what I'm doing wrong!
Hello. Thank you for contacting the Toolset support.
I would like to know what is the field type of resource-file field? URL or File?
Considering the field is type of URL: Could you please try following code:
[wpv-conditional if="( $(resource-title) eq '' )"] <a href="[types field="resource-file" output="raw"][/types]" target="_blank"> [wpml-string context="wpv-views"] Download this resource [/wpml-string] </a> [/wpv-conditional]
Hi Minesh, thanks for getting back to me -
sorry I hadn't specified that the 'Resource-File' field is a 'File' type field.
I'm still quite stumped to understand why the first conditional will work and not the second :/
Well - I need to understand here what you want to display. The conditional statement translates that if resource file equal to empty (no value) - then what you want to display?
The second condition is resource file is empty and still you want to display resource file even though resource file value is empty.
to clarify in detail the intended purpose of this string -
There are 2 fields belonging to the Resource post type.
Resource Title (optional)
Resource File (required)
If the Resource has been given a title
the string needs to output <a href="resource-file-url">Download 'resource-title'</a>
If the Resource has not been given a title
(which it may not have, as it may have not yet been translated via wpml)
the string needs to output <a href="resource-file-url">Download </a>
Its the second conditions output href parameter that is not being formed correctly.
Does this help to understand the issue?
Thanks again! sorry for long thread!
Can I have problem URL to check whats happening when you say second href parameter not formed correctly. Whats your expected output?
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).
I have set the next reply to private which means only you and I have access to it.
OOOOH. I'm so sorry. I see know!
Users have added a whole bunch of Resource posts without uploading any resource.
I really didn't expect that. I'm SOOO sorry to waste your time.