Creating event, post and category

Many of you ask me the opportunity to specify a category when you declare, in the event creation form, the creation of a post associated.

Yet it’s easy to return edit that post and to select the categories you want. But as the customer is king, I looked into the feasibility of this thing.

As Wordpress is very well designed and that its encoders are geniuses, I was not surprised to discover that this implementation was rather simple to achieve.

So as the next version is somewhat expected - but this is normal since all that will change in the plugin! - I think you propose to do it yourself.

To those who will tell me that it would be nice to be able to select multiple categories for the same post: I say NO! It is a little more complicated. But the most intelligent of you will surely find how ;)

Voila the procedure to be followed scrupulously:

  • It is more advisable to work locally than online.
  • Everything happens in the ‘ec_management.class.php‘.
  • Start by saving this file in another directory.
  • We’ll start by adding a dropdown list of categories in the event creation form.
  • Just after the line #185, after </tr> and before </table>, insert this :
  • <tr>
      <th width="33%" scope="row" valign="center"><label for="EC_CatPost">< ?php _e('Select category','events-calendar');?></label></th>
      <td width="67%">< ?php wp_dropdown_categories('name=EC_CatPost');?></td>
    </tr>
  • Now we will ensure that the category will be selected will be sent to creation of the post in Wordpress. Between line 55 and 56, before the line that starts with $data, insert this line:
  • $post_category[0] = $_POST['EC_CatPost'];
  • And finally replace this line 61:
  •           , 'post_category' => $wpdb->escape($this->blog_post_author)
  • By this one:
  •           , 'post_category' => $post_category

Now he’ll just do the tests.
And if it works well, to write me full of thanks ;)

Heirem 11 octobre 2008 14:05 Events-Calendar, Plugins 31 commentaires URI du rétrolien Comments RSS

Donations Wikipedia Affiliate Button

for help Heirem's

