Skip Navigation

[Resolved] Forming correct anchor link

This support ticket is created 7 years, 3 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 6 replies, has 2 voices.

Last updated by rubenB 7 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#477225

Hi, I'm using this code in a View that you can see here
hidden link

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!

#477341

Minesh
Supporter

Languages: English (English )

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

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] 

More info:
=>https://toolset.com/documentation/customizing-sites-using-php/functions/#file

#478545

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 :/
Thanks! Ruben

#478565

Minesh
Supporter

Languages: English (English )

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

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.

#478572

Hi Minesh,
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!

#478573

Minesh
Supporter

Languages: English (English )

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

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.

#478742

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.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.