Skip Navigation

[Resolved] Problem with nested wpv-conditional causing infinite loop

This support ticket is created 6 years, 11 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Tagged: 

This topic contains 8 replies, has 3 voices.

Last updated by Nigel 6 years, 9 months ago.

Assisted by: Nigel.

Author
Posts
#594412
no condition.png
with condition.png

I have a view that displays only 1 post based on url param. (Include only posts with IDs determined by the URL parameter "bkn")

The problem is the wpv-conditional that wraps the table.
The entire code is copied from a single post layout (on the same site) where it works without any issues.

If I use this code it causes an infinite loop.
If I remove the condition the view works as expected.
See images for result with and without the condition applied.

[wpv-conditional if="('[wpv-current-user info='id']' eq '[wpv-post-author format='meta' meta='ID' id='$exhibitor']') OR ('[wpv-current-user info='id']' eq '[wpv-post-author format='meta' meta='ID' id='$organizer']') OR ('[wpv-current-user info='id']' eq '[wpv-post-author format='meta' meta='ID']') OR ( '[wpv-current-user info='role']' eq 'administrator' )"]
//lot more code and nested conditionals
[/wpv-conditional]

Complete view code

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
		<wpv-loop>
          [wpv-conditional if="('[wpv-current-user info='id']' eq '[wpv-post-author format='meta' meta='ID' id='$exhibitor']') OR ('[wpv-current-user info='id']' eq '[wpv-post-author format='meta' meta='ID' id='$organizer']') OR ('[wpv-current-user info='id']' eq '[wpv-post-author format='meta' meta='ID']') OR ( '[wpv-current-user info='role']' eq 'administrator' )"]
<table class="table" style="font-size:10px; margin-top:-40px;" data-pg-collapsed>
                    <tbody>
                        <tr style="font-size:20px;">
                            <td colspan="2" style="border-top: none;" class="pad-bottom20">
  [wpv-conditional if="( $(_wpcf_belongs_space_id) gt '1' ) AND ( $(wpcf-booking-status) eq 'draft' )"]
  [types field='booking-status'][/types] Bokning nr [wpv-post-id]<h6>Status: Denna bokning är påbörjad, saknar information.</h6>
  [/wpv-conditional]
  [wpv-conditional if="( $(wpcf-booking-status) eq 'wait' )"]
 [types field='booking-status'][/types] Bokning nr [wpv-post-id]<h6>Status: Väntar på Arrangörens godkännande.</h6>
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-booking-status) eq 'approve' )"]
 [types field='booking-status'][/types] Bokning nr [wpv-post-id]<h6>Status: Godkänd av Arrangören.</h6>
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-booking-status) eq 'deny' )"]
 [types field='booking-status'][/types] Bokning nr [wpv-post-id]<h6>Status: Arrangören har tackat nej till bokningen.</h6>
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-booking-status) eq 'invoice' )"]
[types field='booking-status'][/types] Faktura nr [wpv-post-id]
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-booking-status) eq 'cancel' )"]
 [types field='booking-status'][/types] Bokning nr [wpv-post-id]<h6>Status: Utställaren har avbokat.</h6>
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-booking-status) eq 'paid' )"]
 [types field='booking-status'][/types] Kvitto nr [wpv-post-id]
[/wpv-conditional]
  [wpv-conditional if="( $(wpcf-book-invoice-paid-date) gt '1' )"]<h6>Betalning mottagen: [types field='book-invoice-paid-date' style='text' format='j F, Y'][/types]</h6>
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-booking-status) eq 'move' )"]
 [types field='booking-status'][/types] Bokning nr [wpv-post-id]<h6>Status: Utställaren är erbjuden annan plats än den bokade.</h6>
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-booking-status) eq 'accept' )"]
 [types field='booking-status'][/types] Bokning nr [wpv-post-id]<h6>Status: Utställaren accepterar erbjudandet om ny plats.</h6>
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-booking-status) eq 'refuse' )"]
 [types field='booking-status'][/types] Bokning nr [wpv-post-id]<h6>Status: Tackat nej till erbjudande om platsbyte men vill gärna få ett nytt förslag.</h6>
[/wpv-conditional]</td>
                            <td colspan="2" style="border-top:none;overflow:visible">[types field='logo' id='$organizer' alt='%%TITLE%% logotype' title='%%TITLE%% Logo' width='225' height='85' align='none' resize='proportional' style="max-height:83px" class='user-logo img-responsive pull-right'][/types]</td>
                        </tr>
    <tr>
      <td colspan="4" style="font-size:16px;"><b>[types field='book-market'][/types]</b>, [types field='start-date' style='text' format='j F'][/types] – [types field='end-date' style='text' format='j F, Y'][/types]</td>
    </tr>
                        <tr>
                            <th class="text-right">Mottagare</th>
                            <td style="width:30%">[types field='book-exhibitor'][/types]</td>
                            <th class="text-right">Avsändare</th>
                            <td style="width:30%">[types field='book-organizer'][/types]</td>
                        </tr>
                        <tr>
                            <td class="pad0 text-right" style="border-top:0;">Adress</td>
                            <td class="pad0" style="border-top:0;">[wpv-conditional if="( $(wpcf-book-exhib-box) ne '' )"][types field='book-exhib-box'][/types]<br>[/wpv-conditional]
