Skip Navigation

[Resolved] Conditional view

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

Problem:
How to display conditional output within views

Solution:
You can use [wpv-conditional] shortcode to display the conditional output.

You can find proposed solution, in this case, with the following reply:
=> https://toolset.com/forums/topic/conditional-view-5/page/2/#post-623726

Relevant Documentation:
https://toolset.com/documentation/views-shortcodes/#wpv-current-user

This support ticket is created 6 years, 10 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 24 replies, has 2 voices.

Last updated by bouchairY 6 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#623690

Please test in this page, i do it with php (without using view)

hidden link

Thank you

#623694

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

When you say - user is not connected - do you mean when user is not logged in? If yes - it suppose to work like that as:

[user_role_editor roles="administrator, editor, manager, agent"]

you set the permission to only "administrator, editor, manager, agent" roles - do you want to allow to guest user as well?

#623708

I have 2 cases :

FIRST CASE :
If a User is not logged in
ONLY CHECKED (green) ITEMS ARE DISPLAYED

SECOND CASE
If a user is logged in and have one of theses roles : administrator, editor, manager, agent
ALL ITEMS ARE DISPLAYED (green + red)

In other words, not checked items (red) are available only for website owner to make modifications on them before making them available for all visitors.

Thank you

#623726

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - could you please check now: hidden link

 [user_role_editor roles="administrator, editor, manager, agent"]
				<div class="col-sm-4">[wpv-post-body view_template="element-de-boucle-dans-circuits_tags"]</div>
          [/user_role_editor]
      
	      [wpv-conditional if="( '[wpv-post-field name='visible_sur_le_front']' eq '1' ) AND ('[wpv-current-user info='id']' eq '')" ]
      			<div class="col-sm-4">[wpv-post-body view_template="element-de-boucle-dans-circuits_tags"]</div>
          [/wpv-conditional]

I've adjusted the condition accordingly within your view's loop output.

More info:
=> https://toolset.com/documentation/views-shortcodes/#wpv-current-user

#623732
not.jpg

Hello
There is a problem When not logged in
Please see attached image
Thank you

#623745

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

It was CSS issue and I fixed it by adding following CSS to your view's content template editor's CSS section:

.projects_holder article .portfolio_description {
    padding: 16px 12px 18px !important;
    margin: 0 2px 0 0;
        margin-bottom: 0px;
    background-color: #fff;
    text-align: center;
    min-height: 90px !important;
    margin-bottom: 12px !important;
}

I can see it looks OK now: hidden link

#623829
filters.jpg

Hello
Very good

Just one small problem, i don't know if you can fix it

Normally, only destinations of existing items will be displayed in the filter black bar

Please see attached image

Thank you

#624149

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

We can not continue like this - as per our support policy we entertain only one question per ticket.

As your original issue is resolved to display conditional output - May I kindly ask you to open a new ticket with your each new question. This will help other users searching on the forum. Thank you for understanding.

You can create a new ticket and assign it to me.

#624487

Thank you

#628890

Hello
Can you help me to add the code, I dont' know what happened, i don't found the code you added to my website !
Thank you