Posted: March 28, 2013 at 2:20 am
|
I am attempting to create a duplicate of the espresso_table custom file template so that I can have a different variation of it. I know how to modify template itself, but in some cases I want a table that only has a course name and register column and other times I need one with more columns/details (but I need them both showing at the same time, so I can’t just edit the original template). I will briefly run through what I’ve done so far. It’s late and I was winging it, so I’ll try to stay coherent! At one point earlier on I got the shortcode I created to display the original esspreso_table’s template, so I figure I am headed somewhere in the right direction. Anyhow, I duplicated the espresso_table.php file and renamed it espresso_tabletest. Inside that file at the top I changed what function it was referencing on line 12 to: <code>function espresso_display_tabletest($atts){ </code> Went into the custom_shortcodes.php and copied the chunk of code used for the espresso_table and edited it with my names: <code>function espresso_tabletest($atts) { ob_start(); espresso_display_tabletest($atts); $buffer = ob_get_contents(); ob_end_clean(); return $buffer; } add_shortcode('ESPRESSO_TABLETEST', 'espresso_tabletest'); </code> And in custom_includes.php I did the same thing, found the espresso table code and modified it to fit my new template: <code>if (file_exists(EVENT_ESPRESSO_TEMPLATE_DIR."espresso_tabletest.php")){ require_once(EVENT_ESPRESSO_TEMPLATE_DIR."espresso_tabletest.php"); } </code> Right now I am getting the page to display but I’ve got this error: Fatal error: Call to undefined function espresso_display_tabletest() in /home/content/73/10778773/html/wp-content/uploads/espresso/custom_shortcodes.php on line 132 So it’s clearly not recognizing my new function and I went into the custom_functions.php and didn’t see anything referencing the espresso_table, so I am stopping here for the night/early early morning. My only other guess is that I didn’t do something right in the custom_shortcodes file? I was hoping I’d be able to just duplicate and modify the code I found for espresso_table – did I get close? Flying by the seat of my pants on this one. Thanks ahead of time! |
|
Hi, You are certainly on the right path here. From what I can see everything is done correctly, there must be a typo error somewhere, where it is still referring to the older function. I couldnt recreate your issue exactly, but I hit a similar one where I forgot to change a function name over in the main table file. I would take another look in the morning after some coffee, the error is likely to hit you. If not, feel free to add the code to a service like pastebin and we can take a quick look at it and see if a fresh pair of eyes can find the issue. |
|
Alright, by main file table are you talking about the new variation of espresso_table.php? I’ve had some coffee, so I am going to look through the code again shortly. If I get stuck I will use pastebin and see if you guys can spot anything I may have done wrong. Also, I noticed that in the espresso table if you have an apostrophes in the course name it will have slashes put in front of it inside the table. I searched and read about the stripslash function, so I’d assume that needs to be thrown into the espresso table template somewhere. Thanks! |
Hi Yolande, I can’t say for sure what file Dean meant, but I think he might have meant custom_shortcodes.php. With the stripslashes, that’s correct, there aren’t any stripslashes there, but they can be added to strip the slashes from the event name:
|
|
|
Thanks for the stripslash code josh, it worked perfectly. And I got back to tinkering with my template duplicate and got it to work! In my espresso_tabletest.php I missed a piece of code on line 52 that was referencing the original espresso_table code (echo espresso_get_table($sql);) so once I changed that to get_table_test all went well. Managed to skip over that piece of code last night. Thanks again! |
|
And I meant to type that I changed the code to get_tabletest. I’d still be in the same boat if I added an extra underscore into the code for no reason! |
|
Glad you got it sorted! |
The support post ‘Duplicating the espresso_table template’ 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.