Support

Home Forums Event Espresso Premium EE Table Code

EE Table Code

Posted: February 22, 2016 at 8:39 am


Robert Zak

February 22, 2016 at 8:39 am

I have been using Filezilla to edit my code for the table template, and in doing so, trying to follow along some tutorials that were posted. I tried moving the date column first, and adding in a Price column. I thought I did everything correctly, but I am getting this error message:

Parse error: syntax error, unexpected ”); ?></th>’ (T_CONSTANT_ENCAPSED_STRING) in /home/content/p3pnexwpnas10_data02/62/2671462/html/wp-content/uploads/espresso/templates/espresso-events-table-template.template.php on line 51

I am not sure what I did wrong since this refers to the line, which I moved first but didn’t change:

<th class=”th-group”><?php _e(‘Date’,’event_espresso’); ?></th>

Any help? Thank you!


Tony

  • Support Staff

February 22, 2016 at 8:54 am

This may sound strange, but there are different types of single quotes ‘ and double quotes “, mainly style and unstyled.

I can’t be 100% sure if that’s the problem because the forum editor can change them when posting, however swap that line for:

<th class="th-group"><?php _e('Date','event_espresso'); ?></th>

Here it is in a gist to make sure its unstyled:

https://gist.github.com/Pebblo/40f8582f2da0d32a940c

Copy and paste that in place and re-test.

If it still doesn’t work copy all of the code from your template into gist or pastebin.com and post the link here for us to view. Note however we do not provide support for custom code, but in this case we can point you in the right direction ๐Ÿ™‚


Robert Zak

February 22, 2016 at 9:18 am

Thanks for the quick response. I do think that this forum just styled the quotes, but I tried to replace it anyway. It still is giving me the same error message, so I copied the info to gist:

https://gist.github.com/anonymous/304f6e31127d0f678d0e.js

A little nudge in the right direction is all I should need!


Robert Zak

February 22, 2016 at 9:20 am

Sorry, I’m not sure how that happened. This should be the right link:

https://gist.github.com/anonymous/304f6e31127d0f678d0e


Tony

  • Support Staff

February 22, 2016 at 9:31 am

Line 51 on that template is:

<?php if ($footable != 'false' && $table_paging != 'false'){ ?>

Whats the full shortcode you are using for the template?


Robert Zak

February 22, 2016 at 9:35 am

Oh I must have miscounted while I was just editing the file. Are you asking for the full shortcode I am using on the page with the error? That is:

[ESPRESSO_EVENTS_TABLE_TEMPLATE table_search=false order_by=start_date category_slug=”epa-rrp-ref”]


Robert Zak

February 22, 2016 at 9:39 am

Actually, I am not sure why there is a discrepancy, but when I could to line 51 on the actual file that is being put in the uploads folder through Filezilla, it is the line:

<th class=”th-group”><?php _e(‘Date’,’event_espresso’); ?></th>

Which makes sense, because the error [ the unexpected ”); ?></th>’ ] isn’t in the line marked as 51 in gist. But that still doesn’t really help my understand/resolve the problem.


Lorenzo Orlando Caum

  • Support Staff

February 22, 2016 at 10:33 am

Hi Robert,

Take a look at this line:

https://gist.github.com/anonymous/304f6e31127d0f678d0e#file-ee-table-template-L47

There is an single quote there before Price that is different.

Try using your code editor to do a find for that specific quote and replace it with the unformatted version. Then save changes and that should clear the error.


Lorenzo


Robert Zak

February 22, 2016 at 10:42 am

Lorenzo, thank you for the response. I replaced that line with an unformatted version, but the error is still there. Is there a specific problem with the โ€); ?></th>โ€™ that is referenced in the error message? It all looks like it should work.

I believe the error it is talking about is in this line somehow:

<th class=”th-group”><?php _e(‘Date’,’event_espresso’); ?></th>


Lorenzo Orlando Caum

  • Support Staff

February 22, 2016 at 11:21 am

