Skip Navigation

[Closed] Grandparent URL

This support ticket is created 8 years, 4 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by Luo Yang 8 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#351801

Ben
Screen Shot 2015-12-05 at 19.28.32.png
Screen Shot 2015-12-05 at 19.28.22.png

I am trying to: Show the URL of a Grandparent

I visited this URL:

I Tried : <a href='[wpv-post-url id="$venue"]'>[types field="show-time"][/types]</a>

Instead, I got: The parent url, not the grandparent (Venue)

--

The view in question is displayed on my home page, via PHP with
[code]<?php echo do_shortcode('[wpv-view name="upcoming-bookings-fpage-parent-view"]'); ?>[/code]

This view displays upcoming concert dates (Bookings) , Venues, and Showtimes.

The relationship is like this
Venue: ( parents: NONE, children: Bookings )
Bookings: ( parent: Venue, Children: Shows )
Shows: ( Parent: Bookings, Children: NONE

The parent view: "upcoming-bookings-fpage-parent-view"
Displays: Venue Name, Booking Date & CHILD VIEW: "booking-show-detail"

The Child View: "booking-show-detail"
Displays: the Showtimes field of the post type "Shows"
With show-times, I would like to link to the GRANDPARENT Venue

-- I've tried the steps in: "https://toolset.com/documentation/user-guides/displaying-fields-grandparents/"
--In the CHILD VIEW: "booking-show-detail"
I created a new content template (grandparent-url-link) as per the instructions, and added:
<a href='[wpv-post-url id="$venue"]'>[types field="show-time"][/types]</a>

BUT - its still displays the url for the BOOKING, not the VENUE 🙁

I've added screen shots of the fields so you can see.

#351955

Dear Ben,

How do you put the content template(grandparent-url-link) into the child view?
It should include attribute id="$bookings", for example:

[wpv-post-body  id="$bookings"view_template="grandparent-url-link"]

More help:
https://toolset.com/documentation/views-shortcodes/#wpv-post-body
id (opt):
'$parent' | 'post-id' | '$custom post name'
See Displaying Fields of Parent Pages

#353226

Ben
Screen Shot 2015-12-11 at 15.49.13.png
Screen Shot 2015-12-11 at 15.46.18.png

Thank you Luoy. I've now got the correct link being displayed, but in the loop, rather than showing all the child showtimes, it is now only repeating the last child in the loop.

In the picture attached, the first showtime should be 6pm, NOT 8pm. The second screen shot shows the booking fields as they are filled out.

The Loop output is as follows:

[wpv-layout-start]
[wpv-items-found]
<ul class="unstyled">
<!-- wpv-loop-start -->
   <wpv-loop> 
          <li>
			[wpv-if f1="wpcf-show-status" ticketing="wpcf-ticketing-url" evaluate="!empty($ticketing) AND $f1 = 'scheduled' "]<a href="[types  raw="true" field="ticketing-url"][/types]">[types field="show-time"][/types]</a><br/><i class="fa fa-ticket"></i> <i class="fa fa-external-link-square"></i>[/wpv-if]
            
          [wpv-if f1="wpcf-show-status" ticketing="wpcf-ticketing-url" evaluate="empty($ticketing) AND $f1 = 'scheduled' "] [wpv-post-body id="$booking" view_template="grandparent-url-link"] <i class="visible-desktop fa fa-ticket"></i>[/wpv-if]
           
          [wpv-if f1="wpcf-show-status" evaluate="$f1 = 'canceled'"]<del>[types field="show-time"][/types]</del> | [types field="show-status"][/types][/wpv-if]
                     
          [wpv-if f1="wpcf-show-status" evaluate="$f1 = 'sold-out' "][types field="show-time"][/types] | <em>[types field="show-status"][/types]</em>[/wpv-if]    

          </li>
   </wpv-loop>
   <!-- wpv-loop-end -->
</ul>
[/wpv-items-found]
[wpv-no-items-found][wpml-string context="wpv-views"] TBC [/wpml-string][/wpv-no-items-found]
[wpv-layout-end]

The view template:
<a href='[wpv-post-url id="$venue"]'>[types field="show-time"][/types]</a>

#353371

Ben

Luoy,
So I've managed to resolve both the issue of retrieving parent urls AND the issue of the loop, only outputting the last child show, again and again. I found that breaking apart the view query for the parent url ( [wpv-post-url id="$venue"] ) into two parts we could get both to work, however it's a bit nonsensical. Perhaps you have a better way of doing it?

One observation, that might be passed to the Dev team: The "Templates for this View" seems to require [wpv-post-url id="$venue"] to be wrapped in an html element. Without being wrapped in an element, it appears the shortcode would not be processed, and this causes the shortcode text to breaks the HTML output to screen.

Attempt 1)
The following does *NOT* work, as the template shortcode is not rendered:

Loop Output (abbreviated):

 <a href="[wpv-post-body id="$venue" view_template="grandparent-url-link"]">[types field="show-time"][/types]</a>

Template for this View:

[wpv-post-url id="$venue"]

Attempt 2)
In this iteration also does *NOT* work. The parent url is correct, but the loop does not correctly render the child showtimes:

Loop Output (abbreviated):

[wpv-post-body id="$venue" view_template="grandparent-url-link"]

Template for this View:

<a href="[wpv-post-url id="$venue"]" >[types field="show-time"]</a>

Attempt 3)
The following *DOES* work, but because the opening and closing html elements are split across the loop and template, is very hard to read and maintain:

Loop Output (abbreviated):

[wpv-post-body id="$venue" view_template="grandparent-url-link"][types field="show-time"]</a>

Template for this View:

<a href="[wpv-post-url id="$venue"]">
#353513

Thanks for the feedback, could you duplicate same problem in a test site, and fill below private detail box with login details, also point out the problem page URL and content template URL, I need a live website to test and debug this problem, thanks

The topic ‘[Closed] Grandparent URL’ is closed to new replies.