• Great plugin for wordpress – only thoughts are: It would be great to link an event to an existing post! We really don’t have a lot of control over the post when creating it via the event calendar function.

Viewing 15 replies - 1 through 15 (of 17 total)
  • I agree, a link from the calendar to the relevant post would be the most useful addition to this great plugin.

    *bump*

    Yes, I agree… I think the sidebar calendar works great what with the pop-up events and all but the large calendar just doesn’t do it for me.

    At this point the Events Calendar will add a post to the DB but it is inserted as unpublished… If events could be posted as published posts then it would only be necessary to link events in the large calendar to the corresponding post ID or whatnot. Right?

    I did some more poking around and found the bit of code that builds the large calendar. It’s in ec_js.class.php:` <script type=”text/javascript”>
    jQuery(function($) {
    $(document).ready(function() {
    $(‘#events-calendar-<?php echo $d;?>Large’).append(“<span id=\”events-calendar-<?php echo $id;?>Large\”><?php echo $title;?></span>
    “);
    $(‘#events-calendar-<?php echo $id;?>Large’).attr(‘title’, ‘<?php echo $output;?>’);
    $(‘#events-calendar-<?php echo $id;?>Large’).mouseover(function() {
    $(this).css(‘cursor’, ‘pointer’);
    });
    $(‘#events-calendar-<?php echo $id;?>Large’).Tooltip({
    delay:0,
    track:true
    });
    });
    });
    </script>`

    This would be really sweet. IvΓ© made some modifications to my calendar and this is the last one I need in order for it behave as I want.

    The problem is that the events has no connection to any post in the Database. Thus, ID and Title handed out cannot be used.

    A somewhat ugly solution is (ab)using the permalink structure. If you put the post in a category that you exclude from showing in the main blog feed you can then use $title and transform i.e “My event 3” to “my-event-3”, and then just echo it with an a href=www.yoursite.com/a-non-date-based-permalink-structure/my-event-3

    Doing something like that could work.. if someone could hack the wp title-to-permalink function it’s solved. πŸ™‚

    I realised: you dont have to destroy your permalink structure.

    if your post is in category ‘calendar’, just point the link to yoursite/calendar/post-title

    I have the Events calendar – AND a working link. horraaay! πŸ˜€

    I’m having the same problem but I’m not sure I understand your solution. Check http://www.mondogdl.com. I’d like to be able to hover on a day, then click for more detail, and then click again to link to the post (if one exists). Do I have to modify ec_js.class.php (listed above). Confused.

    I’ve been working on this for a couple of days and it seems that this problem can be solved in around 5 lines of PHP code! I’ve now got the calendar working so that clicking an event on the widget calendar brings up a lightbox, and if that event has a post associated with it then it displays a link to the post page. Which opens in the main window. And shuts the lightbox. Perfect! Find the file called ‘ec_day.class.php’ in the events calendar directory. Before the last ‘endif’ statement, after the ‘description’ div stuff, try adding the following code:

    if (!empty($postID) && !is_null($postID))
    {
    	?>
    	<a href="<?php echo $root; ?>/?p=<?php echo $postID; ?>" target="_parent">Full details</a></div>
    	<?php
    }
    else
    {
    	echo ('</div>');
    }

    This works for me, so hopefully may help a few others with the same problem.

    Cheers,
    Chris

    Thank you for this code but it doesn’t work for me. As I am a newbie, something is probably wrong in my code. Where do I exactly have to put this code in the file ec_day.class.php?

    Thank you for your help.

    msieurbush

    The end of my ec_day.class.php file looked like this before:

    if(!empty($endTime) && !empty($startTime) || !is_null($endTime) && !is_null($startTime)):
          /* Added for localisation by Heirem --------------------*/
    
    	_e('to','events-calendar');?> <strong><?php echo substr($endTime,0,5);?></strong>
    <?php
          /* -----------------------------------------------------*/
          endif;
    
          if(!empty($startTime) || !is_null($startTime)):
    ?>
          </div>
    <?php
          endif;
    ?>
    	<hr />
          <div for="EC_description" class="EC_description"><?php echo $description;?></div>
    
          </p>
    <?php
        endif;
        }
    [INSERT CODE HERE]
      }
    }
    endif;
    ?>

    So I just put that code before the penultimate closing curly brace. I’m pretty sure that’s all I had to do to get this bit to work, however I previously changed this file to alter the functionality of the thickbox, but I don’t think that would affect this part of the code…

    By the way I’m using events calender version 6.4 and a wordpress install version 2.5, if that helps.

    Thank you for your answer.
    Actually, the problem is that “$postID” is always empty but I don’t know why. Any idea?

    Thank you

    Aaah of course! Silly me, knew I’d missed something. You have to declare the $postID variable, as it doesn’t take on any value in the current context. Find the start of your variable declarations, near the start of the php file after all the style stuff. It should look like:

    <?php
        foreach($events as $event) {
        if(($event->accessLevel == 'public') || (current_user_can($event->accessLevel))) :
          $title = stripslashes($event->eventTitle);
          $description = preg_replace('#\r?\n#', '<br />', $event->eventDescription);
          $description = stripslashes($description);
          $location = stripslashes($event->eventLocation);
          list($ec_startyear, $ec_startmonth, $ec_startday) = explode("-", $event->eventStartDate);
          if(!is_null($event->eventStartTime) && !empty($event->eventStartTime)) {
            list($ec_starthour, $ec_startminute, $ec_startsecond) = explode(":", $event->eventStartTime);

    After this you should set the $postID variable so that it knows what it’s trying to retrieve, as follows:

    $postID = $event->postID;

    This should solve your problem. The reason this works is that when creating the event through the large calendar in admin, if you tick the “create post for event” box, wordpress DOES actually insert the post ID into the database entry for the event, and so the post and event are effectively linked. The only issue is that, as mentioned above, there is no actual built-in functionality with the calendar which lets your users see the link!

    Hope this works.

    Chris

    Thank you for your help. It works now!

    Excellent. Just a quick update – the original bit of code that goes at the end of the file, you should move that up so that it’s just before the third closing curly brace, otherwise it’s outside of the foreach loop and will only execute for one event! Not a problem unless there’s more than one event on the same day, but it’s better to sort it out now.

    Cheers

    Chris

    hi chris, this works perfectly! thanks.
    now, if we use the sidebar calendar to show as events lists; how to get this link-to-post working?

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘[Plugin: Events Calendar] Link to existing post’ is closed to new replies.