[types field='book-exhib-street'][/types]<br>
[types field='book-exhib-zip' output='raw'][/types] [types field='book-exhib-city'][/types]</td>
                            <td class="pad0 text-right" style="border-top:0;">Adress</td>
                            <td class="pad0" style="border-top:0;">[wpv-conditional if="( $(wpcf-book-org-box) ne '' )"][types field='book-org-box'][/types]<br>[/wpv-conditional]
[types field='book-org-street'][/types]<br>
[types field='book-org-zip' output='raw'][/types] [types field='book-org-city'][/types]</td>
                        </tr>
                        <tr>
                            <td class="pad0 text-right" style="border-top:0;">Org nr</td>
                            <td class="pad0" style="border-top:0;">[types field='book-exhib-orgno' output='raw'][/types]</td>
                            <td class="pad0 text-right" style="border-top:0;">Org nr</td>
                            <td class="pad0" style="border-top:0;">[types field='book-org-orgno' output='raw'][/types]</td>
                        </tr>
                        <tr>
                            <td class="pad0 text-right" style="border-top:0;">Moms nr</td>
                            <td class="pad0" style="border-top:0;">[types field='book-exhib-vat' output='raw'][/types]</td>
                            <td class="pad0 text-right" style="border-top:0;">Moms nr</td>
                            <td class="pad0" style="border-top:0;">[types field='book-org-vat' output='raw'][/types]</td>
                        </tr>
                        <tr>
                            </tbody>
                </table>
 <table class="table table-bordered table-hover table-striped" style="margin-bottom:0px">
<tr>
  <td style="width:25%">[types field='book-space'][/types]</td>
    <td>[wpv-post-body view_template="None" id="$space" output='raw']  [wpv-conditional if="( $(wpcf-choose-space-size) ne '' )"]<strong>Önskemål:</strong> [types field='choose-space-size' output='raw'][/types][/wpv-conditional]</td>
  <td class="text-right" style="width:15%">[types field='book-space-price' output='raw'][/types] kr</td>
</tr>
   </table>
[wpv-view name="booking-chosen-addons"]
[wpv-view name="related-bookings-raw" bid="[wpv-post-id]"]
                        <table class="table" style="font-size:10px; padding-top:0; padding-bottom:0px, margin-bottom:0px; margin-top:0px">
                            <tbody>
                            <th colspan="3" class="text-right pad-bottom0" style="border-top:0; padding-top:0;">Bokning</th>
                            <th style="border-top:0; padding-top:0;" class="pad-bottom0">[types field='book-net' output='raw'][/types] kr</th>
                        </tr>
                        <tr>
                            <th colspan="3" class="text-right pad0 pad-bottom0" style="border-top:0;">Rabatt %</th>
                            <th style="border-top:0;" class="pad0 pad-bottom0">[wpv-conditional if="( $(wpcf-book-disc-percent) ne '' )"][types field='book-disc-percent' output='raw'][/types][/wpv-conditional][wpv-conditional if="( $(wpcf-book-disc-percent) eq '' )"]0[/wpv-conditional] %</th>
                        </tr>
                        <tr>
                            <th colspan="3" class="text-right pad0 pad-bottom0" style="border-top:0;">Rabatt kr</th>
                            <th style="border-top:0;" class="pad0 pad-bottom0">[wpv-conditional if="( $(wpcf-book-disc-amount) ne '' )"][types field='book-disc-amount' output='raw'][/types][/wpv-conditional][wpv-conditional if="( $(wpcf-book-disc-amount) eq '' )"]0[/wpv-conditional] kr</th>
                        </tr>
                        <tr>
                            <th colspan="3" class="text-right pad0 pad-bottom0" style="border-top:0;">Summa ex moms</th>
                            <th style="border-top:0;" class="pad0 pad-bottom0">[types field='invoice-net' output='raw'][/types] kr</th>
                        </tr>
                        <tr>
                            <th colspan="3" class="text-right pad0" style="border-top:0;">Moms 25%</th>
                            <th style="border-top:0;" class="pad0">[types field='invoice-vat' output='raw'][/types] kr</th>
                        </tr>
                        <tr style="font-size:16px">
                            <th colspan="3" class="text-right" style="border-bottom:1px solid #ddd; border-left:1px solid #ddd;"><em>Att Betala</em></th>
                            <th style="border-bottom:1px solid #ddd; border-right:1px solid #ddd;"><em>[types field='invoice-tot' output='raw'][/types] kr</em></th>
                        </tr>
                        <tr>
                            <td colspan="4" class="pad15" style="font-size:16px;">Betalningsinformation: [wpv-conditional if="( $(wpcf-stripe-mng-id).id(organizer) ne '' )"]<em>Denna faktura kan betalas med kort på BokaMarknad.se</em>[/wpv-conditional]</td>
                        </tr>
                        <tr>
                            <th colspan="2" style="border-left:1px solid #ddd;" class="text-right">Anges vid betalning:</th>
                            <th>Faktura nr</th>
                            <td style="border-right:1px solid #ddd;">[wpv-post-id]</td>
                        </tr>
                        <tr>
                            <th style="border-left:1px solid #ddd;">Fakturadatum</th>
                            <td>[types field='book-invoice-date' style='text' format='F j, Y'][/types]</td>
                            <th style="border-bottom:1px solid black;">Förfallodag</th>
                            <td style="border-bottom:1px solid black; border-right:1px solid #ddd;">[types field='book-invoice-due-date' style='text' format='F j, Y'][/types]</td>
                        </tr>
                        <tr>
                            <th style="border-left:1px solid #ddd;">Bankgiro</th>
                            <td>[types field='book-org-bg' output='raw'][/types]</td>
                            <th>PlusGiro</th>
                            <td style="border-right:1px solid #ddd;">[types field='book-org-plusgiro' output='raw'][/types]</td>
                        </tr>
                        <tr>
                            <th style="border-left:1px solid #ddd; border-bottom:1px solid #ddd;">Swish</th>
                            <td style="border-bottom:1px solid #ddd;">[types field='book-org-swish' output='raw'][/types]</td>
                            <th style="border-bottom:1px solid black;"><em>Att Betala</em></th>
                            <th style="border-bottom:1px solid black; border-right:1px solid #ddd;"><em>[types field='invoice-tot' output='raw'][/types] kr</em></th>
                        </tr>
                        <tr>
                            <td class="text-center pad20 pad-bottom0" colspan="4">Länk till bokningen på BokaMarknad.se</td>
                        </tr>
                        <tr>
                            <td colspan="4" class="text-center pad-bottom0 pad0" style="border-top:none; font-size:14px"><strong>www.bokamarknad.se/bokning-nr-[wpv-post-id]</strong></td>
                        </tr>
                    </tbody>
                </table>
