Navigation überspringen

[Gelöst] Use Views Output to Trigger Shortcodes

This support ticket is created vor 4 years, 2 months. 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 -

Zeitzone des Unterstützers: America/Jamaica (GMT-05:00)

Dieses Thema enthält 7 Antworten, hat 3 Stimmen.

Zuletzt aktualisiert von cameronJ-3 vor 4 years, 2 months.

Assistiert von: Shane.

Author
Artikel
#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: versteckter Link ).

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

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

Thanks,
Cam

What is the link to your site?
versteckter Link

#2309987

Nigel
Unterstützer

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: 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: versteckter Link
There is no link now and the shortcode is still not working.

Please Advise,
Cam

#2310293

Shane
Unterstützer

Sprachen: Englisch (English )

Zeitzone: 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
Unterstützer

Sprachen: Englisch (English )

Zeitzone: 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: versteckter 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
Unterstützer

Sprachen: Englisch (English )

Zeitzone: 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.
versteckter Link

The view below displays the repeatable field group.
versteckter 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!