Tell us what you are trying to do?
- Output a link wth only the filename on a [types field].
Is there any documentation that you are following?
- I thougth I could use something like format="%%TITLE%%" but the block gets invalid as I modify it
Is there a similar example that we can see?
[wpv-for-each field="wpcf-adicionales"][types field='adicionales' output='normal'][/types][/wpv-for-each]
Outputs a link to: hidden link
I need to output a link with only the filename and not all the URL.
It would be nice to find some documentation that adresses that shortcode argument but I cant find it
What is the link to your site?
sorry, It's private.
Sorry guys, another question... how can I add a notice if there are no documents?
[wpv-for-each field="wpcf-otros-documentos"]
[get_file_name_custom url="[types field='otros-documentos' output='raw'][/types]"]<br>
[/wpv-for-each]
The above shortcode works, but shows nothing if there is no files.
Hi,
Welcome to Toolset support. There is no default functionality in Toolset to extract filename from URL. That is considered a custom development.
You can hire a developer to do so:
https://toolset.com/contractors/
In general you will need a custom shortcode for that. Something like this:
function get_file_name_custom_shortcode($atts) {
$atts = shortcode_atts(array('url' => ''), $atts);
$url = $atts['url'];
if (empty($url)) return '';
return basename($url);
}
add_shortcode('get_file_name_custom', 'get_file_name_custom_shortcode');
And the usage of shortcode should be something like this:
[wpv-for-each field="wpcf-otros-documentos"]
[get_file_name_custom url="[types field='otros-documentos' output='raw'][/types]"]<br>
[/wpv-for-each]
This loop will display only the filenames of the files in the otros-documentos field.
Please note: We did not test the code above. It is just to give you an idea how you need to go forward.
To show a message when there are no files in the otros-documentos field, you can use Toolset's conditional shortcodes. Here's how:
[wpv-conditional if="( $(wpcf-otros-documentos) ne '' )"]
[wpv-for-each field="wpcf-otros-documentos"]
[get_file_name_custom url="[types field='otros-documentos' output='raw'][/types]"]<br>
[/wpv-for-each]
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-otros-documentos) eq '' )"]
<p>No documents available.</p>
[/wpv-conditional]
Thanks.