Page 1 of 1

Modify multiple lines in twig file - Event System OC4.x

Posted: Sun Feb 18, 2024 11:59 pm
by samdz
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

Re: Modify multiple lines in twig file - Event Systme OC4.x

Posted: Mon Feb 19, 2024 12:16 am
by JNeuhoff
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.