31 réponses à “Creating event, post and category”

  1. Heiremle 12 octobre 2008 à 0:55 Lier au commentaire

    Be careful!
    In the piece of code into this post there is a small error that I can not correct because the editor does not take into account!

    There is no space to put between ‘< ' and '?php'.

  2. guangzhoule 14 octobre 2008 à 3:37 Lier au commentaire

    that’s great !

    i downloaded your wordpress plugins evelt calendar

    thx!

  3. guangzhoule 14 octobre 2008 à 3:47 Lier au commentaire

    I am gmt+8 chinese beijing ,hongkong time!

    region,area question!

    not is

  4. Heiremle 14 octobre 2008 à 17:07 Lier au commentaire

    Hello guangzhou, taking into account the time zone will be included in a future version of Events Calendar. It’s in my ToDo List ;)

  5. jdchumanitiesle 14 octobre 2008 à 19:33 Lier au commentaire

    Hello,

    Thanks for the quick response about my CSS trouble. After poking around a bit, I found that Events Calendar (large) worked fine on both Google Chrome and IE. The problems I was experiencing only showed up when using Mozilla. Is this something you’re aware of? I will check through the CSS and see if I can find an easy fix. If anyone has any ideas, let me know.
    Thanks!

  6. jdchumanitiesle 14 octobre 2008 à 19:55 Lier au commentaire

    I have found that when using Mozilla, it looks better if you go into the CSS folder of Events Calendar and delete the code: border-collapse: collapse; The calendar doesn’t look as good as it did, but it does look the same on Mozilla, IE and Chrome. No open boxes or anything.

  7. Jean-Pierrele 15 octobre 2008 à 21:57 Lier au commentaire

    merci pour cet ajout.

    petite précision : je n’accède dans event calendar qu’aux catégories déjà utilisées. Les catégories pas encore utilisées n’apparaissent pas.

  8. Heiremle 16 octobre 2008 à 3:29 Lier au commentaire

    Bonsoir Jean-Pierre, très bonne remarque. Effectivement c’est un petit défaut que je vais m’employer à corriger, dès que j’en aurais un peu le temps.

    Mais vous pourriez chercher également de votre coté. En fait c’est probablement une option supplémentaire à ajouter dans le paramètre chaine de la fonction wp_dropdown_categories() qui va permettre de lister toutes les catégories, qu’elles aient été utilisées ou pas.

    Soit vous arrivez à trouver un site qui parle de tout cela en détails, soit, comme je l’avais fais, vous vous plonger courageusement dans les sources de Wordpress ;)

  9. Stephenle 16 octobre 2008 à 17:59 Lier au commentaire

    Bonsoir Heirem!

    I am curious if there is a way to have posts appear in event calendar?

    Merci!

  10. Stephenle 16 octobre 2008 à 18:01 Lier au commentaire

    To clarify:

    When I do ‘Write Post’ to have it create an entry for event calendar automatically…

    Merci!

  11. Picks-at-Fliesle 19 octobre 2008 à 20:06 Lier au commentaire

    Silly question… where does it get the list of categories from? Do we need to manually add (and populate) a new column to wp_eventscalendar_main?

    And thanks… I’ve looked at various calendars and once I got the events list working (thanks to your answer on your previous post), Events Calendar is by the far the best and perfect for what we need.

    Picks-at-Flies

  12. Picks-at-Fliesle 20 octobre 2008 à 2:55 Lier au commentaire

    Update:
    Okay, solved list of categories (waves newbie hat).
    It seems that your fix is only useful if you are creating a post from your calendar entry. Which is fine for a quick fix, but it wasn’t clear. It’s not a priority for me just yet, but if I feel coding urges I might have a fiddle.

    Thanks again.
    PaF

  13. Heiremle 20 octobre 2008 à 14:18 Lier au commentaire

    Hello Stephen, Frankly, I try and try again, I really do not understand your question. Even with the clarification. If anyone has understood, I will further explanations.

  14. Stephenle 20 octobre 2008 à 14:47 Lier au commentaire

    Merci Heirem!

    I will try again - When I write a new post, I would like it to automatically appear in the event calendar as an event with a link to the post. Is this possible?

    If not, that is okay - I will just create an event and link the post to it after I am done!

    Merci beaucoup!

  15. Heiremle 21 octobre 2008 à 1:14 Lier au commentaire

    Hello everybody,
    If you have applied the code of this post, and if you want the list of categories also display those are empty, here to make the changes.

    Just replace:

    wp_dropdown_categories('name=EC_CatPost');

    by

    wp_dropdown_categories('name=EC_CatPost&hide_empty=0');

    ;)

  16. Xavi Ivarsle 21 octobre 2008 à 9:04 Lier au commentaire

    Dear Heirem,

    It would be great if, in addition to choose a category, you could add a specific CSS class to an event: so they would be shown different in the calendar.

    And if those CSS-classes were per-category based, better (example: music events-> class event-music; travel event -> class event-travel, etc).

    You can see something like this here: http://www.racocatala.cat/agenda.php

    ;)

  17. Jean-Pierrele 21 octobre 2008 à 12:42 Lier au commentaire

    ça marche !

  18. Johanle 22 octobre 2008 à 14:24 Lier au commentaire

    Hej!

    Nice plugin, Im starting to get hold with it!

    One silly question: how do I remove an event? Cant find where they are stored…

    Salut!

  19. Heiremle 22 octobre 2008 à 21:25 Lier au commentaire

    Dear Xavi Ivars, it is an idea that has already been proposed. And that I find very good. But, as I often say these days, the world was not done in one day ;)

  20. Heiremle 22 octobre 2008 à 21:28 Lier au commentaire

    Hello Johan, in your dasboard, managing events, for each event, you do not have a red cross? Click on it to remove the event ! ;)

  21. cabotinele 22 novembre 2008 à 21:39 Lier au commentaire

    Hi,
    is there a way to always create and publish a post with a default category?
    This would really save a lot of clicks for our team. ;)
    Thx

  22. Heiremle 23 novembre 2008 à 23:29 Lier au commentaire

    Hello Cabotine, yes there is a possibility. To replace this parameter function:

    wp_dropdown_categories('name=EC_CatPost&hide_empty=0');

    With this:

    wp_dropdown_categories('name=EC_CatPost&hide_empty=0&selected='.$defcat);

    Of course ‘$defcat’ must contain the number of the category you want to default position.

    But you can also write this for example:

    wp_dropdown_categories('name=EC_CatPost&hide_empty=0&selected=2');

    ;)

  23. cabotinele 24 novembre 2008 à 0:38 Lier au commentaire

    thanks I ll try this…
    and how could I set to create always a post and always publish it?

    Thank you
    C.

  24. cabotinele 13 décembre 2008 à 19:52 Lier au commentaire

    I managed to always create and article and always publish it, but I dont know how to use more than one category for the article…
    Can you tell me?

    Btw. is the pot-file for german available anywhere? There are some translations missing…

    Thanks for your help
    C.

  25. cabotinele 13 décembre 2008 à 19:59 Lier au commentaire

    another question, where is the post created, I want to add some more default content to all posts…

  26. cabotinele 13 décembre 2008 à 20:50 Lier au commentaire

    found how to add the second one (after I re-read this post ;) ) and found where the post is created as well
    thx

  27. Heiremle 14 décembre 2008 à 0:34 Lier au commentaire

    Dear Cabotine, I think you know what that means “cabotine” in French isn’t it? So I think that you wear your nickname ;)

    Better management of the categories of all kinds, and import / export iCal is in my todo list. If you want to supplement or improve the translation file in German, I accept with pleasure :)

  28. cabotinele 14 décembre 2008 à 10:18 Lier au commentaire

    Actually I wasnt aware of the french translation, I use it because of the name of perfume by Gres…

    Could you email me the translation file
    Thank you
    C.

  29. Elana Findlowle 16 mars 2009 à 12:31 Lier au commentaire

    thanks for this - works great

  30. Heiremle 17 mars 2009 à 18:40 Lier au commentaire

    Hello Elana,
    Thank you very much for your donation !!
    It is a very touching and encouraging attention.
    Especially from someone who did not need support with Events Calendar!
    Best Regards

  31. Davele 22 juillet 2009 à 6:02 Lier au commentaire

    Thank You very much. Worked perfectly.

Laisser une réponse