Support

Home Forums Event Espresso Premium Question code in template and about how espresso reacts to local dev environment

Question code in template and about how espresso reacts to local dev environment

Posted: November 4, 2013 at 10:18 pm

Viewing 8 reply threads


Matt Paul

November 4, 2013 at 10:18 pm

WordPress 3.7.1.
Version 3.1.35.P EE

Have WP site cloned and it is on a mamp local environment to make some thematic changes, work with templates, etc.

Question

Working with espresso_table.php template. All of the events when in the table indicate “registration is closed” when you click on the register and go the the event page.

the relevant code in the template is below – it says it was written by Author: Seth Shoultes
Contact: seth@eventespresso.com

/* Before php on question is general HTMl markup, CSS, and template tags for the other table cells in this area – this is my notes (Matt) to help describe the code */

// html and template tags before php in question

<?php

foreach ($events as $event){
$reg_limit = $event->reg_limit;

$event_desc = wpautop($event->event_desc);

$register_button = 'id.'" href="'.get_option('siteurl').'/?page_id='.$event_page_id.'&regevent_action=register&event_id='.$event->id.'&name_of_event='.stripslashes_deep($event->event_name).'">Register';

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

if ( $open_spots < 1 ) { $live_button = 'Closed'; }
$st = event_date_display($event->start_date, $format = 'M d, Y');
$en = event_date_display($event->end_date, $format = 'M d, Y');
$sd = event_date_display($event->start_date, $format = 'l');
$ed = event_date_display($event->end_date, $format = 'l');
?>
<tr class="espresso-table-row">
<td class="elink" style="text-align:left; font-weight: bold; color: #F8911D;">
<?php echo $event->event_name ?>
</td>
<td class="td-group" width="100">
<?php
if(($st == $en)||($sd == $ed)){
echo event_date_display($event->start_date, $format = 'l');
}else{
echo event_date_display($event->start_date, $format = 'l').'-'.event_date_display($event->end_date, $format = 'l');
}
?>

// more html and template tags before php in question

<?php
if( $is_active['status'] == 'REGISTRATION_CLOSED' ){
?>
<td valign="middle" align="center">
<?php
echo "<span style='font-size:14px; font-weight:bold; color:red; margin-top:5px;'>Closed</span>";
//echo "<br />event_name."' style='font-size:12px; font-weight:bold; color:#F8911D; text-decoration:underline;'>Join Waiting List";
echo "<br />Contact Us";
}else
if ( $open_spots == 0 ) {
?>
<td valign="middle" align="center">
<?php
echo "<span style='font-size:14px; font-weight:bold; color:red; margin-top:5px;'>Full</span>";
//echo "<br />event_name."' style='font-size:12px; font-weight:bold; color:#F8911D; text-decoration:underline;'>Join Waiting List";
echo "<br />Join Waiting List";
}else{
?>
<td class="td-group">
<?php echo $register_button; } ?>
</td>
</tr>
<?php } //close foreach ?>
</tbody>
</table>

<?php
}

Questions-
1) looking at it not sure what the issue is – because it works when it is live on the web (mattpaulsports.com) – also the event_list.php works.

2) Can anyone tell me the point of the else statement – open_spots == 0. Is it just a reinforcement of making sure it will show closed. Doesn’t the first part of the If statement handle that -if( $is_active[‘status’] == ‘REGISTRATION_CLOSED’ )

3. Why on both of those statements does the code not have a closing td tag. Neither <td valign="middle" align="center">; have a closing </td>. When you do put the closing tags in – the information disappears – so I am assuming it is good code. But not sure why it is so. Is it somehow using the td-group’s closing tag from the register_button statement?

<td class="td-group">
echo $register_button; }
</td>

4. If I want to move the Register button to the first td in the row – I need to bring all of that code with it I take it.

5. Is that last line correct? Where is the closing php tag?

<?php
}

Thanks in advance.

Matt

  • This topic was modified 11 years ago by Matt Paul.
  • This topic was modified 11 years ago by Matt Paul.
  • This topic was modified 11 years ago by Matt Paul.


Matt Paul

November 4, 2013 at 10:27 pm

code keeps getting messed up using code tag in editor not sure what the issue is.

// html and template tags before php in question

<?php

foreach ($events as $event){
$reg_limit = $event->reg_limit;

$event_desc = wpautop($event->event_desc);

$register_button = 'id.'" href="'.get_option('siteurl').'/?page_id='.$event_page_id.'&regevent_action=register&event_id='.$event->id.'&name_of_event='.stripslashes_deep($event->event_name).'">Register';

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

if ( $open_spots < 1 ) { $live_button = 'Closed'; }
$st = event_date_display($event->start_date, $format = 'M d, Y');
$en = event_date_display($event->end_date, $format = 'M d, Y');
$sd = event_date_display($event->start_date, $format = 'l');
$ed = event_date_display($event->end_date, $format = 'l');
?>
<tr class="espresso-table-row">
<td class="elink" style="text-align:left; font-weight: bold; color: #F8911D;">
<?php echo $event->event_name ?>
</td>
<td class="td-group" width="100">
<?php
if(($st == $en)||($sd == $ed)){
echo event_date_display($event->start_date, $format = 'l');
}else{
echo event_date_display($event->start_date, $format = 'l').'-'.event_date_display($event->end_date, $format = 'l');
}
?>

// more html and template tags before php in question

<?php
if( $is_active['status'] == 'REGISTRATION_CLOSED' ){
?>
<td valign="middle" align="center">
<?php
echo "<span style='font-size:14px; font-weight:bold; color:red; margin-top:5px;'>Closed</span>";
//echo "<br />event_name."' style='font-size:12px; font-weight:bold; color:#F8911D; text-decoration:underline;'>Join Waiting List";
echo "<br />Contact Us";
}else
if ( $open_spots == 0 ) {
?>
<td valign="middle" align="center">
<?php
echo "<span style='font-size:14px; font-weight:bold; color:red; margin-top:5px;'>Full</span>";
//echo "<br />event_name."' style='font-size:12px; font-weight:bold; color:#F8911D; text-decoration:underline;'>Join Waiting List";
echo "<br />Join Waiting List";
}else{
?>
<td class="td-group">
<?php echo $register_button; } ?>
</td>
</tr>
<?php } //close foreach ?>
</tbody>
</table>

