• Resolved sarumbear

    (@sarumbear)


    Is there a way to keep widget layout customisation inside the theme folder?

    I placed a ‘See all events’ link at the bottom of the EM widget that opens the events page, but obviously my edit will be over-written on the next EM update. How can I save such a change like you can with templates?

    One option (and the best one) is to place a field to write your own code using placeholder and other HTML at the bottom of the widget area.

    Riz

    http://wordpress.org/extend/plugins/events-manager/

Viewing 15 replies - 1 through 15 (of 16 total)
  • hi,

    you can duplicate widgets/em-events.php then place it in your theme directory and rename it; then in your theme functions.php you can put
    include("em-events-mod.php"); - if you rename the file as em-events-mod.php

    note: you have to rename also the class name

    Thread Starter sarumbear

    (@sarumbear)

    I received the following error when I placed the suggested line in my theme’s functions.php

    Fatal error: Cannot redeclare class EM_Widget in /usr/local/pem/vhosts/112942/webspace/httpdocs/simonmcbride/wp/wp-content/themes/sarumbear/em-events-mod.php on line 184

    change line at around 184/185 to add_action('widgets_init', create_function('', 'return register_widget("EM_Widget_Mod");'));; also did you rename class EM_Widget to e.g. class EM_Widget_Mod? also, change the title to 'title' => __('Events Mod','dbem'),

    Thread Starter sarumbear

    (@sarumbear)

    Duh! Forgot to rename the class. Sorry.

    I have renamed the class name on line 2 as below:

    class EM_WidgetMod extends WP_Widget {

    and the error is gone, but I cannot see the effect of changes I’ve made. It is still reading from the master file.

    on my file ’em-events-mod.php’ line 77 is changed to:

    echo "</ul>",'<div style="text-align:center;"><a href="http://www.simonmcbride.net/tour">See all concerts</a></div>';

    I cannot see the link at the bottom of the widget. It works if I change line 77 on the master file on the widgets folder.

    this is the line that produces the link
    $events_link = (!empty($instance['all_events_text'])) ? em_get_link($instance['all_events_text']) : em_get_link(__('all events','dbem'));

    Thread Starter sarumbear

    (@sarumbear)

    I changed all you said (I think) but still getting errors.

    Warning: Missing argument 2 for WP_Widget::__construct(), called in /usr/local/pem/vhosts/112942/webspace/httpdocs/simonmcbride/wp/wp-includes/widgets.php on line 324 and defined in /usr/local/pem/vhosts/112942/webspace/httpdocs/simonmcbride/wp/wp-includes/widgets.php on line 93

    The modified code is here

    change line 11 to function EM_WidgetMod() {

    this is my working file – http://pastebin.com/Apu2hwci

    Thread Starter sarumbear

    (@sarumbear)

    I made it work. A new widget with mod suffix is generated and I’m using that instead. I am also using your code instead of hard coding the URL, but I have a problem.

    I changed default text on lines 22 and 23 as below but it still shows ‘all events’.

    'all_events_text' => __('all concerts', 'dbem'),
    'no_events_text' => __('No concerts', 'dbem')

    I can see that there are a few more places on the file where the text ‘all events’ is declared. Do I have to change all those?

    depends on you, it is located inside function function form($instance) {

    Thread Starter sarumbear

    (@sarumbear)

    I’ve changed like 160 to read ‘all concerts’ as below but still it shows ‘all events’ on the widget?

    <input type="text" id="<?php echo $this->get_field_id('all_events_text'); ?>" name="<?php echo $this->get_field_name('all_events_text'); ?>" value="<?php echo (!empty($instance['all_events_text'])) ? $instance['all_events_text']:__('all concerts','dbem'); ?>" >

    Thread Starter sarumbear

    (@sarumbear)

    I think I finally get it. I missed the input field on the widget itself where you actually enter the text for ‘All events link text?’ and ‘No events text’. I changed that field and my link has now changed to ‘all concerts’. Those in the code were the place holders.

    I have question though: What is the purpose of the link text as the link wasn’t there in the first place? That is the whole purpose of customising the widget! Am I missing something?

    in which part of the widget?

    Thread Starter sarumbear

    (@sarumbear)

    I am so very sorry! Words are not enough to explain how stupid I feel right now. I missed the all events link option on the widget!

    I was trying to create an option that you were thoughtfully have already catered for. I missed that section of the widget panel completely. The standard panel had the facility I wanted all along.

    Please accept my sincere apologies for taking your time. I learned a lot from this thread but I feel VERY STUPID now.

    no problem; am glad that I was able to help you out.

    Thread Starter sarumbear

    (@sarumbear)

    You always do. Your support is exemplary.

    <still feel so very ashamed>

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘[Plugin: Events Manager] Customised widget layout?’ is closed to new replies.