Adding a Content Type to the Open Atrium Calendar Views
People often seem to wonder how they can get their new date-specified content types to show up on the Atrium Calendar. The following Views snippet makes it happen for a content type called “example_type” in module “custom”. Note that this code is specific to the Views as they were renamed for Kit-compatibility in Open Atrium 1.0-beta8.
Step 1
Build your “example_type” content type. You can build this out however you want, but for the purpose of this post you need to add the same field_date that the Event type uses.
Step 2
/** * Implementation of hook_views_default_views_alter(). */ function custom_views_default_views_alter(&$views) { $views['calendar_listing']->display['default']->display_options['filters']['type']['value']['example_type'] = 'example_type'; $views['calendar_upcoming']->display['default']->display_options['filters']['type']['value']['example_type'] = 'example_type'; }
Why Not Override the View with Views UI?
Once you have overridden the core Views in Atrium, you take a potentially stressful upgrade/maintenance path and make it vaguely nightmarish. Your changes will disappear into the ether when you upgrade. Restoring your changes would require building out a site based on a backup database to grab the key pieces of your override.
By keeping these changes in code, you can much more easily determine how to fix them… assuming any changes are even necessary!
Happy calendar hooking.
3 comments
Thanks for the explenation
Hi,
I often see PHP code without understanding why to do it like that. Thanks to your explanation, I get the point. I have been thinking that way but had no idea how to do it ad did not realize this is a way. It leaves me however still in confusion.:
Drupal Module Development
Hi Rino,
Basically we are talking about learning Drupal Module development to do advanced Views tweaking.
For that, there is Pro Drupal Development, Module Development, and a lot of documentation and code to bootstrap yourself on. The only code that ever goes into settings.php is the occasional configuration array.
Im a little perplexed about
Im a little perplexed about your argument.
I would do it via the UI then when time for the upgrade export your customized views. Upgrade then reimport them? Seems im missing a side of the argument here?