Overridden Template view/meta/text.php not called

Home Forums Ticket Products Event Tickets Plus Overridden Template view/meta/text.php not called

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1265381
    Andras
    Participant

    The template file event-tickets-plus/src/views/meta/text.php specifies in its header that it may be overridden by placing a copy of the file at [your-theme]/tribe-events/meta/text.php.

    We planned to implement default values for custom text fields in woocommerce-based tickets, and fill them with values from the current logged-in user (like first/last name and email).

    We did override the text.php template in our custom theme, but it is not called. We tried to view an event page with one woocommerce-based ticket with a few custom text fields defined. Our custom changes to the text fields are not present on the final page. Making other obvious changes to the html in the template file did not occur on the final event page, and it is evident that the overridden template file is not used by Event Tickets Plus.

    When searching your code for the cause of this, we found one instance where the text.php template is loaded in the file Abstract_Field.php on line 222:

    include Tribe__Tickets_Plus__Main::instance()->plugin_path . “src/views/meta/{$template}”;

    This clearly loads the template file exclusively from your own plugin directory, and not from /tribe-events/meta in a theme directory (as the template file header states).

    We needed to replace the text.php file in the original tribe-events-plus plugin directory to make our changes visible, but this solution is clearly not acceptable. The changes will be overwritten at next update and we do not want to make changes in the plugin directory.

    As usual, we tested this with all other plugins inactive (except woocommerce), but obviously used our own theme to use the theme-overridden files.

    How do we solve this issue?

    #1267809
    Barry
    Member

    Hi Andras,

    Thanks for contacting us and my apologies for the slower than normal response: we’ve been experiencing higher demand for support than normal and that has regrettably resulted in some extra delays.

    This clearly loads the template file exclusively from your own plugin directory, and not from /tribe-events/meta in a theme directory (as the template file header states).

    You’re absolutely right. This is a bug or oversight and I’ll log a ticket on our internal tracker so we can address this in a future release.

    How do we solve this issue?

    A safe way to workaround this without modifying core plugin code would be to override src/views/meta.php instead. You could then modify the following loop:

    foreach ( $meta_fields as $field ) {
    	echo $field->render();
    }

    It should be possible to test if the field is of the type ‘text’ by inspecting the $field object’s type priority. You could then handle those fields using some other logic:

    foreach ( $meta_fields as $field ) {
    	if ( 'text' === $field->type ) {
    		custom_text_type_meta_field_renderer( $field );
    	}
    	else {
    		echo $field->render();
    	}
    }

    Of course, you would need to define the custom function responsible for rendering the field – though you could closely base it on the existing code found in:

    • Tribe__Tickets_Plus__Meta__Field__Abstract_Field::render()
    • Tribe__Tickets_Plus__Meta__Field__Abstract_Field::render_field()

    Does that help at all?

    #1268119
    Andras
    Participant

    Yes, it does indeed!

    We overrode the meta.php template instead, as you suggested, and created a special helper function combining render(), render_field(), and the contents of our version of text.php into it, and this seems to function correctly as a temporary measure.

    Looking forward to your future release where this will be fixed.

    Thank you for your help!

    #1268223
    Barry
    Member

    Glad that worked — and as soon as we have an update in place that resolves this we’ll do our best to post an update in here 🙂

    Thanks for your patience in the meantime.

    #1329131
    Victor
    Member

    Hello Andras!

    Just wanted to share with you that a new maintenance release (for the Week of 24 July 2017) is out, including a fix for this issue 🙂

    Find out more about this release → https://theeventscalendar.com/maintenance-release-week-24-july-2017/

    Please update the plugins and let us know if the fix works for your site.

    Best,
    Victor

    #1339183
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Overridden Template view/meta/text.php not called’ is closed to new replies.