Skip Navigation

[Resolved] Use Views Output to Trigger Shortcodes

This support ticket is created 3 years, 2 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 7 replies, has 3 voices.

Last updated by cameronJ-3 3 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#2309857

Tell us what you are trying to do?

I am trying to get the views output to be recognized as a shortcode and not as formatted text.

I am using leaflet maps and it works perfectly when I manually enter the shortcodes. (As seen in this link here: hidden link ).

When I try and get the views output to work as shortcodes it doesn't work (as seen here: hidden link )

Can you provide any insight on a method that will make this work?

Thanks,
Cam

What is the link to your site?
hidden link

#2309987

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Screenshot 2022-03-07 at 07.34.04.png

Looking at the markup on your failing example (screenshot), the shortcodes are not correctly formed, instead of a url for the gpx attribute they contain a link and that link uses the same double-quotes for its href attribute as wraps the gpx attribute, hence breaking the shortcode.

So, however you are creating this shorcode, you need to output the raw url rather than a link, and you need to avoid using the same quotes. (But if you output the url as a url and not a link, that problem will likely disappear.)

#2310195

Hello Nigel,

It is still not working. I created a new view: hidden link
There is no link now and the shortcode is still not working.

Please Advise,
Cam

#2310293

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Cameron,

Would you mind allowing us to have admin access to the site so as to look more closely at this issue for you ?

I've enabled the private fields for your next response.

Thanks,
Shane

#2310569

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Cameron,

This should now be working.

The problem was that your shortcode was formatted incorrectly as nigel mentioned. What you had was this below.

      &#91elevation gpx="[wpv-post-body view_template="loop-item-in-gpx"]"&#93<br>

You were passing the entire content template for the view into the shortcode and note that instead of the square brackets, the ascii code for the shortcode is being used.

What I did was to call the Types shortcode directly rather than using the content template. The new format is now this below.


[elevation gpx="[types field='gpx-track' output='raw'][/types]"]

Please let me know if everything is ok now.

Thanks,
Shane

#2310587

Thanks Shane, That Works perfectly.
For some reason the view is outputing this:
[elevation 0=gpx= ]
[elevation 0=gpx= ]

I'm assuming it is null fields from past posts (as seen here: hidden link )

Do you know how I can try and get around that? I tried putting a condition on it that the field wasn't full, but I'm assuming I didn't do it correctly.

Thanks,
Cam

#2310635

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Cameron,

I see where GPX track is a repeatable field group. In this case we're going to have to set things up a little differently.

I've now modified your GPX view to display the nested repeatable field group view to display the correct GPX track according to the post that is being displayed by the view.
hidden link

The view below displays the repeatable field group.
hidden link

Also there is a conditional added that will only allow fields that have values to be displayed.

Please let me know if everything is ok now.
Thanks,
Shane

#2310653

Thanks Shane, your solution works perfectly!