Support

Home Forums Event Espresso Premium EE_Meta not working in various templates & how to make dropdown EE_Meta values

EE_Meta not working in various templates & how to make dropdown EE_Meta values

Posted: July 28, 2012 at 10:29 am


mcote

July 28, 2012 at 10:29 am

2 questions-

Point 1-The EE_Meta data works fine in the registration_page_display.php with the following code

<strong>Durée de la session: </strong> ?php echo do_shortcode('[EE_META type="event_meta" name="event_week_total" event_id="'.$event-&gt;id.'"]');? semaines

“I removed the signs before the ?php intentionally so the code could be read in this post”

whereas the code doesn’t work in other templates such as the payment_overview.php, the confirmation_display.php etc..

Question, is there some standard code I can add in those templates so that the EE_Meta shortcode is picked up? I absolutely need to diplay this information because it’s the information which summarizes the begining and ending dates of a whole semester. I therfore need to display the info everywhere, (Invoices, confirmations, lists etc….)

Point 2- When entering a new event there are already 3 default values when using the Event Meta boxes (event_hastag, event_livestreamed and event_format). Where can I make my own meta values default in those dropdowns?

  • This topic was modified 8 years, 4 months ago by  mcote.
  • This topic was modified 8 years, 4 months ago by  mcote.
  • This topic was modified 8 years, 4 months ago by  mcote.
  • This topic was modified 8 years, 4 months ago by  mcote.
  • This topic was modified 8 years, 4 months ago by  mcote.
  • This topic was modified 8 years, 4 months ago by  mcote.
  • This topic was modified 8 years, 4 months ago by  mcote. Reason: problems displaying the code
  • This topic was modified 8 years, 4 months ago by  mcote. Reason: problems displaying the code
  • This topic was modified 8 years, 4 months ago by  mcote. Reason: problems displaying the code


Josh

  • Support Staff

July 30, 2012 at 3:49 pm

Add this to the beginning of your custom templates:

<?php global $event_meta;
 $event_meta = event_espresso_get_event_meta($event_id); ?>

For point two, see the documentation section under Adding default meta key/values for example code:
http://eventespresso.com/wiki/shortcodes-template-variables/#ee-meta

Basically, you’d create a new function and place it in the theme’s functions.php file.


mcote

July 30, 2012 at 9:22 pm

I’ve added the code at the begining of the espresso_table.php file as you suggested and it didn’t work. Then I inserted the information in this section ( around line 56) by adding the $event_meta within those variables and nothing again.

function espresso_get_table($sql){
   global $wpdb, $org_options,$event_meta;
  //echo 'This page is located in ' . get_option( 'upload_path' );
  $event_page_id = $org_options['event_page_id'];
  $currency_symbol = $org_options['currency_symbol'];
  $events = $wpdb-&gt;get_results($sql);  $event_meta = event_espresso_get_event_meta($event_id);

I tried to compare looking at the code why those EE_meta codes are working in the registration_page.php versus the espresso_table.php but I can’t figure it out. Any suggestions?

For point number 2, what I found out which is interesting is that the default values come from the functions.php file found in the following folder: includes/admin-files/ around line 332, and not from the code I added into my themes folder as documented in the http://eventespresso.com/wiki/shortcodes-template-variables/#ee-meta . This is the code found in the functions.php,

 if (!function_exists('ee_default_event_meta')){
    function ee_default_event_meta(){
        return array("event_hashtag"=&gt;"","event_format"=&gt;"","event_livestreamed"=&gt;"");
    }

So to have my default key dropdowns and values, shouldn’t I place them in the functions.php found in /admin-files instead?


Josh

  • Support Staff

July 31, 2012 at 10:23 am

For the espresso_table template, it would be a little different, around line 91 add:

global $event_meta;
 $event_meta = unserialize($event->event_meta);

If you edit core files directly (eg admin-files/functions.php) you’ll lose your changes when you update Event Espresso. Copy the entire function over to the custom_functions.php file in the custom files add-on.


mcote

July 31, 2012 at 12:03 pm

Question no. 2 is now OK. I’ve added the entire function in the custom_functions.php and it works fine. Although it’s nothing like the documentation said…

For the first subject, using the $event_meta still doesn’t work, in fact the whole website crashed when I added that line (anywhere in the code)such as in this example:

      reg_limit;

 global $event_meta;
     $event_meta = unserialize($event-&gt;event_meta);

    $event_desc = wpautop($event-&gt;event_desc);

    $register_button = '<a>id.'" href="'.get_option('siteurl').'/?page_id='.$event_page_id.'&amp;regevent_action=register&amp;event_id='.$event-&gt;id.'&amp;name_of_event='.stripslashes_deep($event-&gt;event_name).'"&gt;S&#039;inscrire</a>';

    //Check to see how many open spots are available
    $open_spots = get_number_of_attendees_reg_limit($event-&gt;id, 'available_spaces') == 'Unlimited' ? 999 : get_number_of_attendees_reg_limit($event-&gt;id, 'available_spaces');
    //echo $open_spots;

    if ( $open_spots 


            event_name ?&gt;

If I were a programmer I would probably investigate more but since it’s not my cup of tea, I feel I keep running in circles. I also tried to apply what is said in the EE documentation but it’s not that clear so I haven’t found an easy way to add meta data in templates.


Josh

  • Support Staff

July 31, 2012 at 12:15 pm

I tested the code on my test site using the espresso_table.php template and it’s working fine.

When you copy the code from the forum into the template file, does it appear like the example you posted, or the one I posted? Specifically, is it:

$event_meta = unserialize($event->event_meta);

or

$event_meta = unserialize($event-&amp;gt;event_meta);

The first instance is correct, the second would most likely crash a site.


mcote

July 31, 2012 at 1:04 pm

I come up with the first instance, it’s the forum code which changes the signs. Maybe because my browser is in French…

I tested with a clean version of the template and you are correct, the code works fine therefore it must be the way I am calling the meta code. I have it this way;

        ?php echo do_shortcode('[EE_META type="event_meta" name="event_begin_date" event_id="'.$event-&gt;id.'"]');?  

Note: I had to remove the signs before ?php and at the end so you could see this code

  • This reply was modified 8 years, 3 months ago by  mcote. Reason: Again the code is chewed up so I removed the signs


mcote

July 31, 2012 at 1:32 pm

Josh, it works, there was most likely something corrupted in my template. Thanks for the support.

The support post ‘EE_Meta not working in various templates & how to make dropdown EE_Meta values’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3 Documentation for Event Espresso 4

Status: closed

Updated by  mcote 8 years, 3 months ago ago

Topic Tags

Notifications

This topic is: resolved
Do NOT follow this link or you will be banned from the site!