arjen Posted November 22, 2012 Share Posted November 22, 2012 I am struggling to show the $page->path in as a <li> right after all the other actions like new, edit, et cetera. The reason for this is that a client has to copy a lot of his urls and it sames him some time being able to see them.I can get it to work as an action, but I'd would really like to just have an <li>. As an alternative a place after the closing <ul> is also great.Thanks in advance!This is what I have right now: <?php /** * PageListPath 0.0.1 ProcessWire module * * @author Arjen * @created 22/11/2012 * * ProcessWire 2.x * Copyright (C) 2010 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://www.processwire.com * http://www.ryancramer.com * */ class PageListPath extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'Page List Path', 'version' => 001, 'summary' => 'Adds the path to the page', 'autoload' => true ); } public function init() { $this->addHookAfter("ProcessPageListRender::getPageActions", $this, 'hookPageListActions'); } /** * Hook into ProcessPageListRender * */ public function hookPageListActions(HookEvent $event) { $page = $event->arguments[0]; $actions = $event->return; $actions[] = array( 'cn' => 'Copy', 'name' => 'Copy path', 'url' => "#" ); $event->return = $actions; } } Link to comment Share on other sites More sharing options...
apeisa Posted November 22, 2012 Share Posted November 22, 2012 What about Setup => Templates => basic-page (or any other template you need) => Advanced tab => List of fields to display in the admin Page List => "title path" Edit: and if "path" is too much information, you can use "name" also. Link to comment Share on other sites More sharing options...
Soma Posted November 22, 2012 Share Posted November 22, 2012 Simply add "url" like "title url" to the advanced template options for fields shown on page list. Damn I'm getting slow! Link to comment Share on other sites More sharing options...
arjen Posted November 22, 2012 Author Share Posted November 22, 2012 Thanks to the both of you, but I need this to use javascript to copy the path to the clipboard. Since I don't want to interfere with the default PW actions I've modified a theme that aligns the path right. There also will be /very-interesting/long/urls/using-this-technique so the path will be shortened for viewing purposes. Link to comment Share on other sites More sharing options...
Soma Posted November 22, 2012 Share Posted November 22, 2012 YOu could do it like this and add a jscript file and use the action to copy to clipboard or make a prompt: PageListPath.js $(function(){ $('.PageListActionURL a').live('click', function(e){ e.preventDefault(); console.log($(this).attr('href')); copyToClipboard($(this).attr('href')); }); }); function copyToClipboard(text) { window.prompt("Copy to clipboard: Ctrl+C, Enter", text); } And the module code <?php /** * PageListPath 0.0.1 ProcessWire module * * @author Arjen Blokzijl * @created 22/11/2012 * * ProcessWire 2.x * Copyright (C) 2010 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://www.processwire.com * http://www.ryancramer.com * */ class PageListPath extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'Page List Path', 'version' => 001, 'summary' => 'Adds the path to the page', 'autoload' => true ); } public function init() { $this->addHookAfter("ProcessPageListRender::getPageActions", $this, 'hookPageListActions'); $this->addHookAfter("ProcessPageList::execute", $this, 'addScripts'); } public function addScripts($event){ $this->config->scripts->add($this->config->urls->PageListPath . "PageListPath.js"); } /** * Hook into ProcessPageListRender * */ public function hookPageListActions(HookEvent $event) { $page = $event->arguments[0]; $actions = $event->return; $actions[] = array( 'cn' => 'URL', 'name' => 'url', 'url' => "$page->url" ); $event->return = $actions; } } 1 Link to comment Share on other sites More sharing options...
arjen Posted November 23, 2012 Author Share Posted November 23, 2012 Thanks soma! I will look into this today! Link to comment Share on other sites More sharing options...
arjen Posted November 30, 2012 Author Share Posted November 30, 2012 And there my first real module: https://github.com/arjenblokzijl/ProcessPagePathCopy The origin A client needed to copy a lot of handpicked pages. You can do it using "view" and rightclick, but I thaught a single click might be a bit easier. So I wrote (thanks to Soma) this little module which adds a "copy path" action. You can also select a prefix or select which template(s) the actions should be applied to. The client can use command/ctrl + c, switch to his e-mail, do command/ctrl - v, switch back press enter to continue to the next. I need to implement a flash based solution to make the last step redundant. Hopefully that is done the next couple of days. 4 Link to comment Share on other sites More sharing options...
Nico Knoll Posted December 1, 2012 Share Posted December 1, 2012 And now you should add it here: http://modules.processwire.com/ 1 Link to comment Share on other sites More sharing options...
arjen Posted December 2, 2012 Author Share Posted December 2, 2012 Will do Nico after the flash copy/paste has been introduced. 1 Link to comment Share on other sites More sharing options...
Nico Knoll Posted December 7, 2012 Share Posted December 7, 2012 -- Moved into development -- Please create a separate topic in "modules" for the finished module. Link to comment Share on other sites More sharing options...
Nico Knoll Posted December 7, 2012 Share Posted December 7, 2012 (edited) Edit: sry, posted this two times Edited December 7, 2012 by Nico Link to comment Share on other sites More sharing options...
ryan Posted December 17, 2012 Share Posted December 17, 2012 Arjen thanks for creating and sharing this module. Can you post to the modules directory? Link to comment Share on other sites More sharing options...
arjen Posted December 17, 2012 Author Share Posted December 17, 2012 I will. I ultimately dropped the Flash version since it won't work on IOS. I doubt if anyone ever wants to use this, but I will post it to modules directory. 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