StudioPress Community Forums

StudioPress Community Forums (http://www.studiopress.com/support/index.php)
-   General Discussion (http://www.studiopress.com/support/forumdisplay.php?f=7)
-   -   Simple Sidebar per Post Type (http://www.studiopress.com/support/showthread.php?t=121228)

kristinsf 10-17-2012 02:27 PM

Simple Sidebar per Post Type
 
Hi, I'm using genesis, wpml and events manager pro. things are seeming pretty complicated.

events manager lists events as posts with the type "event". I want these posts to have a sidebar i created in simple sidebars called "Events Sidebar" #events-sidebar. I tried attaching the custom sidebar to the event category - it is an option in the events categories to set the sidebar, but it didn't work.

I'm hoping there are a few lines of code that I can add to functions.php to say "when an event has post_type of event, use event-sidebar instead of the regular sidebar.

any help with this would be way appreciated.

my php is not strong.

Bill Murray 10-17-2012 02:52 PM

You need to make sure the post type is registered with support for simple sidebars. See this thread.

You can try to find where the post type is registered in your plugin and edit the plugin file, but that would make it difficult to upgrade the plugin as new versions are released. You could also ask the plugin developer if the arguments for the post type registration are filterable. That way could modify these arguments without modifying the plugin itself.

Given that you said your PHP skills are not strong, contacting the plugin author with this info might be your best bet. Otherwise, you'll have to maintain a modified version of the plugin.

Hope that helps.

kristinsf 10-17-2012 03:52 PM

Thanks for your help, Bill. It seems I can't register support for simple sidebars through functions.php? i definitely don't want to hack the plugin if I can possibly avoid it. Let me know your thoughts and I appreciate your help...

The plugin supoport block is

Code:

$event_post_type = array(       
                'public' => true,
                'hierarchical' => false,
                'show_ui' => true,
                'show_in_menu' => true,
                'show_in_nav_menus'=>true,
                'can_export' => true,
                'exclude_from_search' => false,
                'publicly_queryable' => true,
                'rewrite' => array('slug' => EM_POST_TYPE_EVENT_SLUG,'with_front'=>false),
                'has_archive' => get_option('dbem_cp_events_has_archive', false) == true,
                'supports' => apply_filters('em_cp_event_supports', array('custom-fields','title','editor','excerpt','comments','thumbnail','author')),


Bill Murray 10-17-2012 10:20 PM

First, I haven't checked this code, so before you edit anything, make sure you have FTP access to your site and a backup of your functions.php. Even a minor typo can break your site, but you can quickly and easily fix that by deleting the broken file (the one you just edited with the typo) and replacing it with the good backup. Post back with the results; if it doesn't work, post any errors and we'll go from there.

It looks like your plugin applies filters, which is good. So you can add the code below to your child theme's functions.php and you should see simple sidebars on your CPT:

PHP Code:

function wpp_events_sidebar() {
    
$wpp_sidebar = array('custom-fields','title','editor','excerpt','comments','thumbnail','author','genesis-simple-sidebars');
    return 
$wpp_sidebar;
}
add_filter'em_cp_event_supports','wpp_events_sidebar' ); 

This should replace the supports array from the CPT registration with a new one that includes support for simple sidebars.

One additional caution: that code is really basic, and doesn't check to see if the plugin is active or if the filter is being applied. Those things could break if you deactivate the plugin for any reason. It should be a starting point and you can go from there. Also, if you opt to modify the plugin, you can simply modify the supports array to match what I included above.

Hope that helps.

kristinsf 10-18-2012 12:46 PM

Thanks for this - I inserted that code in my functions.php, and then went to the event category and set the sidebar for that category but nothing changes on the page. I have an inquiry in to the plugin developer and i'll let you know if I get it working. Unless you are available for hire to help me to make it work, in which case I would gladly go that route. Private message me, if so!

Bill Murray 10-18-2012 02:43 PM

Is this a paid plugin? Is there a free version that can be tested? Can you provide a link to the plugin site?

You say you are changing the sidebar for an event category. Is that different for the sidebar for the event itself?

All that code should do is allow you to select one of your simple sidebars on the event, since it is tied to the registration of the event custom post type. Adding a simple sidebar to a category might be different. t

Without looking at more of the plugin code, that's all I can do. If you provide a link, I can try it on a site where I have simple sidebars set up.

kristinsf 10-18-2012 04:47 PM

Ah, brilliant! indeed it does work on an event by event basis. my only other desire would be that that sidebar would be set for all events of the event post_type, not leaving my client to remember to set it on an event by event basis. I'd love your help on that, and I really appreciate the time you have spent so far giving material support! I sent you a PM with the URL for the event and the plugin is event manager:
http://wp-events-plugin.com/

I'm using the pro version.

I'm open to giving you my credentials via private msg as well if that is warranted. Let me know your thoughts - thanks!

Bill Murray 10-18-2012 11:20 PM

Yep, it works nicely.

http://test2.beta.wpperform.com/even...ce-conference/

That's a link to an event with a Genesis Simple Sidebar setup (as you can see from the top).

I did this as a plugin (happy to PM it to you once complete), but it's very basic now.

Sticking to what is in the free version for now (and looks like the pro has similar features), my plugin would need ...

- a check to see if events manager is active so if you deactivate events manager it won't break your site
- adding simple sidebars support for all the other event stuff (categories, tags, locations, recurring events, and bookings)

I'll investigate your request of specifying a default sidebar for the post type (it's very doable but it might require my simple plugin have a UI, which I'd rather not do). My quick reaction is that the request is better off made to the Events Manager folks. Since you're a Pro customer, you can make that in their forums. They already support other defaults for events (category, location), so it seems like that would be a logical place for it. However, IF they already support a filter for the sidebar, it would be easy to change the sidebar to one that has a specific ID by default (you could change it manually to something else). That would do what you want.

If I do add the ability to set a default sidebar, to avoid adding a UI you'll have to match an ID because you could create many sidebars with Simple Sidebars.

Give me a few days to look around some more. It all might be pretty easy.

kristinsf 10-19-2012 11:52 AM

hi bill, your help is lovely, thank you. i did inquire with the plugin developer but he referred me back to you ;-)

i'll wait for you to do what your doing and am glad to compensate you as such. i'll also ping him back if need be.

THANK YOU!

Bill Murray 10-19-2012 12:14 PM

Referring back to me is kind of funny. The circular loop of pro support?

Anyway, here's a link to the plugin:
https://github.com/wpperform/events-...le-support.php

You just save that code, put the file in your plugins folder, and activate it. If it breaks anything, just delete the file. It's working fine on the test site I set up.

I added support for Genesis Simple Menus too. Simple Sidebar support for categories comes from Simple Sidebars itself so no need to do anything there. As for making a sidebar a default, I posted a question on the WP forums but the plugin dev hasn't answered. I doubt that will get far. Unless I get more info or time to look at his code more, that's about as far as I can take it.

Your best bet is to ask the plugin dev via pro support to see if he'd add an option for the default sidebar for a single event. That way, you could create your sidebar using Simple Sidebars, get the ID and update your settings in EM, and you'd have what you want without hacking the plugin. If anyone else adds it, it is likely to break when the plugin is updated. For all of your existing events/event categories/locations, you'll have to manually edit them to choose the sidebar/menu after you create those sidebars/menus.

Btw, EM looks like a nice plugin.

kristinsf 10-19-2012 04:59 PM

EM is awesome, we use to great effect for class registrations on mightyminnow.com. i have installed your plugin and activated it and removed the code above from my functions.php. i understand that i still need to set the event sidebar on an event by event basis, and i'll take this up with the event manager plugin developer.

Thank you so much for your time. If you would like to be compensated - even virtual coffee or beer - PM me with the deets.

THANKS!!!

Bill Murray 10-19-2012 05:45 PM

Glad it works. I'm happy if you do 2 easy things: 1) if your support request gets anywhere, let me know and I'll update the plugin and 2) if I ever get around to adding something like a Twitter account to my signature here, follow me.

kristinsf 10-19-2012 06:07 PM

Sure thing. And if you hear anything in your channels, let me know.

Have a great weekend.


All times are GMT -5. The time now is 01:51 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.