abmcr Posted November 5, 2021 Share Posted November 5, 2021 I want to change the label of the View anchor and i have created an hook as $wire->addHookAfter('ProcessPageEdit::buildForm', function(HookEvent $event) { $form = $event->return; $ppe = $event->object; $page = $ppe->getPage(); if(in_array($page->template->name, ['trail'])) { $button = $form->getChildByName('_ProcessPageEditView'); // How get this value?????? if($button) $button->value = 'My new text'; // Change the text } }); but how can get the exact reference to element; as you see in the attached image i have used the ID of the element but this is not the correct way because the code don't work... What is the correct logic for get the name for using it in an hook code? Thank you Link to comment Share on other sites More sharing options...
Jan Romero Posted November 5, 2021 Share Posted November 5, 2021 Hi, I’m on my phone, but I think you might want to hook ProcessPageEdit::getSubmitActions and change the label in the returned array. It will look like this: $event->return['view']['label'] Apologies if this is not 100% correct – I’m looking through the code on a first gen iphone SE ? You should also be able to change the text using ProcessWire’s translation capabilities. 1 Link to comment Share on other sites More sharing options...
Zeka Posted November 5, 2021 Share Posted November 5, 2021 Hi @abmcr I think you can try to use wireLangReplacements https://processwire.com/blog/posts/pw-3.0.155/#new-wirelangreplacements-function 2 Link to comment Share on other sites More sharing options...
abmcr Posted November 8, 2021 Author Share Posted November 8, 2021 On 11/6/2021 at 12:28 AM, Zeka said: Hi @abmcr I think you can try to use wireLangReplacements https://processwire.com/blog/posts/pw-3.0.155/#new-wirelangreplacements-function Thank you: very simple solution Link to comment Share on other sites More sharing options...
abmcr Posted November 8, 2021 Author Share Posted November 8, 2021 I want also change the label "view" in PageList: i have searched into the code and the data for showing the buttons is created in the ProcessPageList.js; the data used in this file is send from ProcessPageList.module in the public function renderReady not hookable.... It is possible in a way i not suppose, achieve my purpose? Thanks Link to comment Share on other sites More sharing options...
Zeka Posted November 8, 2021 Share Posted November 8, 2021 $this->addHookAfter('ProcessPageListActions::getActions', function($event) { $actions = $event->return; $actions['view']['name'] = 'SomeValue'; $event->return = $actions; }); Link to comment Share on other sites More sharing options...
abmcr Posted November 8, 2021 Author Share Posted November 8, 2021 Thank you Zeka... i have not clear the workflow of processwire admin .... Thank you : now i have a new info ? This is my working code $wire->addHookAfter('ProcessPageListActions::getActions', function($event) { $actions = $event->return; $page = ( $event->arguments('page')); if(in_array($page->template->name, ['myTemplate'])) { $actions['view']['name'] = 'My label'; } $event->return = $actions; }); 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