Skip Navigation

[Resolved] conditional display

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

Our next available supporter will start replying to tickets in about 1.95 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by martinP-13 3 years, 6 months ago.

Assisted by: Shane.

Author
Posts
#1745401

on this page hidden link i have a corona section , it is set to display different coloured backgrounds dependant on the data saved by the toolset custom field whis is a select field.

username toolset password toolset will let you view the front end. for back end you will need set a privatee reply so i can provide

it uses this view hidden link

which has in it
[wpv-conditional if="( $(wpcf-corona-virus) eq '' )"]
<div class="mynone">
[/wpv-conditional]

[wpv-conditional if="( $(wpcf-corona-virus) eq '2020 events going ahead' )"]
<div class="mygreen99">
[/wpv-conditional]

[wpv-conditional if="( $(wpcf-corona-virus) eq '2020 events cancelled' )"]
<div class="myred99">
[/wpv-conditional]

[wpv-conditional if="( $(wpcf-corona-virus) eq '2020 To Be Updated' )"]
<div class="myorange99">
[/wpv-conditional]
<div class="myimg2"><div class="myimg">Corona Virus : <img src="hidden link" width="15" height="15" class="" /><span class="myspan1"> [types field='corona-virus'][/types]</span></div></div>
</div>

and in the custom csss

.myimg {
display: inline-flex;
padding: 3px;
}

.myspan {

font-size: 15px !important;
}
.myspan1 {

margin-left:3px !important;
}

.myspan2 {

margin-top:1px !important;
}

div.mygreen99 {
background-color: #81ef81;
color: #000;
margin: 6px;
display: inline-flex;
font-weight: bold;
border: 2px solid black;
}
div.myred99 {
background-color: #e81414;
color: #000;
margin: 6px;
display: inline-flex;
font-weight: bold;
border: 2px solid black;
}

div.myorange99 {
background-color: orange;
color: #000;
margin: 6px;
display: inline-flex;
font-weight: bold;
border: 2px solid black;
}

div.mynone {
display: none;
}

div.myimg2 {
padding: 2px;
}

this view is inserted in to the page using <?php echo do_shortcode("[wpv-view name='single-club-corona']");?>

here hidden link

no matter which of 3 selct is chose or if none are chosen in the backend the display out come is the same.

thanks

#1745535

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Martin,

I managed to have a look at this for you.

However I will need to check the debug on the conditional statement itself to see exactly what is happening.

I've enabled the private fields for your next response.

Thanks,
Shane

#1745775

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Martin,

From what I see the conditionals are working as intended. However based on what i see is it that you want to list the events under each heading based on the status that was selected on the posts?

Please let me know and we can go from there .

Thanks,
Shane

#1745831

hi shane thanks for taking a look .

my toolset custom field is here , hidden link custom field is set to clubs

on my cpt clubs like here hidden link
the 1st option is corona virus , i select one of the 3 options.

on the front end this is the cpt for the same club
hidden link

depending what i chose in back end it should now either be green orange or red , set by the conditionals , if i havnt selected one of the 3 for the club in the backend it should display nothing.

the view is here hidden link , this view is inserted into the fron end by shortcode in the single-club.php (belonging to the events calendar ).

and also i have done the same here which works perfectly fine ,
hidden link which is a lost of all my clubs the view for that page is
hidden link

thanks for your time
regards
martin

#1748883

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Martin,

I believe I understand the issue now. You want the view to only show the status based on the current post page.

In this case i'm not sure where you are calling the view shortcode itself, however i've added a post ID filter to the view so that you can use the shortcode attribute for the view and pass the ID of the current page into the view.

Have a look at the example below.


[wpv-view name='single-club-corona' ids='[wpv-post-id]']

Please try this and let me know if it helps.
Thanks,
Shane

#1748955

thnks shane but no cigar with that soltion , it remains the same but adds '] under the field on the front end , i added

<?php echo do_shortcode("[wpv-view name='single-club-corona' ids='[wpv-post-id]']");?> to my file here single-organizer,php

hidden link

thanks

#1749105

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Martin,

I know exactly what is the issue, its because the shortcode is being called through PHP.

Do it like this.

<?php 
$postid = get_the_ID();

echo do_shortcode("[wpv-view name='single-club-corona' ids='".$postid."']");

?>

Thanks,
Shane

#1749373

My issue is resolved now. Thank you! final code used

<?php if( get_field('wpcf-corona-virus') ): ?>
<div style="background: #dff0d8; border-radius: 5px; border:black 1px solid ;font-size: 35px !important; padding: 5px 5px 5px 5px; color: #fff !imortant;">
<h3><?php $postid = get_the_ID();
echo do_shortcode("[wpv-view name='single-club-corona' ids='".$postid."']");?></h3></div><br>
<?php endif; ?>

you the man shane , you the man!!

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