richplane
Forum Replies Created
-
Chris, man: good code shouldn’t throw notices. Don’t blame me for failing to ignore them now, I like my logs clean!
Just updated to 2.0.2 and this error is back. Line 172 is fixed but line 160 isn’t!
I’ve solved the problem.
We obviously have the right event object – we’re seeing the correct data being pulled through when I do
<?= $event->output(‘#_LOCATIONLINK’) ?>
<?= $event->output(‘#_EVENTIMAGE{200,125}’) ?>etc. etc.
The problem is because we’re using a WP template. WP will parse shortcodes in the_content() but we’re not using the_content().
The solution is to create an event-single template (at /themes/<theme_name>/plugins/events-manager/templates/event-single.php), which just runs $event->output(‘#_EVENTNOTES’). Then replace that call in the single-event.php theme template with the_content().
Just in case (!) that’s not clear to anyone: what’s happening is that WordPress is pulling up the theme’s single-event.php template for the event custom post type. When it see the the_content() call in this template, it gets hooked by Events Manager, which outputs its own template event-single.php into this spot.
This is a great and powerful plugin; can’t really complain about these confusions and the minimal documentation given that it’s free.
Adding this code didn’t make it work for me. Whilst doing that I spotted that the ‘Add new event’ page throws the following warnings:
Notice: Undefined variable: EM_Location in /home/sites/ypsyork.org/public_html/wp-content/plugins/events-manager/templates/forms/event/location.php on line 26 Notice: Trying to get property of non-object in /home/sites/ypsyork.org/public_html/wp-content/plugins/events-manager/templates/forms/event/location.php on line 26 Notice: Undefined variable: EM_Location in /home/sites/ypsyork.org/public_html/wp-content/plugins/events-manager/templates/forms/event/location.php on line 27 Notice: Trying to get property of non-object in /home/sites/ypsyork.org/public_html/wp-content/plugins/events-manager/templates/forms/event/location.php on line 27I fixed these by wrapping the echo $EM_Location->location_latitude & $EM_Location->location_longitude calls with isset() – so:
<input id='location-latitude' name='location_latitude' type='text' value='<?php if (isset($EM_Location->location_latitude)) echo $EM_Location->location_latitude; ?>' size='15' /> <input id='location-longitude' name='location_longitude' type='text' value='<?php if (isset($EM_Location->location_longitude)) echo $EM_Location->location_longitude; ?>' size='15' />Just to clarify, the lines I commented out are in
\wp-content\plugins\event-manager\templates\forms\event\attributes.php
It’s an ugly hack but we have suffered no ill effects from it. Same lines in the latest version (5.1.8.5).
Also, for any EM authors watching: it’s “deprecated” not “depreciated”!
http://en.wikipedia.org/wiki/DeprecationYes! That’s exactly what we’ve found. The whole ‘deprecated attributes’ set of values are a real irritation. They clash horribly with ACFs.
I hacked the EM code to hide them all (no inputs -> nothing posted!) but now have to remember to do this after all updates of EM. Which has wrong-footed me once already.
See my post here:
http://wordpress.org/support/topic/plugin-events-manager-strange-depreciated-attributes-when-using-custom-meta-boxesAnd hoping that newcomdd_gmbh is still following this thread, please log back in and put some code tags round your code!
OK, I disabled our theme template file and put a basic format in there hopefully sufficiently quickly that the client wouldn’t notice.
(Interestingly, simply selecting ‘Yes’ for “Override with Formats?” in Events -> Settings -> Pages didn’t actually override the single-event template. I had to delete the file before the page updated. Anyway, beside the point.)
The caption shortcode is indeed parsed correctly when I enter it directly into the Event Format textarea. So why doesn’t it work when I do <?= $event->output(‘#_EVENTNOTES’) ?> in our single-event.php template?
– NB you’ll note I misled you before. We’re using a single-event.php template not an event-single.php one.
We’re setting $event from em_get_event($post->ID, ‘post_id’); – can anyone see why the output method of the object this returns wouldn’t parse shortcodes? Perhaps $event->output() expects the shortcodes to have already been parsed? Can’t quite get my head around how this could work.
@aglonwl – Thanks – but I’m not sure what you’re suggesting here. The client is entering event data and trying to insert images with captions as you would do on posts and pages. I don’t think do_shortcode() will help.
@marcus – you say ‘should’ – do you know that they do work OK? None of the EM-powered sites I’ve seen have captioned images inline in the descriptions. The demo on demo.wp-events-plugin.com/ doesn’t.
We’re using an events-single template, so it’s the #_EVENTNOTES placeholder replacement that seems to be going askew.
If you do your own search form then just sending a
name="location_id"field back in the search will give you the results you want.It’s easy to do your own search form. A category search can by dynamically generated like this:
<?php $terms = get_terms("event-categories"); if ( count($terms) > 0 ) { ?> <select name='category' id='category' class='em-events-search-category' > <option value='-1'>Event type</option> <?php foreach ( $terms as $term ) { ?> <option class="level-0" value="<?= $term->term_id ?>"><?= $term->name ?></option> <?php } ?> </select> <?php } ?>– do the same for the locations with
$locations = EM_Locations::get();then $location->location_idThe default search script will pick up and filter on location_id. This doesn’t seem to be a documented feature.
Thanks for the pointer, agelonwl – I can just comment out all the code that shows the “deprecated attributes” (lines 49-80 in the current version (5.1.7)).
‘Course it’ll all get overwritten on next upgrade! As I understand it, these admin templates can’t be stored in our theme.
It’d be nice to have an elegant fix for this – EM shouldn’t assume that all custom fields are to do with itself! I would suggest that when you remove an event attribute from the settings menu all the values associated with the deleted attribute get wiped at that point. That’s how I’d do it, but I’m not a WP plugin developer and there may be constraints I don’t know about.
In our case, we have custom fields and attributes both switched on in the settings, so I’m not sure why we were seeing anything here.
Similar situation – we’re using a gallery on posts, created by the Advanced Custom Fields plugin by Elliot Condon. For every picture I add to the gallery I get two ‘deprecated attributes’ showing up in the ‘attributes’ box. Allowing custom fields in the EM Settings doesn’t get rid of them. I’m also prevented from removing images from the gallery (because the custom fields effectively get re-posted as deprecated attributes). I have to clear these values to remove images.
Anyone got any tips on how to get Events Manager to ignore custom fields?
Cookie Control says it only blocks Google Analytics cookies out of the box, and blocking others may require you to write additional JavaScript.
The CookieCert one doesn’t help at all because it asks permission at the same time as the site drops any cookies it has.
I’ve yet to find any plugins that will make a WordPres site compliant.