Skip Navigation

[Resolved] View within a template – display values from outside the view

This thread is resolved. Here is a description of the problem and solution.

Problem:

Displaying custom fields from the current page being rendered.

Solution:

You can display the current single book post information with item attribute: item="$current_page"

For example:

https://toolset.com/forums/topic/view-within-a-template-display-values-from-outside-the-view/#post-2106387

Relevant Documentation:

https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

This support ticket is created 3 years, 5 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 6 replies, has 2 voices.

Last updated by Bob 3 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#2106379

Bob

I have a template displaying a type (book).
Within that there is a view displaying related fields from a related type (members that have borrowed the book).
What I'd like to do is add a field from the book inline within the view.
I am displaying everything I want to but it would be handy to get a particular field from the book into the view based on the related member.

#2106387

Hello,

I assume we are talking about the single book post.

If it is, you can display the current single book post information with item attribute: item="$current_page"

For example:

[wpv-post-link item="$current_page"]

More help:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

$current_page is used to retrieve data from the current page being rendered. It can be used inside a View loop to obtain data from the page on which the View is being rendered.

#2106391

Bob

I'll check out the reference.
Sorry I didn't explain but it's not the link what I need is a custom field from within the book record

#2106393

Types shortcode supports the "item" attribute too, for example:
[types field="my-singlelinetext" item="$current_page"][/types]

More help:
https://toolset.com/documentation/customizing-sites-using-php/functions/#textfield

#2106397

Bob

That sounds good - I'll read the docs and, fingers crossed, close the ticket.
Thanks Luo!

#2106445

Bob

Thanks Luo - works a treat!

#2106467

Bob

My issue is resolved now. Thank you!