Hi, could you post an updated gist?

The original one that you shared has at least one issue with the single quote.


Lorenzo


Robert Zak

February 22, 2016 at 11:29 am

No problem. This is how it looks currently,

https://gist.github.com/anonymous/05078d74fd0930210501


Tony

  • Support Staff

February 22, 2016 at 12:48 pm

Remove the ” around the param strings:

[ESPRESSO_EVENTS_TABLE_TEMPLATE table_search=false order_by=start_date category_slug=epa-rrp-ref]

You only need ‘ or ” with shortcode parameters when they contain spaces, yours do not.

Actually, I am not sure why there is a discrepancy, but when I could to line 51 on the actual file that is being put in the uploads folder through Filezilla, it is the line:

Is that not the template file you are including within the gist?


Robert Zak

February 22, 2016 at 1:17 pm

The quotes around the parameters worked fine before I started customizing the template. But if I remove them, it doesn’t change the error.

I had a typo. I meant “when I count to line 51”. It is the same file. But line 51 in my template that I am editing through Filezilla is different than line 51 when I copy and paste everything into gist.


Lorenzo Orlando Caum

  • Support Staff

February 22, 2016 at 1:37 pm

Hi Robert,

Your version works for me using your shortcode with an actual event category on my test site:

http://cl.ly/2e451F2l0c1L

