Home › Forums › Calendar Products › Events Calendar PRO › Theme integration – conditional headers
- This topic has 3 replies, 2 voices, and was last updated 9 years, 7 months ago by Brian.
-
AuthorPosts
-
August 31, 2014 at 2:48 am #713242jeroenbackxParticipant
Hello,
I have a question regarding integrating The Events Calendar in my theme (Flawless by Goodlayers), which I’m developing locally.
This theme uses a conditional switch statement to determine what type of title and title design should be printed. Is there a way in PHP to let my theme know what type of The Events Calendar page is being displayed?
I’m would like to expand the switch statement with the following criteria:
– Is The Events Calendar plugin active? If so:
– Is the events ‘homepage’ or overview page being displayed? – i.e. is_home(): print title
– Is the events ‘single’ being displayed? – i.e. is_single(): print title
– Is the events archive or taxonomy (category & tag) being displayed? – i.e. is_tax(): print titleI’ve already checked the documentation and tutorials, but couldn’t find these kinds of template tags.
I’m hoping to receive a conclusive answer.Best regards,
RubenSeptember 2, 2014 at 6:53 am #717150BrianKeymasterRuben,
I can help provide some conditionals to get you going in the right direction.
– Is The Events Calendar plugin active? If so:
There is not a direct function to do this, but you could run a check if a function exists and if it does do something. The functions below only work if the Events Calendar is active so it may not be needed, but that depends on your setup.
– Is the events ‘homepage’ or overview page being displayed? – i.e. is_home(): print title
tribe_is_view() (add in ‘month’, ‘list’, etc for the view you would like on the main events calendar page)
– Is the events ‘single’ being displayed? – i.e. is_single(): print title
is_singular( ‘tribe_events’ ))
– Is the events archive or taxonomy (category & tag) being displayed? – i.e. is_tax(): print title
tribe_is_event_category()
Let me know if that helps our you need some more information.
Thanks
September 3, 2014 at 10:37 am #719773jeroenbackxParticipantHello Brian,
Thank you for the provided conditionals, I managed to get it all working as intended.
Besides the provided conditionals i used the following statement to check whether TEC is activated:
if( class_exists(‘TribeEvents’) ) {
$tribe = TribeEvents::instance();
} else {
$tribe = ”;
}Using the stored instance i was able to make use of statments such as:
if( !empty($tribe) ) {
$tribe_is_tax = is_tax( $tribe->get_event_taxonomy() );
$tribe_tax_cat = get_queried_object();
}
echo __(‘Category’,’my_namespace’) . ‘: ‘ . $tribe_tax_cat->name;if ( !empty($tribe) ) {
$views = tribe_events_get_views();if ( count( $views ) > 1 ) {
foreach ( $views as $view ) {
if ( tribe_is_view( $view[‘displaying’] ) ) {
$tribe_in_view = $view[‘displaying’];
}
}
}if ( $tribe_in_view == ‘upcoming’ ) {
$title = __(‘Upcoming Events’,’my_namespace’);
} elseif ( $tribe_in_view == ‘photo’ ) {
$title = __(‘Upcoming Events’,’my_namespace’);
} elseif ( $tribe_in_view == ‘month’ ) {
$title = __(‘Monthly Events’,’my_namespace’);
$caption = get_the_date(‘F Y’);
}
}
echo $title;
echo $caption;if( is_single() ) {
$page_title = get_the_title();if($post->post_type == ‘tribe_event’ ){
$page_title = __(‘Location’,’my_namespace’) . ‘: ‘ . $page_title ;
$page_caption = ”;
}else if($post->post_type == ‘tribe_venue’ ){
$page_title = __(‘Location’,’my_namespace’) . ‘: ‘ . $page_title ;
$page_caption = ”;
}else if($post->post_type == ‘tribe_organizer’ ){
$page_title = __(‘Organizer’,’my_namespace’) . ‘: ‘ . $page_title ;
$page_caption = ”;
}
}
echo $page_title;
echo $page_caption;Let’s hope that some of this code proves to be helpful for other TEC users.
Regards,
RubenSeptember 3, 2014 at 11:28 am #719888BrianKeymasterRuben,
Thanks for sharing the coding!
Glad you got it all working too. I am going to go ahead and close this ticket, but if you need any other on something else please post a new ticket.
Thanks!
-
AuthorPosts
- The topic ‘Theme integration – conditional headers’ is closed to new replies.