Events Made Easy › Forums › Generic › Error with Conditional Tags
- This topic has 17 replies, 2 voices, and was last updated 12 years, 9 months ago by Anonymous.
-
AuthorPosts
-
Sat 30 Jul 2011 at 11:25 #43342AnonymousInactive
Franky,
I’ve just encountered an error with the conditional tags.
Following the information here: http://www.e-dynamics.be/wordpress/?cat=24 I came up with the following to show a FEATURED box for events in the ‘Featured’ category:
[events_if tag='#_CATEGORIES' contains='Featured']<span class=”pstv-cl-featured”>FEATURED</span>[events_if]
The trouble is it only appears on events NOT in that category.
I also tried with with notcontains but I’m getting the same.
Any ideas?
Thanks
Tom
Sat 30 Jul 2011 at 11:41 #48160FrankyKeymasterYour events_if tag is not closing, maybe that’s an issue? Also (I need to rectify the doc), try using ESC_CATEGORIES in the equation:
[events_if tag='#ESC_CATEGORIES' contains='Featured']<span class="pstv-cl-featured">FEATURED</span>[/events_if]
Sat 30 Jul 2011 at 11:46 #48161FrankyKeymasterAlso, try this change in the code, it might help:
Sat 30 Jul 2011 at 12:40 #48162AnonymousInactiveOk, I’ve done that and added the closing tag but now notcontains works as expected but contains isn’t working
Sat 30 Jul 2011 at 13:13 #48163FrankyKeymasterIt is case sensitive of course …
Sat 30 Jul 2011 at 17:45 #48164AnonymousInactiveChecked that – and that wouldn’t explain why it works when using notcontains which does work but is the opposite of what I want
Sat 30 Jul 2011 at 18:28 #48165FrankyKeymasterYes it would explain that: the code for contains and notcontains is practically identical:
} elseif (is_numeric($contains) || !empty($contains)) {
if (strpos($tag,"$contains")!== false) return do_shortcode($content);
} elseif (is_numeric($notcontains) || !empty($notcontains)) {
if (strpos($tag,"$notcontains")===false) return do_shortcode($content);so if notcontains works, contains should as well …
I just checked it here, and it seems to be working just fine using contains. If you just print out #_CATEGORIES, what do you get as a result? It might be that some strange character is interfering with php quotes here (although I escape using mysql_real_escape_string, but that might not be sufficient)
Sun 31 Jul 2011 at 07:57 #48166AnonymousInactiveOk – I did some playing around and this seems to be a problem related to the use of more than one category. For any with a single category it works fine.
I assign several categories to my events and want to highlight those in a ‘Featured’ category.
Can you think of a way that I can do this, please?
Sun 31 Jul 2011 at 08:55 #48167FrankyKeymasterI tried with different categories without problems. Please see my question in my previous post.
Sun 31 Jul 2011 at 10:40 #48168AnonymousInactiveI tried that but it prints out what I would expect.
On the test page here: http://www.tomchubb.com/developer/wordpress/club-listings/
the bottom line on each event prints out the categories as the styles, eg: Style: Techno, Tech House, Featured
For testing I’ve changed the category search for the term ‘Tech’ which is used in two styles; “Techno” and “Tech House”.
The code I’m using is: [events_if tag='#ESC_CATEGORIES' contains='Tech']<span class=”pstv-cl-featured”>FEATURED</span>[/events_if]
This is showing on some but not all of them.
For completeness, here is my Events code:
<div class=”pstv-cl-eventHolder”>
<div class=”pstv-cl-event”>
<div class=”pstv-cl-calendar”>
<div class=”pstv-cl-day”>#l</div>
<div class=”pstv-cl-date”>#d</div>
<div class=”pstv-cl-month”>#F</div>
</div> <!– end pstv-cl-calendar –>
<div class=”pstv-cl-eventInformation”>
<div class=”pstv-cl-description”>#_LINKEDNAME</div>
<div class=”pstv-cl-locationPrice”>#_LOCATION – #_TOWN – Price £#_ATT{Price}{?}</div>
<div class=”pstv-cl-more”>#_NOTES</div>
<div class=”pstv-cl-bottomLine”><span class=”pstv-cl-style”>Style: #_CATEGORIES</span><span class=”pstv-cl-time”>#_24HSTARTTIME – #_24HENDTIME</span>[events_if tag='#ESC_CATEGORIES' contains='Tech']<span class=”pstv-cl-featured”>FEATURED</span>[/events_if]</div>
</div> <!– end pstv-cl-eventInformation –>
</div> <!– end pstv-cl-event –>
</div> <!– end pstv-cl-enventHolder –>
I made the changes you explained in eme_functions.php and I’m baffled as to what’s stopping it from working!
Sun 31 Jul 2011 at 17:32 #48169FrankyKeymasterVery weird … would you be interested in testing the trunk version?
Mon 1 Aug 2011 at 04:28 #48170AnonymousInactiveOf course. Will install now…
Mon 1 Aug 2011 at 04:39 #48171AnonymousInactiveStill the same. Will try doing it a different way. Thanks for your help
Mon 1 Aug 2011 at 05:33 #48172AnonymousInactiveBeen digging around on php.net and found this but can’t figure out if that would apply:
atomkirk at hotmail dot com 23-Oct-2008 01:19
careful that when you put a strpos in an if statement that you take note that if the string is in the 0 position it will return false, causing your control structure to think its not in the string.
It’s about half way down the page at: http://php.net/strpos
I know you’ve changed it to strstr() now but just thought I’d see if it sheds any light
Mon 1 Aug 2011 at 08:30 #48173FrankyKeymasterNo, I use strpos again but I compare the result binary: 0 is not false then. So that’s not the issue.
Would you give me a temporary admin account so I can snoop around?
Mon 1 Aug 2011 at 08:49 #48174AnonymousInactiveLogin info sent to liedekef email
Thanks
Mon 1 Aug 2011 at 11:57 #48175FrankyKeymasterThe code works just fine, but sometimes your “Featured”-span doesn’t show, I’m guessing because the div is too small or so (look via firebug, you’ll see the “Featured” is there in html).
Mon 1 Aug 2011 at 12:11 #48176AnonymousInactiveOh no – sorry for time-wasting!
-
AuthorPosts
- The forum ‘Generic’ is closed to new topics and replies.