WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Events Calendar] Link to existing post (18 posts)

  1. creativeworldstudio
    Member
    Posted 5 years ago #

    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.

  2. Zighead
    Member
    Posted 5 years ago #

    I agree, a link from the calendar to the relevant post would be the most useful addition to this great plugin.

  3. jzo
    Member
    Posted 5 years ago #

    *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?

  4. jzo
    Member
    Posted 5 years ago #

    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>`

  5. Jimmy_R
    Member
    Posted 5 years ago #

    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. :)

  6. Jimmy_R
    Member
    Posted 5 years ago #

    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! :D

  7. Anonymous
    Unregistered
    Posted 5 years ago #

    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.

  8. chris27
    Member
    Posted 5 years ago #

    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

  9. msieurbush
    Member
    Posted 5 years ago #

    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.

  10. chris27
    Member
    Posted 5 years ago #

    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...

  11. chris27
    Member
    Posted 5 years ago #

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

  12. msieurbush
    Member
    Posted 5 years ago #

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

    Thank you

  13. chris27
    Member
    Posted 5 years ago #

    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

  14. msieurbush
    Member
    Posted 5 years ago #

    Thank you for your help. It works now!

  15. chris27
    Member
    Posted 5 years ago #

    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

  16. af3
    Member
    Posted 5 years ago #

    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?

  17. chris27
    Member
    Posted 5 years ago #

    af3

    Good question, I'll take a look at it this afternoon. From what I can see, there is no lightbox (thickbox) function with the list view, only the tooltips pop-up which shows more details. On hover, it appears the events are links, but they don't click through to anything, so it would be nice to make that the link to the relevant post. Hopefully it'll just about be a copy/paste job.

    Chris

  18. fpuga
    Member
    Posted 5 years ago #

    With the current beta version of the plugin v6.5.2a i think that it works "out of the box"

    If you select create a post from the event (and not write anything in the "link out" input text) a link between the calendar event and the post is established.

    In the event list layout if you click in the event the post is opened in the main column. In the calendar layout when you click in the event a thickbox is opened, and in that thickbox there is a link to the post.

    To apply some format to the post, instead of "publish" it you can create it as draft from the events-calendar admin panel and the edit the post as you want.

Topic Closed

This topic has been closed to new replies.

About this Topic