[/wpv-conditional]
		</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		[wpv-post-body view_template="no-items-found"]
	[/wpv-no-items-found]
[wpv-layout-end]

#594418

(PS. found missing <tr> but it didn't help)

#594636

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Tina

Because of the filter the View returns only a single result, right?

It is just an idea, but try moving the conditional shortcode so that it wraps the entire wpv-loop section, i.e. the opening wpv-conditional shortcode comes immediately after the wpv-items-found tag and the closing wpv-conditional shortcode comes immediately before the closing wpv-items-found shortcode.

If that doesn't help then I will need a copy of your site, but let me know first.

#595622

Yes the view returns only a single post.
Tested to position the condition directly after [wpv-items-found] but that returns a blank page.

#595664

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Can I take a look at your site, then?

I will mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site, even though I don't intend to make any changes other than to temporarily add a backup plugin to take a snapshot of the site.

Can you also confirm which View we are talking about?

#598317

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Tina

I thought this might be related to an issue that has surfaced using complex conditionals with PHP 7, but I took a duplicate of your site and installed it locally with a server running PHP 5.6 and that didn't help.

No errors reported anywhere, I tried several things such as moving the output of your View into a content template, but nothing helped.

I've had to escalate this one so that it can be debugged further. I'll keep you posted.

#605055

Tina, I just wanted to let you know that we have some issues replicating the issue in order to fix it.

I am back from vacation as you know and took this task now, please allow me some time to narrow the problem down and update you.

Meanwhile Mohammed found that calling Post Body of the parent posts causes issues in your install and he solved this by changing the ShortCode a little, this might help you go around the issue for now:
- instead of [wpv-post-body view_template=”None” id=”$space” output=’raw’] for example, he used [wpv-post-body view_template=”None” id=”[wpv-post-id id=”$space”]” output=’raw’]

This seemed to work.

It is not the way we suggest to call the parent Post body, but as for a workaround if you need a fast solution, this seems to have solved the issues on the tests of Mohammed.

I am awaiting some details from Nigel related to the package and will dig into this as well so to update you.

#607947

Looks like problem is resolved with Views 2.5.2 without Mohammeds fix.
(2.5.1 was latest version when this problem existed)

Can you confirm?

#613374

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Tina

I have a little time to review my escalated threads which I'm going through now.

There is nothing specific to this issue in the release notes for 2.5.2, but there was work on the post selector for parent posts for a particular issue which could have affected this as a side effect, which seems likely if you have now found that it is working.

In any case, conditionals are earmarked for an overhaul because of several outstanding but difficult-to-resolve issues, which should cover this ground.

As it appears to be working I suggest we close here unless you find the problem re-appears.