Support

Home Forums Event Espresso Premium Question Group to Questions Mapping Name

Question Group to Questions Mapping Name

Posted: December 1, 2020 at 10:15 pm

Viewing 10 reply threads


texashauntersgroup

December 1, 2020 at 10:15 pm

Greetings,

When configuring “Question Groups” it would be very helpful if the text list of “Questions” also (or in place of) displayed the “Question Label (admin-only)” text. I have several questions that have the same “Question Text” and mapping them as is can be confusing. It seems by the definition you have listed in help for the “Question Label (admin-only)” this was the intended use for this field.

Let me know if this is possible today. If not please turn in an enhancement request for me if you would. Thank you!


Tony

  • Support Staff

December 2, 2020 at 2:43 pm

Hi there,

This is possible to do but you’ll need to override the template used within Event Espresso on the Question Group edit, are you comfortable with PHP?


texashauntersgroup

December 2, 2020 at 11:07 pm

Greetings Tony,

if you walk me through the changes in PHP I can make them. I hate to update the files that an update will overwrite. I try when possible to put updates in the child theme functions.php file. I have a few “add_filter” in there to change some basic text for Event Espresso today.


Tony

  • Support Staff

December 3, 2020 at 3:32 am

I hate to update the files that an update will overwrite.

If the only way to change this was indeed to change core files then I wouldn’t class that as a solution and would simple reply with it’s not currently possible as we don’t support editing core files (we do make an exception from time to time if its something like adding a filter that we then know will also be included in the next release).

I try when possible to put updates in the child theme functions.php file.

The themes functions.php file should hold functions that specifically affect the theme itself. I can’t tell you what functions as its different for everyone but anything that you want to keep applied even after changing your theme, should really go in a custom functions plugin:

https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/

I have a few “add_filter” in there to change some basic text for Event Espresso today.

Those are generally a good example of the above as if you did change themes you would likely still want those text changes to apply, meaning they would be ‘better’ in a plugin.

However, it’s really up to you 🙂

So to do this you need to override a template within Event Espresso, but that doesn’t mean you need to edit the template within EE itself.

Create a site specific plugin using the documentation above.

Within that plugins directory also create a ‘templates’ directory.

In the custom functions plugin file, add this code:

https://gist.github.com/Pebblo/cf18ff686cca964193cbd8026c2c3379

What that code does is hook into the display_template method within Event Espresso and allows you to override the path for a template file. The $custom_templates array holes the filenames that EE should be searching for to replace. Any additional file names should go on a new line after the comma and each line should end with a comma.

Now, you have a plugin that loads a custom version of question_groups_main_meta_box.template.php, however, it actually does nothing right now as we don’t have a custom template, so let’s get one!

Go to \event-espresso-core-reg\caffeinated\admin\extend\registration_form\templates\

Grab a copy of question_groups_main_meta_box.template.php and place it in your custom functions /templates/ directory.

If you just want to swap out question test for the adin label then lines 184 – 190

<span class="question-text"><?php
    echo trim($question->display_text())
         . (95 <= strlen(trim($question->display_text()))
            ? "&hellip;"
            : '');
    ?>
</span>

Change both display_text()calls to admin_label().

That’s it, you’re now loading your own custom version of the template and you’ve switched over to using the admin label without modifying core.


texashauntersgroup

December 4, 2020 at 12:47 am

Greetings Tony,

That worked perfectly. Thank you for the info!

I assume if I ever have an issue with that page I can disable the plugin and see if the issue goes away. If it does, I may need to update the question_groups_main_meta_box.template.php to the latest version and modify it again.

I had edited the functions.php file based on the link below but I have now moved that code into the custom plugin.

https://eventespresso.com/topic/change-ticket-selector-heading-text/

Thanks again for your help!


Tony

  • Support Staff

December 4, 2020 at 4:31 am

Yeah you’ll need to make sure you keep up with updates to that file but we do try to keep any business logic outside of the templates, they just control the display so you shouldn’t run into any issues even if we change the original a little.

I had edited the functions.php file based on the link below but I have now moved that code into the custom plugin.

It’s common to just use functions.php as it is essentially a plugin just tied to your theme. There’s technically nothing wrong with either (although sometimes you do get load order issues depending on what you’re trying to do) and there’s a lot of this kind of debate around.

In the end, if it works, it works. It’s only when you start changing themes and your customizations vanish that it becomes something you need to think about so I tend to favour a custom plugin unless the functionality is specific to the theme itself (like changing a string that the theme itself added etc).


texashauntersgroup

December 13, 2020 at 10:45 pm

Greetings Tony,

I have a follow-up question related to this topic.

When looking at a user’s registration on the back end under the “Registration Form Answers” section, is it also possible to update that template to display the “Question Label (admin-only)” text as opposed to the “Question” text?

Let me know when you have a chance. Thank you!


Tony

  • Support Staff

December 15, 2020 at 8:52 am

I checked into this and currently, it’s not easily done.

There is a hook available that allows you to completely override the method used to output that form, but to switch over to using the admin label text you’ll need to basically re-create your own function that outputs the same as what is available now but using the admin label.


texashauntersgroup

December 16, 2020 at 12:55 am

Thank you for checking Tony.

I recently had conditional questions implemented on my front end so that attendees would be provided different questions and question groups depending on which ticket they selected. Because of this, I have several questions that have the same label but have different options. Only the end admin label is different.

This can get confusing on the backend. Originally I was going to have my developer hide the questions on the backend like it is being done on the front end but those hooks are not present on the backed according to them. I thought updating to show the admin label would be a good second choice but it sounds like those hooks are not present either.

As a feature request can you ask to have hooks added to allow for hiding of questions/question groups on the backend as well as the use of the admin label?

Let me know if you have any questions.


Tony

  • Support Staff

December 16, 2020 at 6:20 am

This can get confusing on the backend. Originally I was going to have my developer hide the questions on the backend like it is being done on the front end but those hooks are not present on the backed according to them.

There is a hook available they can use to completely override the default output:

FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default

Its a filter so return false and echo out whatever you want to use in its place, however… it has been deprecated, mainly because its a filter being used an as action.

I thought updating to show the admin label would be a good second choice but it sounds like those hooks are not present either.

I’ll double-check with the developers on this to confirm something isn’t available already.


texashauntersgroup

December 16, 2020 at 9:11 pm

Thank you for checking Tony.

Viewing 10 reply threads

The support post ‘Question Group to Questions Mapping Name’ 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