Skip Navigation

[Resolved] Get the current pages’s details

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

Problem:
How can I access details about the "current page", for example from within a View that is inserted in any page, how can I display data about the page where the View is inserted to, inside the View?

Solution:
You can always use item="$current_page
This is forcing any Views ShortCode that supports the item attribute to read (and display) data from the current "page or post container" whereto the ShortCode is inserted inside any View or Content Template

Relevant Documentation:
https://toolset.com/documentation/user-guides/views/views-shortcodes/item-attribute/

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

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 2 replies, has 2 voices.

Last updated by joshH 4 years, 3 months ago.

Assisted by: Beda.

Author
Posts
#1437075
Screen Shot 2020-01-02 at 8.35.29 PM.png

I am trying to:
I have the scenario where I have players who can be assigned to more than one team, so I have a custom field called Team ID that is set to be a repeating field. For each team the player gets assigned to, the team id is added to their post. However, when I select the team and get the list of players for that team, I need to be able to view the player's profile so I can manage their assignment to the team(s) their assigned to.
However, when I try and pass the current team ID via the URL, because the player has multiple team IDs, all of them show up in the URL, which causes a bunch of stuff to break. H

Link to a page where the issue can be seen:
hidden link

I expected to see:
I was hoping I would be able to maintain the single team id that I had been viewing. You can see the multiple team id's in the url at the bottom of the screenshot. However, just below the game title, you can see the Team ID i'm currently viewing. I only want to pass that value, not all team ID's in the player's post.

Instead, I got:

#1437631
teamId.png

Just pass the Current page/posts' ID to the HTML where you generate the "manage" button's URL

In the View with ID 319 you added the HTML for the Button with class "button small orange" in a "col-md-3" DIV.
I assume you used ShortCodes to build the dynamic link.

You could just remove that ShortCode of the repeating field, as all you want here is the actual ID of the current team, which in the best case would be the current page.
So you could insert a ShortCode like wpv-post-id item="$current_page" in there.
This would ensure to take the ID of the current page (current team in this case) and plot it into the Button's Link, just as now you plot the repeating field, but it'll pass only (the needed) one ID of the team.
https://toolset.com/documentation/user-guides/views/views-shortcodes/item-attribute/

However that's not the case, you only know the Team ID from the URL parameter of the current View.
So you'd have to work with the wpv-search-term ShortCode.
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-search-term

For example, you can render the ID of the Team being viewed (knowing its URL parameter) by:
[wpv-search-term param="tid"]

This would show only the value of the URL parameter "tid", no matter where you insert this ShortCode.

Now this time, if you insert this in the HTML to build the button's URL, if clicking on it, you'd pass only that Team ID to the URL.

Is that resolving the issue?

#1439845

This solved my issue, thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.