Skip Navigation

[Resolved] Color or Background change using Conditionals in Views

This support ticket is created 4 years, 4 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
- 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 22 replies, has 2 voices.

Last updated by larryL 4 years, 3 months ago.

Assisted by: Nigel.

Author
Posts
#1732935

Nigel
Supporter

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

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

That happens because the conditions for the yellow section ($(wpcf-item-start-date) ne 'TODAY()') and the blue section ($(wpcf-items-statuses) ne 'Complete' ) AND ( $(wpcf-item-end-date) gte 'TODAY()') are both true, and so both get output.

You need to make sure that your conditions are mutually exclusive to avoid outputting more than one block of markup at a time.

#1733873

But I need multiple blocks to output at the same time.

#1734037

Nigel
Supporter

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

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

I don't really understand what the problem is, I need more to go on than that.

#1741695

Sorry Nigel, What I was saying is that I need all the conditions to appear in the same view. Is this not doable?

#1741839

Nigel
Supporter

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

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

I'm still not sure quite what you mean.

The View iterates over posts, which you are outputting as rows in a table.

For any given row, the tds should be output only once.

You have several conditional tests, each outputting a complete set of tds for that post iteration, i.e. that row.

Which is why you need to carefully choose conditions that are mutually exclusive, so that the set of tds can only ever be output once for that row. Your yellow-and-blue screenshot shows two groups of tds being output for the same row, but there should only ever be one.

So it seems like you need to rethink the logic of your conditional tests (rather than the syntax of implementing the tests).

Otherwise, what do you expect to happen when both the yellow and blue conditions are true for the same post being iterated over?

That they should both be output, but on separate rows?

If that's the case then you would need to move the tr tags inside the linked template, within each conditional section.

Right now they are in the wpv-loop section but not in the linked template, i.e.

		<wpv-loop>
			<tr>
				[wpv-post-body view_template="loop-item-in-locations-on-test"]
			</tr>
		</wpv-loop>
#1753435

Sorry for the late reply back Nigel, You meant moving the TR tags into the loop as part of each condition statement? Yes, that appears to have fixed it. Sorry for not making sense.

#1753549

Nigel
Supporter

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

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

Great, that sounds like a result.

We can close here?

#1757315

My issue is resolved now. Thank you!