Post by samdz » Sun Feb 18, 2024 11:59 pm

Hi,

Is possible to replace multiple lines in same time in twig file using event system ?

For example want to remove this :

Code: Select all

 <label for="input-code" class="col-sm-2 col-form-label">{{ entry_code }}</label>
 <div class="col-sm-10">
 <input type="text" name="code" value="{{ code }}" placeholder="{{ entry_code }}" id="input-code" class="form-control"/>
<div class="form-text">{{ help_code }}</div>
<div id="error-code" class="invalid-feedback"></div>
</div>
I used this but not working;

Code: Select all

$html = '';
$find = '<label for="input-code" class="col-sm-2 col-form-label">{{ entry_code }}</label>
                <div class="col-sm-10">
                  <input type="text" name="code" value="{{ code }}" placeholder="{{ entry_code }}" id="input-code" class="form-control"/>
                  <div class="form-text">{{ help_code }}</div>
                  <div id="error-code" class="invalid-feedback"></div>
                </div>';
$output = str_replace($find, $html, $output);
Thanks

Active Member

Posts

Joined
Fri Jan 28, 2011 3:02 am

Post by JNeuhoff » Mon Feb 19, 2024 12:16 am

You modify the template in a view after event, where you can grab the generated output, and then simply add a jquery document ready section which would remove the $("label[for='input-code']") and $("#input-code").parent() portions.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am

Who is online

Users browsing this forum: No registered users and 4 guests