Skip Navigation

[Resolved] Create one View but show parts of each result in different page location

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

Last updated by Luo Yang 4 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#1544645

Hi,
I have a view that display my Clients (custom post type) data (cutosmo_fields) . Simple words a user profile page
I use the Short code option at View;s filter to get the logged in users mail from the current post .
i get the name, the adress, the phone e.t.c

now want to create a users profile page (not within the view itself with html and ccs) but in a regular page that i have created and i am trying to display the field of the result in different partd of the page.
for example : name : show only the custom field name of the results
adress : show only the custom field adress of the results

Is this possible or i have to create a separate view for each of this fields ?

#1545159

If you have the Data (User ID or Post ID) of which you want to display details on a random page, you can pass it in the View as well as a shortcode attribute.

Note, you could for example link from somewhere else to that particular page and pass an URL argument. That could be for example site.com/your-page-with-view/?your_url_param=USER_ID or POST_ID (Replace User iID and Post ID with something that returns the right value.
For example, you can link to that page from within a View, that lists all users.
This way you can always be sure the right user id is passed as a URL parameter.

Then, since the View you will use on the single page would listen to the User ID passed, you could populate that with wpv-search-term
wpv-search-term will allow you to get the value passed to your_url_param like shown here in the first post:
https://toolset.com/forums/topic/wpv-search-term-paramwpv-xxx-display-the-name-and-not-the-slug/

The DOC for that ShorCode is here:
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-search-term

Please let us know if I misunderstood your goals.

#1545285

hi Beda, thanks for the help here,

I think using url params is not an option because i have one page (for example myProfile) that has the same URL for all my users (e.g. site.com/myProfile).

inside this i have a view that show all the fields i want (e.g. name, phone, mail) of the current user . What i am asking it can i make somehow this view (with some extra params inside the [ ]) that displays 3 custom fields to display only one of the three and use this view three times in the same page to display one filed each time instead of using three separate views to do this ?

or can i somehow through pass a variable (not a custom field) and use it with shortcode to make conditional display
(e.g. if the displayvar=1 show the name if displayvar=2 show the adress if the displayvar=3 show the mail )
in the output editor for example of the views

thanks

#1545287

Or can i somehow run a view in a page , get the resulted custom fields and use them as variables of type wpcf-custom-field to display in the parts of the page i want. With this way i will only run the view one time and would be more efficient

thsnks

#1545387

Hello,

How do you setup these fields: name, address ....
Are they custom user fields or post fields?
If they are user fields, you can use Views shortcode [wpv-user] to display them directly, see our document:
https://toolset.com/documentation/user-guides/views/views-shortcodes/#vf-154505

If they are post fields of post type "Clients", you can try the same solution of your previous thread:
https://toolset.com/forums/topic/show-fileds-of-many-one-to-many-relationship-with-a-comom-fild-to-a-view/

It needs only the parent post view, without the child post view.

#1545433

The custom fields are post fields

Luo the problem is got on getting a result the the fields. This words as you helped me in the previus post.

The problem (or my question better) is if i can somehow run a view in a page with the sortcode as you mentions, (up to now that's works) and then apper not every custom field but each one i want of the result that is comming from the view.

basically it would be the same if a have three views on giving only the name one only the adress and one only the phone .
What I am asking is can this be done with one view and a contitional of type (if "a_non_custom_filed_variable" = "adress" -> show [types] field "adress" /[types] ) for example

#1545447

Yes, it is possible, you can add another custom attribute "mydisplay" to view's shortcode [wpv-view], for example:
[wpv-view name="parent post view" myemail=" [wpv-user field='user_email']" mydisplay="address"]

In post view "parent post view", you can get the attribute "mydisplay" value with shortcode [wpv-attribute name="mydisplay"]:
https://toolset.com/documentation/user-guides/views/views-shortcodes/#vf-309292

Use [wpv-conditional] shortcode to display different content depends on attribute "mydisplay" value, for example:

[wpv-conditional if="( '[wpv-attribute  name="mydisplay"]' eq 'address')"]
Display address field shortcode here
[/wpv-conditional] 

More help:
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-conditional

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