Nico Knoll Posted December 29, 2011 Share Posted December 29, 2011 Hi, I try to modify the "InputfieldPageName". I'm using the render hook, but it returns the whole form so I'm looking for a way to only modify this specific field. Does anone know a way? Greets, Nico Link to comment Share on other sites More sharing options...
ryan Posted December 29, 2011 Share Posted December 29, 2011 You should be able to hook InputfieldPageName::render, but note that it will return markup (and should just be the <input /> tag). If you want to modify some attributes from it or something, then you'd want to hook in before(render). If you want to modify the returned markup you'd want to hook in after(render). Link to comment Share on other sites More sharing options...
Nico Knoll Posted December 29, 2011 Author Share Posted December 29, 2011 I just replaced the "<p class="...">" with preg_replace. But now I've got the problem that I have to save an additional template file (permalinkFormat) but if I use "___executeSave" I can't use "$this->input->post" because it does a redirect... Link to comment Share on other sites More sharing options...
ryan Posted December 29, 2011 Share Posted December 29, 2011 I just replaced the "<p class="...">" with preg_replace. It may be better to come in with a 'before' hook and as the class attribute directly, rather than doing a preg_replace. But I don't know the full context here so can't say for certain. but if I use "___executeSave" I can't use "$this->input->post" because it does a redirect... Can you hook in before it? i.e. $this->addHookBefore('ProcessPageEdit::executeSave', $this, 'myExecuteSave'); Link to comment Share on other sites More sharing options...
Nico Knoll Posted December 29, 2011 Author Share Posted December 29, 2011 YES! It works What does addHookBefore do exactly? Link to comment Share on other sites More sharing options...
Pete Posted December 29, 2011 Share Posted December 29, 2011 It literally runs your code before that process - saving the page in your case. Link to comment Share on other sites More sharing options...
ryan Posted December 31, 2011 Share Posted December 31, 2011 Here are the 4 different kinds of hooks, in order of use. The method you use to hook them is in parenthesis. 1. After hooks – execute after the hooked method (addHook or addHookAfter). Can access/modify return value and arguments. 2. Before hooks – execute before the hooked method (addHookBefore). Can access/modify arguments. 3. Method hooks – adds a new method to a class, assuming it's not already there (addHook). 4. Property hooks – adds a new variable/property to a class, assuming it's not already there (addHookProperty). Rarely used so far. 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