Try this version (http://cl.ly/0E1v3s1r1h24) in the following location on your site:

/wp-content/uploads/espresso/templates


Lorenzo


Robert Zak

February 22, 2016 at 1:57 pm

Lorenzo, that worked perfectly! Do you mind telling me what was different between the gist I uploaded and the file you sent over? I would like to be able to figure this out on my own next time!


Lorenzo Orlando Caum

  • Support Staff

February 22, 2016 at 6:28 pm

Hi Robert,

That is a good question. I downloaded your file and then updated the filename and then uploaded it to my test site. I didn’t change any coding within the file itself.

Are you able to edit the updated file and have it work without any issues or is it still reporting errors after your changes via FileZilla?

If there are errors, then could you try a simple edit with Cyberduck?


Lorenzo


Tony

  • Support Staff

February 23, 2016 at 2:04 am

The quotes around the parameters worked fine before I started customizing the template. But if I remove them, it doesnโ€™t change the error.

Sorry I should have explained better, I didn’t say that it would fix it ๐Ÿ™‚

Eventually wrapping parameters within quotes will cause problems, styled quotes can cause the shortcode not to parse at all and we’ve seen that happen a few times, so best not to use those unless actually needed.

I had a typo. I meant โ€œwhen I count to line 51โ€. It is the same file. But line 51 in my template that I am editing through Filezilla is different than line 51 when I copy and paste everything into gist.

That shouldn’t be the case, line 51 should be the same in whichever editor your using.

The strange part is that Lorenzo’s file and your gist (v2) are identical when comparing using diffmerge so I’m really not sure why his works and your did not.

Its possibly related to the editor your using, can you let me know which text editor your using please?


Robert Zak

February 23, 2016 at 8:15 am

That is quite strange that his works and mine did not. When I click to view/edit the file, it opes up with TextEdit which was preinstalled on my computer. I am going to be making more changes today, so I will report back if making any edits causes the error again. Thanks guys!


Tony

  • Support Staff

February 23, 2016 at 8:25 am

You’re most welcome.

Please do let us know how you get on.


Robert Zak

February 24, 2016 at 9:05 am

I have slowly but surely continued editing, and there haven’t been any major issues. No more error messages have shown up yet, but I have still been struggling with a couple things.

I am trying to follow the tutorial for showing the first datetime without the time (e.g. December 10, 2014 instead of December 10, 2014 7:00am). However it seems like the sample code is different from my file.

This is what I have:

$datetime = end( $datetimes );

//let’s use date_i18n on the correct offset for the timestamp. Note it seems like we’re doing a lot of
//unnecessary conversion but this is so it works with two different pardigmas in the EE core datetime
//system, without users having to worry about updating.
$startdate = date_i18n( $date_format . ‘ ‘ . $time_format, strtotime( $datetime->start_date_and_time(‘Y-m-d’, ‘H:i:s’) ) );

Instead of this:

foreach ( $datetimes as $datetime ) {
$startdat = $datetime->start_date_and_time();
}

I have tried editing in a way that makes sense to me but I haven’t produced the results I am looking for.


Tony

  • Support Staff

February 24, 2016 at 9:11 am

Can you link us to the tutorial you are using please?

Also I’d recommend posting code examples either within a gist or http://pastebin.com/ and including the link here, the form adds styling and can oftn end up all just looking a mess (although its not too bad above)

If you just want the date you can use start_date(), like this

$datetime->start_date();

Or you can even pass the format in:

$datetime->start_date('Y-m-d');

I’d recommend installing Kint and wrapping the $datetime object within d();

You’ll get a really nice output that shows all of the available methods on the datetime object and you can see what you can use for various information from that.


Robert Zak

February 24, 2016 at 9:25 am

Apologies, I was following along one of Lorenzo’s gist templates. I was attempting the second alternate he provided.

https://gist.github.com/lorenzocaum/ac217033f12232404cce#comment-1349052

This is my current file:

https://gist.github.com/anonymous/db90d2ab4eaab5c499b5

I had previously tried editing the end of line 108 to remove the “_and_time” and “, ‘H:i:s'” as referenced above, but instead of taking away the time completely, it just says that they all start at 12:00 am now.


Lorenzo Orlando Caum

  • Support Staff

February 24, 2016 at 10:01 am

Hi Robert,

I updated the tutorial:

https://gist.github.com/lorenzocaum/ac217033f12232404cce#gistcomment-1349052

Thanks


Lorenzo


Robert Zak

March 2, 2016 at 10:10 am

Okay I’m back (hopefully for the last time).

I have been continuing to make edits successfully with no errors reporting! I have been attempting to follow other tutorials, and have found moderate success. However, there are still two things I cannot quite get right.

Here is my current code:

https://gist.github.com/anonymous/3369e974a9b89ea92ce9

1 (Line 126): The last thing I am trying to accomplish with the table itself is to be able to display only the “City, State” for the venue location. Right now it is showing the full location (using “espresso_venue_address”), but nothing shows up when I try changing it (even just to the parameter “espresso_venue_city”). Again, my ideal situation is for it to only display the “City, State”. I’ve also tried removing all details except for the city and state in the address area of the events (i.e. without a business name, street number, or country), but even that shows up as “City, State, UNKNOWN”.

2 (Line 21): This is a little tricky. We are currently using categories to designate which course it is and which location it is. That way, I can use a short code on the page like above (i.e.”[ESPRESSO_EVENTS_TABLE_TEMPLATE category_slug=epa-rrp-ref]”) to only display one type of course per table. But then I don’t want the course names to show up in the drop down category filter, I only want the consumer to see the location they are searching for (i.e. “Minnesota”, “New York”, etc.). I am fairly certain this is the bit of code I need to adjust so that it doesn’t “Show All”, but nothing I do pulls it up right. Is there a way here to exclude certain categories from showing up in the filter bar?

Just a final push in the right direction is all I need!


Lorenzo Orlando Caum

  • Support Staff

March 2, 2016 at 11:09 am

Hello,

See this tutorial: https://gist.github.com/lorenzocaum/afdc8aba310d6388cdd3

On two, there is a parameter to remove the dropdown menu:

category_filter=false


Lorenzo


Robert Zak

March 2, 2016 at 12:08 pm

Hey Lorenzo! That first tutorial seems to be exactly what I am looking for.

As for the second question. I still want the category filter to appear. I just don’t want all of the categories to appear. So for example, for each event we will either select “RRP Initial” or “RRP Refresher” to designate which kind of course it it. But we will also select “Minnesota”, “New York”, “Illinois”, etc. to designate which location the course take place at.

But then the drop down category filter will have all of the categories listed. I want to edit it so that I can use the short code to show only “RRP Initial” or “RRP Refresher” designated events, but I only want the state names (“Minnesota”, “New York”, “Illinois”, etc.) to show up in the drop down category filter. Does that make sense/is that possible?


Robert Zak

March 3, 2016 at 10:21 am

Looking through your files, it seems like this might be the solution, but I’m not quite sure how to implement it the way I want to.

https://gist.github.com/lorenzocaum/9d514b7eac07df81d602


Josh

  • Support Staff

March 4, 2016 at 2:16 pm

jQuery allows for chaining selectors, so you can remove as many of the categories as you want to by listing them out.


Robert Zak

March 7, 2016 at 7:31 am

Well, I think my real problem is figuring out where exactly to try putting this code. The tutorial isn’t quite clear on that. I tried creating its own php file, which did nothing. And I also tried putting it in my theme’s function.php file, which actually caused the whole site to go down until I corrected the change through FileZilla.

I know my page numbers and I know the category names, so I think if I could get this snippet of code in the right place and working, everything would communicate properly.


Josh

  • Support Staff

March 7, 2016 at 7:48 am

Hi Robert,

If the whole site goes down when you copy code into the functions.php file of the theme, that means there’s an error/typo, or something missing from your code. The same would happen if you add the uncorrected code to a site specific plugin.


Robert Zak

March 7, 2016 at 7:52 am

I directly copied what was in the tutorial. Except for changing the page number and the category name.

<script src=”https://gist.github.com/lorenzocaum/9d514b7eac07df81d602.js”></script>

Is the functions.php file the right place to add this then? Or should it be put in somewhere else?


Robert Zak

March 7, 2016 at 7:54 am

Sorry, I thought that would show you the text of the gist, not just the url. But if you follow the earlier link, that is what I have been basing this off.


Josh

  • Support Staff

March 7, 2016 at 8:00 am

If you included the opening PHP tag from the code, that will result in bringing the site down.


Robert Zak

March 7, 2016 at 8:07 am

That was the second attempt I did at adding it to the functions.php file, because just adding:

function ee_remove_category_options_from_dropdown() {
  if(is_page('12')){
 ?>
<script>
jQuery(document).ready(function () {
jQuery("#ee_filter_cat option:contains(Optimist Lanzarote)").remove();
});
</script>
 <?php
}
}
add_action( 'wp_footer', 'ee_remove_category_options_from_dropdown' );

didn’t make any changes to the specified page either. Am I doing something wrong or adding this to the wrong place?


Josh

  • Support Staff

March 7, 2016 at 8:30 am

Hi Robert,

This is a guess because you haven’t given us enough information to know for sure:

Where you have the code:
if(is_page('12')){

You’ll need to change the 12 to match the actual page ID of the page where you want the code to actually execute.


Robert Zak

March 7, 2016 at 8:34 am

As I mentioned earlier, when I put that into my functions.php file, I copy and pasted that exactly, except for I replaced the 12 with the appropriate page ID number as well as replacing the “Optimist Lanzarote” with the actual category title that I wanted to exclude and nothing happened.

Would Lorenzo have a better idea of what to trouble shoot in this situation, since he wrote the code in this tutorial?


Josh

  • Support Staff

March 7, 2016 at 8:45 am

Hi Robert,

Can you post a link to the page where you’re running the code, and also post the actual code you’re using? Not the code you started with (that’s not useful here) the actual code you’re using will be helpful to troubleshoot this.


Robert Zak

March 7, 2016 at 8:53 am

Josh, I actually went through to double check everything I had, and it turns out that the person who set up event espresso had a typo in the category name. I fixed that and everything seems to be working perfectly now. Thank you for your help in trying to resolve this!


Josh

  • Support Staff

March 7, 2016 at 9:05 am

You’re welcome.

The support post ‘EE Table Code’ 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