WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: The Events Calendar] Want to create a Page that calls/contains calendar - what code to inse (22 posts)

  1. PaulieP
    Member
    Posted 4 years ago #

    Simple question I havent been able to find the answer to,

    Since all Pages create a link automatically in the menu bar of my template, I wanted to make a Page that basically is the event calendar. I have created other similar pages before that call up other plugins like my forums, galleries etc..

    I'm just wondering what code I insert into the Page to call up The Events Calendar -

    using [the-events-calendar] doesnt seem to work for example. Thanks.

  2. kelseydamas
    Member
    Posted 4 years ago #

    Hi Paulie,

    Our plugin doesn't support shortcode tags, but we've discussed it and it will most likely make it into a future version of the plugin. For the time being, using the templates is the way to go.

  3. PaulieP
    Member
    Posted 4 years ago #

    Thanks for the reply. Right now all I am doing is using an html redirect plugin so I can have Page link that shows the calendar. Works but the less plugins I have to throw at everything the better of course.

    My theme automagically generates Page links in the native font using Flash. So for people using more visually creative themes using a shortcode in a Page will definitely be useful.

    Thanks.

  4. SebAshton
    Member
    Posted 4 years ago #

    I was after an answer to exactly the same issue - well to get the events list. so i solved it myself.

    I altered the list.php template and saved it as a page template in my root directory.

    Below is the code i used so you can literally copy and paste it if you want. You may want to alter the position of the post content loop to before or after the calander, but thats your choice.

    NB. I deleted the function to swap between list and calender so if you want it copy it from list.php in views

    hope this helps,

    Seb

    <?php
    /*
    Template Name: eventlist-in-page
    */
    ?>
    <?php
    	global $spEvents;
    	$spEvents->loadDomainStylesScripts();
    
    	get_header();
    ?>
    	<div id="tec-content" class="upcoming">
    		<div id='tec-events-calendar-header' class="clearfix">
    			<h2 class="tec-cal-title"><?php _e('Calendar of Events', $spEvents->pluginDomain) ?></h2>
    		</div><!--#tec-events-calendar-header-->
    
    		<div id="tec-events-loop" class="tec-events post-list clearfix">
    		<?php $cal_query = new WP_Query('category_name=Events'); ?>
    		<?php while ($cal_query->have_posts()) : $cal_query->the_post(); ?>
    
    				<div id="post-<?php the_ID() ?>" class="tec-event post clearfix<?php echo $alt ?>">
    							    <div style="clear:both;"></div>
    							        <?php if ( is_new_event_day() ) : ?>
    					<h4 class="event-day"><?php echo the_event_start_date( null, false ); ?></h4>
    							        <?php endif; ?>
    						<?php the_title('<h2 class="entry-title"><a href="' . get_permalink() . '" title="' . the_title_attribute('echo=0') . '" rel="bookmark">', '</a></h2>'); ?>
    					<div class="entry-content tec-event-entry">
    						<?php the_excerpt() ?>
    					</div> <!-- End tec-event-entry -->
    
    					<div class="tec-event-list-meta">
    		              <table cellspacing="0">
    		                  <tr>
    		                    <td class="tec-event-meta-desc"><?php _e('Start:', $spEvents->pluginDomain) ?></td>
    		                    <td class="tec-event-meta-value"><?php echo the_event_start_date(); ?></td>
    		                  </tr>
    		                  <tr>
    		                    <td class="tec-event-meta-desc"><?php _e('End:', $spEvents->pluginDomain) ?></td>
    		                    <td class="tec-event-meta-value"><?php echo the_event_end_date(); ?></td>
    		                  </tr>
    		                  <?php
    		                    $venue = the_event_venue();
    		                    if ( !empty( $venue ) ) :
    		                  ?>
    		                  <tr>
    		                    <td class="tec-event-meta-desc"><?php _e('Venue:', $spEvents->pluginDomain) ?></td>
    		                    <td class="tec-event-meta-value"><?php echo $venue; ?></td>
    		                  </tr>
    		                  <?php endif; ?>
    		                  <?php
    		                    $phone = the_event_phone();
    		                    if ( !empty( $phone ) ) :
    		                  ?>
    		                  <tr>
    		                    <td class="tec-event-meta-desc"><?php _e('Phone:', $spEvents->pluginDomain) ?></td>
    		                    <td class="tec-event-meta-value"><?php echo $phone; ?></td>
    		                  </tr>
    		                  <?php endif; ?>
    		                  <?php if (tec_address_exists( $post->ID ) ) : ?>
    		                  <tr>
    							<td class="tec-event-meta-desc"><?php _e('Address:', $spEvents->pluginDomain); ?><br />
    							<?php if( get_post_meta( $post->ID, '_EventShowMapLink', true ) == 'true' ) : ?>
    								<a class="gmap" href="<?php event_google_map_link(); ?>" title="Click to view a Google Map" target="_blank"><?php _e('Google Map', $spEvents->pluginDomain ); ?></a>
    							<?php endif; ?></td>
    							<td class="tec-event-meta-value"><?php tec_event_address( $post->ID ); ?></td>
    		                  </tr>
    		                  <?php endif; ?>
    		                  <?php
    		                    $cost = the_event_cost();
    		                    if ( !empty( $cost ) ) :
    		                  ?>
    	 		              <tr>
    							<td class="tec-event-meta-desc"><?php _e('Cost:', $spEvents->pluginDomain) ?></td>
    							<td class="tec-event-meta-value"><?php echo $cost; ?></td>
    						 </tr>
    		                  <?php endif; ?>
    		              </table>
    					</div>
    					<div style="clear:both;"></div>
    				</div> <!-- End post -->
    				<div class="tec-events-list content_footer"></div>
    	<?php $alt = ( empty( $alt ) ) ? ' alt' : '';?>
    		<?php endwhile; // posts ?>
    
    		</div><!-- #tec-events-loop -->
    		<div class="tec-nav" id="tec-nav-below">
    
    			<div class="tec-nav-previous"><?php
    			// Display Previous Page Navigation
    			if( events_displaying_upcoming() && get_previous_posts_link( ) ) : ?>
    				<?php previous_posts_link( '<span>&laquo; Previous Events</span>' ); ?>
    			<?php elseif( events_displaying_upcoming() && !get_previous_posts_link( ) ) : ?>
    				<a href='<?php echo events_get_past_link(); ?>'><span><?php _e('&laquo; Previous Events', $spEvents->pluginDomain ); ?></span></a>
    			<?php elseif( events_displaying_past() && get_next_posts_link( ) ) : ?>
    				<?php next_posts_link( '<span>&laquo; Previous Events</span>' ); ?>
    			<?php endif; ?>
    			</div>
    
    			<div class="tec-nav-next"><?php
    			// Display Next Page Navigation
    			if( events_displaying_upcoming() && get_next_posts_link( ) ) : ?>
    				<?php next_posts_link( '<span>Next Events &raquo;</span>' ); ?>
    			<?php elseif( events_displaying_past() && get_previous_posts_link( ) ) : ?>
    				<?php previous_posts_link( '<span>Next Events &raquo;</span>' ); // a little confusing but in 'past view' to see newer events you want the previous page ?>
    			<?php elseif( events_displaying_past() && !get_previous_posts_link( ) ) : ?>
    				<a href='<?php echo events_get_upcoming_link(); ?>'><span><?php _e('Next Events &raquo;', $spEvents->pluginDomain); ?></span></a>
    			<?php endif; ?>
    			</div>
    
    		</div>
    <div class="clear"></div>
    
    <!--
    	START Page lopp
    -->
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div>
    			<?php
    			/*
    				post content
    			*/
    			    the_content();
    
    			?>
    			<?php edit_post_link('Edit', '<br /><p>', '</p>'); ?>
    		</div>
    		<?php endwhile;?>
    		<?php endif; ?>
    <!--
    	END Page loop
    -->
    	</div>
    
    <?php
    get_footer();
  5. Vayu Robins
    Member
    Posted 4 years ago #

    HI.

    I was looking for the same. The trick is to call e new query.

    <?php query_posts('category_name=events'); ?>

    So for a Calendar Template page I coppied the Gridview and pasted it into my Calendar template and added the query near the top.

    <?php
    /*
    Template Name: Calendar
    */
    ?>
    <?php
    	global $spEvents;
    	$spEvents->loadDomainStylesScripts();
    
    	get_header();
    ?>
    	<div id="tec-content" class="grid">
    
    		<?php query_posts('category_name=events'); ?>
    
    		<div id="tec-events-calendar-header">
    
    			<h2 class="tec-cal-title"><?php _e('Calendar of Events', $spEvents->pluginDomain) ?></h2>
    
    			<span class="tec-month-nav">
    				<span class="tec-prev-month">
    					<a href="<?php echo events_get_previous_month_link(); ?>">
    						← <?php echo events_get_previous_month_text(); ?>
    					</a>
    				</span>
    
    				<?php get_jump_to_date_calendar( "tec-" ); ?>
    
    				<span class="tec-next-month">
    					<a href="<?php echo events_get_next_month_link(); ?>">
    					<?php echo events_get_next_month_text(); ?> →
    					</a>
    				</span>
    			</span>
    
    			<span class="tec-calendar-buttons">
    				<a class="tec-button-off" href='<?php echo events_get_listview_link(); ?>'><?php _e('Liste oversigt', $spEvents->pluginDomain)?></a>
    			</span>
    
    		</div><!-- tec-events-calendar-header -->
    
    		<?php event_grid_view( ); // See the plugins/the-events-calendar/views/table.php template for customization ?>	
    
    	</div><!-- content-->
    
    	<?php locate_template( array( 'sidebar.php' ), true ) ?>
    
    <?php
    	get_footer();
  6. nicdvs
    Member
    Posted 3 years ago #

    THANK YOU SO MUCH !!!!

    I have been looking for this for hours.. Thanks again ! The loop.. that is what I was missing...

  7. nicdvs
    Member
    Posted 3 years ago #

    euh query.. not the loop...

  8. idavila
    Member
    Posted 3 years ago #

    Ok, i really want to be able to do this, but I am not as advanced as you all, can you explain in "idiot" terms. I really wish this plugin used shortcode...would make my life soooo much easier.

  9. FyireChilde
    Member
    Posted 3 years ago #

    any word on how to fix this? I don't mind if my side navigation widget area goes away, I just don't want it continuing forever unto the horizon below it. =/

  10. FyireChilde
    Member
    Posted 3 years ago #

    Alright, I fixed the widget side nave problem myself! =B
    The trick was to grab the code out of php file my version referenced instead of what you have there. ...doy...

    It still doesn't look exactly how I want it to...if anyone has any thoughts on how to make it shrink and center a bit? I'd be all ears.
    @vayu & SebAston, dear god thank you for this so much! This was a gem of information!

    @idavila: I'm not a code guru either...when I'm changing wp code I back up my original files before I start in case I make a mistake, I suggest everyone do the same, 'specially if you are following all my other advice. IF, like me, you are running the most current versions of both wp & event calendar this is how I did what I did~

    Step One: Make a new Page Template
    simple version:

    • with your ftp server download the page.php file from your wp sites selected theme. YOURSITE/wp-content/themes/YOURTHEMENAME/page.php
    • change the name of this page to something like "calendar-page.php" on your computer, make sure it stays a php file if you use an editing program
    • upload the file to YOURSITE/wp-content/themes/YOURTHEMENAME/ folder on your wp site via ftp
    • in your online wp admin panel go to appearances menu, "editor" then find the file that has "calendar-page.php" as it's file name
    • Highlight all of the text in this file and paste:
    <?php
    /*
    Template Name: Calendar
    */
    ?>

    You can also replace the code in your new template php in a code editor like dreamweaver or whatever before you upload it...if you do that you can skip to step 2 right after checking that it appears in your editor.
    Either way, you should now have a template that can be selected when you make a new page, but it is completely blank to be filled in with your calendar code when you grab it! Save "calendar-page.php" in your online editor, if that is what you used, and continue~

    Step 2: Go to your plug in panel, find the event calendar in the list. See where it says "deactivate | edit"? Click edit. You will now be in a browser that looks like your regular theme editor, but it is specific to your calendar widget.
    Decide if you want the list (like your main page but only event entries) or grid view (traditional calendar) of your calendar on your page.

    • List: click the-events-calendar/views/list.php
    • Grid: click the-events-calendar/views/gridview.php

    Open your chosen file in the editor, Select All, copy and then return to your main appearances editor and click on your "calendar-page.php" again.
    Underneath the small bit of code it contains paste everything you just copied. Save.

    Step 3: Use the trick presented here in this thread to make it display~

    Find the line in your file that reads:
    <div id="tec-content" class="upcoming">
    in list view
    <div id="tec-content" class="grid">
    in grid view

    altering none of this code, place your cursor at the end of that line and hit enter, then paste:
    <?php query_posts('category_name=events'); ?>
    Save.

    Step 4: Link this to your page.
    Go to the page publishing section of your wp user panels. You can convert an old one or make a new page. While you are editing/creating your page there should be an area denoting "Page Attributes" with a drop menu for template...select Calendar. Make sure you have no text on your page and save.

    You should end up with something like What I Have!
    I don't know how to make it not take up all of the page, but frankly I don't care, it will link to your regular event calendar functions just fine and I chose the list view since it looks better sprawled out, of course right now it's lipstick on a pig for my new site, but functionality comes first.
    I'm a little apprehensive about updates to this widget in the future making me have to reup my template, but I suppose it is a necessary evil to get what I want, I like how smart finally figuring this out made me feel, but...short code ftw please!

    thanks again SebAshton and Vayu, I cannot stress how helpful you were!

  11. Joggi
    Member
    Posted 3 years ago #

    I had the same issue (the calendar takes up all of the page horizontally) using the link.

    The problem is that the class "category-events" is not called in the body tag. To solve the issue you need to add the "category-events" into the body tag

    For example replace the following line in header.php in the thematic folder:

    <body class="<?php thematic_body_class()?> category-events">

    I know, it is not a very good solution but it works...

  12. FyireChilde
    Member
    Posted 3 years ago #

    @joggi, thank you for trying to help me. I think I understand what you are trying do there with your fix, but I am extremely reluctant to change files that are not specific to the calendar page alone. I don't want to run the risk of it causing problems with other things in the future...

    I never feel comfortable changing things I don't fully understand or need to change to get the perfect result. I wonder if there is a way to do something similar to your fix in the calendar page template file itself?

  13. murraystewart
    Member
    Posted 3 years ago #

    Joggi,
    Please excuse my dumbness but I am no php wizz, Where exactly should I paste it in the Header.php and will it add a calendar to every new page created?

    MY HEADER.PHP

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    <head profile="http://gmpg.org/xfn/11">
    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <title><?php if (is_home () ) { bloginfo('name'); } elseif ( is_category() ) { single_cat_title(); if(get_bloginfo('name') != "") echo ' - ' ; bloginfo('name'); }
    elseif (is_single() ) { single_post_title(); }
    elseif (is_page() ) { bloginfo('name'); if(get_bloginfo('name') != "") echo ': '; single_post_title(); }
    else { wp_title('',true); } ?></title>
    <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/script.js"></script>
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    <!--[if IE 6]><link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/style.ie6.css" type="text/css" media="screen" /><![endif]-->
    <!--[if IE 7]><link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/style.ie7.css" type="text/css" media="screen" /><![endif]-->
    <link rel="alternate" type="application/rss+xml" title="<?php printf(__('%s RSS Feed', 'kubrick'), get_bloginfo('name')); ?>" href="<?php bloginfo('rss2_url'); ?>" />
    <link rel="alternate" type="application/atom+xml" title="<?php printf(__('%s Atom Feed', 'kubrick'), get_bloginfo('name')); ?>" href="<?php bloginfo('atom_url'); ?>" />
    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    <?php wp_head(); ?>
    </head>
    <body>
    <div id="art-main">
    <div class="art-Sheet">
    <div class="art-Sheet-tl"></div>
    <div class="art-Sheet-tr"></div>
    <div class="art-Sheet-bl"></div>
    <div class="art-Sheet-br"></div>
    <div class="art-Sheet-tc"></div>
    <div class="art-Sheet-bc"></div>
    <div class="art-Sheet-cl"></div>
    <div class="art-Sheet-cr"></div>
    <div class="art-Sheet-cc"></div>
    <div class="art-Sheet-body">
    <div class="art-Header">
    <div class="art-Header-png"></div>
    <div class="art-Header-jpeg"></div>

    </div>
    <div class="art-nav">
    <div class="l"></div>
    <div class="r"></div>
    <ul class="art-menu">
    <?php art_menu_items(); ?>

    </div>

  14. weiover
    Member
    Posted 3 years ago #

    If you just want a page shows the calendar, I have made one with custom menu link in the Menus under the Appearance. The link looks something like "/wpdev/category/events/month" Add that to your menu bar and you are done. Is this what people are looking for...?

  15. weiover
    Member
    Posted 3 years ago #

    "wpdev" aka your WordPress installation folder

  16. weiover
    Member
    Posted 3 years ago #

    Actually I followed FyireChilde's instruction and the code from Vayu, I was able to create a regular page with all the sidebar items and the calendar as the main content. Some CSS editing and extra php code from the page.php was needed for my need to make the page appear just like the rest of the site. Thanks to the two!

  17. pbspirits
    Member
    Posted 3 years ago #

    Well, I'm moving on. Not sure why you decided to keep us in the dark about what is probably second nature to you. After three hours I quit. Back to google calendars (which took an hour) unfortunately! I do encourage you to explain this issue with your future users. Looks like an awesome script/plugin. Thanks.

    Sorry to bitch with my original post: Man, I've read the entire plugin instructions, notes, description etc. etc. three times, the setting page blah, blah and not once do you suggest where to put the shortcode.

    C'mon guys put one sentence anywhere so this doesn't have to happen to anyone else. Just a sentence. A clue :)

  18. pixeloco
    Member
    Posted 3 years ago #

    @Vayu: THANK YOU I WAS GOING INSANE... i assumed something like that was needed but talked myself out of it figuring the developers would have for sure included it in the templates they provided....

    "No setup required. Just plug and play!" <-- lies!

    @pbspirits: there is no shortcode. you have to take the templates they provided and build off of them, adding in pieces such as Vayu mentions above.

  19. tracyberna
    Member
    Posted 3 years ago #

    @Seb: You are a GOD for posting that. I copied and pasted just like you said and with only a few tweaks I was up and running with a page that looked exactly like I wanted. All hail Seb! :D

  20. gizmo81
    Member
    Posted 3 years ago #

    Hi all,

    I have followed all the bits and pieces and pretty much have my calender perfect and even within theme. But I used the snippet of code that Vayu suggests, <?php query_posts('category_name=events'); ?> , which works great and brought my calender grid view alive on my page, but as soon as I use any navigation it simply doesn't do anything. I click for next month and it changes the URL to what looks like should be the URL for the next month but the page itself stays on current month. Drop down navigation does the same.
    I have looked everywhere and tried all bits and pieces to no avail. I am average in coding but no expert and is all becoming a blur now.

    WP: 3.0.1
    TEC: 1.6.4

    Can someone please advise where I should be looking to correct the issue.

    Thanks
    Gizmo

  21. FyireChilde
    Member
    Posted 3 years ago #

    I have been living with the fact that my "schedule" page posts oldest events at the top. Since everything else worked awesome, I was living with it, but in the past week the newer posts were bumped off the main page and it stopped working for me.
    I have hunted and gathered off the forum, and came up with a small fix for it with trial and error and felt a plain English addendum to my previous post was necessary for anyone who doesn't understand a lot of code.

    If you wish for your list view calendar template page to display only upcoming events, open your template and find the code:

    <?php query_posts('category_name=events'); ?>
    Replace it entirely with this:
    <?php query_posts('category_name=events&eventDisplay=upcoming'); ?>

    This will give you a page that displays entries or events out of the calendar set in the future. However many posts per page you have set will display as usual, as far as I can tell, and you can still navigate to list/calendar and past events via a link your page should display if you followed all my previous steps, I did insert a <br/> in my template page before the </div> tags, but that was purely cosmetic. Code Sourced from This
    I have not messed with a past event display, since I figure wp's basic archiving function covers that fairly well, and I know the important events are the ones that are still going to happen.
    I assume that a display of past events can be made by replacing:
    category_name=events&eventDisplay=upcoming with category_name=events&eventDisplay=past but I could be wrong. XD;
    Hope it helps if anyone is having the same issue.

    @gizmo81 -
    I did not have that problem in any of my experiments. So I'm not sure how much help I will be, but I can think of two places to look on a 'Murphey's Law' basis. I also consider myself average in code, but possibly not as good as you are looking for:

    1. Have you updated your plug-in or word press version between coding the template and putting it up on the site for use? fix - remake your template with the latest version of code.

    2. Have you been altering code in files other than your specifically created page template? fix - reset it all to default, and start again. Altering your main site header can make things look exactly how you want them too, but can really alter your site function across the board. I have stuck to only altering my separate page template file, and have had no unexpected errors in my site function aside from making the specific page work as desired. Is it possible you turned the actual file for one of your calendar views into a template by accident?

    Just some starting places, I save original versions of all my files to make sure I can go back to defaults...I hope I helped you a bit, Good Luck!

  22. mikedkap
    Member
    Posted 3 years ago #

    I'm looking for a way to just list the upcoming events on a page, just like we have the ability to do so in a sidebar or footer.

    So I basically want the same setup as the widget, but want to hard code it into a page. Does anyone have any ideas on this?

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic