Christian Posted July 24, 2014 Posted July 24, 2014 Hi! Is there anyone here already try to modify the function of View function? I tried to modify it using Inputfield::render when I assign new value, nothing happen. Also, I tried to use Page::render to have a different button but I cannot get the current editable field value of the page.
Christian Posted July 24, 2014 Author Posted July 24, 2014 Ok. I already do this. What I do is this: public function init() { // add before-hook to the inputfield render method $this->addHookBefore("Inputfield::render", $this, "getPreviewURLField"); $this->pages->addHookAfter('Page::render', $this, 'hookFormRendering'); } public function getPreviewURLField(HookEvent $event) { $field = $event->object; if( $field->name == 'site_preview_url' ) { $this->url = $field->value; } } public function hookFormRendering(HookEvent $event) { // GET PAGE DATA $url = $this->url; $page = $event->object; if ( $url ) { $event->return = str_replace('<form id="ProcessPageEdit"', '<a href="' . $url . '" target="_blank">Go to site</a><form id="ProcessPageEdit"', $event->return); } } I have a follow question. Is this ideal
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