<?php
}


Dean

November 5, 2013 at 1:09 am

Hi Matt,

Sorry about the code formatting, it goes wonky sometimes. For large chunks of code we recommend using a service such as pastebin.com.

Before I answer, please note that the espresso table will be deprecated in the near future, we have an alternative templating system we are about to launch which will replace it.

1) When you cloned the site, did you use something like WP Migrate DB in order to make sure that any URLS in the database were correctly changed?

2) Which file is this from? That code isn’t in the latest version of the Custom Files addon that I can see.

3) All the td tags in the default file (espresso-table.php) have closing tags, so not sure why yours don’t.

4) Yes

5) Yes it is correct. A closing php tag is not always required and in WordPress files it is advised to omit it – http://hardcorewp.com/2013/always-omit-closing-php-tags-in-wordpress-plugins/


Matt Paul

November 5, 2013 at 11:23 am

Thanks for the answer.
Okay thanks I will use pastebin in future.
Response to your questions

1. I dont’s remember using “WP Migrate DB “. I used this documentation
http://codex.wordpress.org/Changing_The_Site_URL
– In that doc. I edited the config file; edited the htaccess file; and manually had to change a database field for one plugin
– so you think it has to do with the migration – not the code? That should be fine i can test the file on the live site late night – to see if thats what you think. Can you confirm I am understanding correctly on that?

2. The file’s name is espresso_table.php. I did not implement it – that is not a default template I take it. In my case I dont’t want a table anyway – I want to use divs to make it look like 2 column table with: 1 column program name and register button and second column with all the information data about the program ie. Start time; start date; end date, etc.

– So I was using that since it is recognized by event espresso – just changing the markup.
-should I use event_list and event list display?
– You say deprecated – if I want to make a custom template and make my own table for display what default template should I work off of that will not be deprecate?

3. Weird – okay.

4. Okay I will check that doc. Thanks.

Question – this custom file addons when i go to the page to check it out
https://eventespresso.com/wiki/custom-files-addon/
where do you download the files?

it gives me this message
The page you are trying to access is reserved for VIP Members and Event Espresso Business License holders. Please upgrade your support license for Event Espresso, purchase VIP access or log-in. If you think you are receiving this message in error, contact us.

The account is a business license account – not sure why i get that message. I wanted to check out the files and read documentation on best practices-as someone else originally did the set up. Is there a link you can give me? Or direct me in the right place.

Last quesion
Also premium support – right now i take it I am not signed up for that. Are the questions that I am asking normally for that service. Cause I need to get things moving on the change – and would like to use the service that is going help me streamline the effort.

Thanks


Matt Paul

November 5, 2013 at 11:41 am

I wanted to just add this – what it comes down to – rather then play around with this code- what file or files are a good default file to work with to customize.

Goal’s

1. I want to have a section pages that lists all of the events of the relative category. IE. Basketball events; soccer events;

2. THe lead into a detailed registration page

3. When the event is closed – it changes the markup in both to display a closed message

Questions:
– is goal #3 is this a feature that comes out of the box in event espresso?
– best practice steps:
1. make a template;
2. make a page(page not post);
3. choose the template for the page that i made in the dropdown;
4. Put shortcode- directly in the text editor in the page that I am creating ie. [EVENT_LIST category_identifier=your_category_identifier]

Thanks


Matt Paul

November 5, 2013 at 12:14 pm

correction on step # 3 – I would not choose a wordpress template as the espresso template is called from the shortcode I am using in this case event list.

Can anybody confirm I am understanding that correctly?


Josh

  • Support Staff

November 5, 2013 at 1:46 pm

Hi Matt,

Your best choice right now is to use the event_list_display.php and event_list.php templates and customize those if need be.

When you migrate a site, the URL paths in the database (which can be links to events, image paths, and settings) need to be updated. The WP migrate DB plugin is an excellent choice.

With your questions here:

https://eventespresso.com/topic/local-development-environment-question/#post-65089

As of Event Espresso 3.1.x you are correct that they are not page templates, but rather shortcode templates. You can add your custom templates to /wp-content/uploads/espresso/templates and they will load from there. There is more info in the documentation about modifying templates. Here are a few links:

https://eventespresso.com/wiki/put-custom-templates/

https://eventespresso.com/wiki/customizing-your-upcoming-events-widget-using-css-and-template-files/


Matt Paul

November 5, 2013 at 3:04 pm

okay thanks for the answers


Josh

  • Support Staff

November 5, 2013 at 3:41 pm

You’re welcome. I missed the question you had about the custom files add-on. You can download those files from your account page.

Viewing 8 reply threads

The support post ‘Question code in template and about how espresso reacts to local dev environment’ 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.

Event Espresso