Display value of custom field in sidebar (wordpress)?

Hello there,

I have to say that this is a great plugin, but I have found it really hard to find any documentation - I can see that there is loads, but also, lots of it is at the moment outdated… Can you please help me with displaying custom values in sidebar?

Basically, I want to add a ‘event_name’ custom field, so the long ‘text’ field will be used as an event description. I have added an ‘event_name’ to the Custom Fields. I have modified a sidebar.php to display:

$sidebarEvent = '<li class="scheduler_sidebar_link"><a href="{*URL*}#date={*DATE_SQL*},mode=day">{*DATE*}</a></li><li><div class="scheduler_sidebar_text">{*EVENT_NAME*}</div></li>';

Note that I have tried with the {event_name} and {EVENT_NAME}. I can see that it is saved in the DB, but I don’t quite know how to get this value. I have tried using the scheduler.getLabel("event_name", event.event_name) in the line above, but this breaks my website:).

Please help, what am I doing wrong?

Thanks,
Maja

Unfortunately you can’t include custom fields in sidebar , in such way. getLabel solution can be used within client side logic only , and only inside the scheduler, as for now sidebar can contain only date and text of events.

Is there a way then?

Thanks:)

Is there any way to create and use this in sidebar, even programmatically? PHP is not my best language…:frowning:

Hello,

  1. scheduler.php
    Locate the following line:
$event = str_replace("{*TEXT*}", stripslashes($events[$i]['text']), $event);

add another line just after it:

$event = str_replace("{*EVENT_NAME*}", stripslashes($events[$i]['event_name']), $event);

Where $events[$i][‘event_name’]) is the custom property of your events you wish to display.

  1. sidebar.php
    Edit as necessary, for example:

$sidebarEvent = '<h4 class="scheduler_sidebar_link"><a href="{*URL*}#date={*DATE_SQL*},mode=month" target="_blank">{*DATE*}</a></h4><div class="scheduler_sidebar_text">{*EVENT_NAME*}: {*TEXT*}</div>'; $sidebarEvent = '<li class="scheduler_sidebar_link"><a href="{*URL*}#date={*DATE_SQL*},mode=month">{*DATE*}</a></li><li class="scheduler_sidebar_text">{*EVENT_NAME*}: {*TEXT*}</li>';
Best regards,
Ilya

Thank you very much for that Ilya! I have implemented all that, but it still wasn’t showing the name. Then I spent another 3h reading the code etc and figured out that basically, the class wasn’t getting any custom fields from the database. So, if anybody else is following thius thread, make sure that you find all places in the SchedulerHelper.php where other fields are read or updated from/to database and also add this custom filed there, too… I have found about 6-8 lines needed updating and that seems to work:)

I wrote a plugin that was designed to display the value of a custom field in the sidebar for a post or page… check out http://www.mlynn.org/graceful-sidebar-plugin the graceful sidebar plugin.

Good Luck!
Mike