Startseite › Toolset Professional Support › [Gelöst] condition combine dont work
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.
Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.
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)
Verwandte Dokumentation:
Dieses Thema enthält 39 Antworten, hat 2 Stimmen.
Zuletzt aktualisiert von alexd-6 vor 3 Jahren, 4 Monaten.
Assistiert von: Minesh.
Hi,
i have too conditions to combine like this:
[wpv-conditional if="( $(wpcf-highlight) eq '1' ) AND ( '[datetime]' eq 'aktiv' )"]
it dont work but if i have the condition seperate like below it works:
[wpv-conditional if="( '[datetime]' eq 'aktiv' )"]aktiv[/wpv-conditional] [wpv-conditional if="( $(wpcf-highlight) eq '1' )"] [wpv-post-body view_template="veranstaltungs-slider-slide"] [/wpv-conditional]
What do i wrong?
thx in advance - alex
Hello. Thank you for contacting the Toolset support.
That is strange, it should work with AND clause.
Can you please share problem URL where you added the condition and admin access details so I can check whats going wrong with your setup.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Can you please check now.
I've adjusted the conditional statement as given under with AND clause and I can see it working.
[wpv-conditional if="( '[datetime]' eq 'aktiv') AND ( $(wpcf-highlight) eq '1' )"]aktiv[/wpv-conditional]
hi,
yes, it seems to work. But if i do the following:
[wpv-conditional if="( '[datetime]' eq 'aktiv') AND ( $(wpcf-highlight) eq '1' )"] [wpv-post-body view_template="veranstaltungs-slider-slide"] [/wpv-conditional]
it dont remove the item (content-template - ID 10898) - it shows empty.
ich i only take:
[wpv-conditional if="( $(wpcf-highlight) eq '1' )"] [wpv-post-body view_template="veranstaltungs-slider-slide"] [/wpv-conditional]
it works correclty on startpage in slider: versteckter Link
first slide is not "aktiv" from shortcode [datetime]
thx - alex
Can you please check now - I've adjusted the conditional statement as well as removed the Permanent attachment or content template to your view by clicking on the button "Schleifen-Assistent" and I unchecked the checkbox as shown with the following screenshot: versteckter Link
=> versteckter Link
Can you please confirm it works as expected now.
hi,
no, now is nothing to display? Its empty at all.
The thing is that I removed all the conditional statements and just added the content template within the view's loop:
=> versteckter Link
<!-- wpv-loop-start --> <wpv-loop> [wpv-post-body view_template="veranstaltungs-slider-slide"] </wpv-loop> <!-- wpv-loop-end -->
I do not see any content on the homepage, you must have some misconfigurations on how you are using this view or content tempalte.
hey - but before you removed the the " the Permanent attachment or content template " - it works.
i dont know, what you mean.
thx - alex
I'm not sure why the content template is not get displayed but I've moved the content template code directly within the loop editor section as given under:
<!-- wpv-loop-start --> <wpv-loop> [wpv-conditional if="( '[datetime]' eq 'aktiv') AND ( $(wpcf-highlight) eq '1' )"] <div class="row homeslider"> <div class="col-sm-8"><a href="[wpv-post-url]" >[types field='galerie' title='%%TITLE%%' alt='%%ALT%%' size='custom' proportional='false' width='640' height='480' resize='crop' class='sliderimage' index='0' separator=', '][/types]</a></div> <div class="col-sm-4"> <div class="slidercontent"> <span class="highlight">HIGHLIGHT</span> <h2>[wpv-post-link class="sliderhead"]</h2> <p>[wpv-view name="veranstaltungs-slider-stab"]</p> <p class="subhead1">[types field='untertitelneu-1'][/types]</p> <p class="subhead2">[types field='untertitelneu-2'][/types]</p> [wpv-view name="veranstatlgungs-slider-date-neu" ] [wpv-conditional if="( '[datetime]' eq 'aktiv' )"]akkkktiv[/wpv-conditional] [datetime postidmy="[wpv-post-id]"] <div class="weiterinfos"><a href="[wpv-post-url]" >weitere Infos</a></div> </div> </div> </div> [/wpv-conditional] </wpv-loop> <!-- wpv-loop-end -->
I can see its working.
Hi,
but when i set Post "Veranstaltungen" - > ID 11114: highlight=true and dates in past, its empty.
you can see it here: versteckter Link - slider is empty.
before combine this two conditions -> only if "highlight"= true -> it works. Only Post with "highlight"=true are shown.
Look here this is the first post in slider (screenshot).
thx - alex
The thing is that while you are on the view that query the post type "Veranstaltungen" you can access the field belongs to the post type "Veranstaltungen".
Now, as you shared the screenshot, the date field is belongs to repeating field group "Termine" so you will not have direct access to it.
=> https://toolset.com/wp-content/uploads/2021/07/2109255-Bildschirmfoto_2021_07_08_um_14.28.48.jpg
Can you please tell me where you added the shortcode [datetime]?
it is in function.php
i compare timestamps - that works fine.
function myownfunc( $atts ) { // $post_id = $atts['postidmy']; $post_id = $Post->ID; $fieldvalues = toolset_get_related_posts( get_the_ID(), "termine-veranst", array( 'query_by_role' => 'parent', 'return' => 'post_object')); $today = date("j. F Y H:i"); $todaytimestamp = strtotime($today); $temp = array(); foreach ($fieldvalues as $fieldvalue) { $partone = types_render_field('datum-und-uhrzeit', array('post_id' => $fieldvalue->ID)); $partone = $partone; $temp[] = strtotime($partone); //$temp2[] = $partone; foreach ($temp as &$value) { // $value = $value * 2; if ($value < $todaytimestamp) { $statusinaktiv = 'inaktiv'; }else{ $statusaktiv = 'aktiv'; } } // print $status; } // return join(" - ",$temp). "<br>" .$todaytimestamp . "<br>" . $statusaktiv . "<br>" . $statusinaktiv; return $statusaktiv; } // [datetime postidmy="[wpv-post-id]"] add_shortcode( 'datetime', 'myownfunc' );
There is still confusion with your requirements as I can see with the datetime shortcode you query the repeating field group and based on the date field you are comparing the date and if date value is less than today's date you are returning the inactive otherwise active but the thing is that repeating field group will have multiple records added.
So, lets consider we have 5 records added to repeating field group where 2 records will have the custom date field value set before today's date and remaining 3 records will have future date.
How exactly you want to compare here and return active/inactive status? because in this case with 5 repeating field group records we will Have both active and inactive records. how exactly you want it should work?
Can you please share FTP access details as well.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Hi, yes but in shortcode - it walk trough array and if only one value is positiv, the Var $statusaktiv is set to aktiv. - So it is: is one date in future, shortcode give aktiv.
Where can i give you the Details of FTP?
thx - alex
so, it means irrespective of number of inactive records available in the repeating field group, even if the repeating field group have one future date record it should return active and we should display that post right?
You can share the FTP access details with the next private reply.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.