update AG Posted January 3, 2024 Share Posted January 3, 2024 I am trying to hook into text inputfields to add additional markup to it. But it only adds the markup for the default language tab. How can I achieve, that it also adds to the other language tabs? public function init() { if ($this->initSettings()) { $this->addHookAfter("InputfieldText::render", $this, "markAllowedFields"); } parent::init(); } public function markAllowedFields($event) { // Get the object the event occurred on, if needed $InputfieldText = $event->object; $allowedFieldTypes = [ 'FieldtypePageTitle', 'FieldtypePageTitleLanguage', 'FieldtypeText', 'FieldtypeTextarea', 'FieldtypeTextLanguage', 'FieldtypeTextareaLanguage', ]; $currentPage = $this->wire('pages')->get($this->wire('input')->get->id); $allowedFields = []; if($currentPage && $currentPage->id) { foreach($currentPage->template->fields as $field) { if($field->type->name && in_array($field->type->name, $allowedFieldTypes)) { $allowedFields[] = $field->name; } } } $return = $event->return; if(in_array($InputfieldText->name, $allowedFields)) { $return .= '<div class="gpt-wire-helper-container"><a href="#" class="gpt-wire-helper-link" >Do Something</a></div>'; } $event->return = $return; } KR Orkun Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now