dotnetic Posted March 13 Share Posted March 13 Let's assume you want to change the title of a an edit page. You could hook ProcessPageEdit:execute in a file like site/ready.php like described here. Adapt the template name in the following code to your needs: $wire->addHookAfter('ProcessPageEdit::execute', function (HookEvent $event) { $pageEdit = $event->object; $page = $pageEdit->getPage(); if ($page->template != 'shop') { return; // return early } $this->wire('processHeadline', 'My new headline'); // or modify the existing headline // $headline = $this->wire('processHeadline'); // $this->wire('processHeadline', $headline . " - " . date('d.m.Y', $page->created)); }); 2 Link to comment Share on other sites More sharing options...
bernhard Posted March 13 Share Posted March 13 Is that a tutorial or a question? Link to comment Share on other sites More sharing options...
dotnetic Posted March 13 Author Share Posted March 13 A tutorial. Adapted the title to reflect this. 1 Link to comment Share on other sites More sharing options...
Juergen Posted May 11 Share Posted May 11 Hello Is there a way to use HTML too to manipulate the headline (fe to add FontAwesome icons after the headline)? Best regards Link to comment Share on other sites More sharing options...
bernhard Posted May 11 Share Posted May 11 I don't think so. When I asked Ryan recently about modifications for our admin style he said he usually does those small modifications with JS. Not very pretty, but on the other hand this might be more robust than str_replace (which is not pretty either). 1 Link to comment Share on other sites More sharing options...
Juergen Posted May 11 Share Posted May 11 Thanks @bernhard That was my thought too. It is not so important. I have now added a subheadline instead of appending something to the main headline: $return = $event->return; $subheadline = '<h2>My Subheadline</h2>; $event->return = $subheadline.$return; No I can add every markup inside the subheadline (including icons too) Maybe a little bit offtopic: I guess that same problem persists on modal windows. I have created an Exception to prevent unwanted publishing of pages inside the page tree and the user will get a message with additional infos. I have also tried to add a little bit HTML to make the look and readability better, but without success. The modal window will be triggered with an exception code: throw new WireException('My exception text); If I try to add markup to the exception text, it does not work. Do you know, if it is the same issue as with the headline? Link to comment Share on other sites More sharing options...
bernhard Posted May 11 Share Posted May 11 1 minute ago, Juergen said: $return = $event->return; $subheadline = '<h2>My Subheadline</h2>; $event->return = $subheadline.$return; Would be nice to share the whole hook ? Link to comment Share on other sites More sharing options...
Juergen Posted May 11 Share Posted May 11 5 minutes ago, bernhard said: Would be nice to share the whole hook ? Sure ? $this->addHookAfter('ProcessPageEdit::execute', $this, 'addSubTitle'); protected function addSubTitle(HookEvent $event) { // Get page being edited $page = $event->object->getPage(); // Only use on pages with publishing fields if (!$page->hasField('jk_publish_from')) return; // this is only my restriction -> adapt it to your needs $subHeadline = '<p class="notes" style="padding: 5px; font-size: 20px;"><i class="fa fa-exclamation-triangle"></i>  My Subheadline</p>'; $return = $event->return; $event->return = $subHeadline.$return; } 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