steveooo Posted February 25, 2016 Share Posted February 25, 2016 Ahoy captain! I need to hook into 2 areas of ProcessWire: - "view" page link on page tree - "view" page link on page edit (Are there more areas with these "view" links for pages or did I get everyone?) How can I hook into that in order to change the "view" link url? Arrr! It would be great if someone would help me with that! – Pirate GlassedEyes Link to comment Share on other sites More sharing options...
adrian Posted February 25, 2016 Share Posted February 25, 2016 Are you just wanting to add a _blank target? If so, then the easiest option might be this: https://processwire.com/talk/topic/7588-admin-custom-files/?p=89331 which of course uses Martijn's AdminCustomFiles. Link to comment Share on other sites More sharing options...
LostKobrakai Posted February 25, 2016 Share Posted February 25, 2016 Here's where the link and it's url is defined: https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Process/ProcessPageList/ProcessPageListActions.php#L38-L93 Link to comment Share on other sites More sharing options...
steveooo Posted February 26, 2016 Author Share Posted February 26, 2016 Hi. No, I want to change the url to something different. @LostKobrakai: This is only for the "view" link on the page tree actions, right? How can I hook into the "view" link when I edit a page. Any examples? I am not that great in "hooking" Link to comment Share on other sites More sharing options...
kixe Posted February 26, 2016 Share Posted February 26, 2016 A module is needed doing this.How to build a module: http://wiki.processwire.com/index.php/Module_CreationGet informed about hooks here: https://processwire.com/api/hooks/This one should do the job <?php /** * ProcessWire Module Modify View Url * * @version 100 * @copyright 2016 Christoph Thelen * @author kixe (Christoph Thelen note@qualyweb.com) * */ class ProcessModifyViewUrl extends Process implements Module, ConfigurableModule { static public function getModuleInfo() { return array( 'title' => 'Modify View Url', 'summary' => 'Provide alternative url for the action button \'view\' and the view tab under /page/edit/', 'author' => 'kixe', 'version' => 100, 'singular' => true, 'autoload' => true, 'icon' => 'mail-forward' ); } static public function getDefaultConfig() { return array( 'url' => 'http://example.org' ); } public function __construct() { foreach(self::getDefaultConfig() as $key => $value) { $this->$key = $value; } } public function init() { $this->addHookBefore('ProcessPageEdit::buildFormView', function($event) { $event->arguments(0, $this->url); }); $this->addHookAfter('ProcessPageListActions::getActions', function($event) { $actions = $event->return; $actions['view'] = array( 'cn' => $actions['view']['cn'], 'name' => $actions['view']['name'], 'url' => $this->url ); $event->return = $actions; }); } public function getModuleConfigInputfields(array $data) { $inputfields = new InputfieldWrapper(); $defaults = self::getDefaultConfig(); $data = array_merge($defaults, $data); $f = wire('modules')->get("InputfieldText"); $f->attr('name+id', 'url'); $f->label = __("Alternative Url"); $f->value = $data['url']; $inputfields->add($f); return $inputfields; } } 2 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