Soma Posted September 9, 2011 Share Posted September 9, 2011 HelperFieldLinks Just got a new module working that is only visible to superusers, and is handy for when developing a site, or investigate someone elses.1. It adds a shortcut link to all fields on page in the backend. The link name equals the field name, so on very large complex sites with lots of fields, it can help to quickly see what name the field has.2. It also adds a shortcut to the used template (in the template select field under "Settings" tab). They appear on bottom right corner of the field.Any suggestions for a better module name and general feedback is welcome.ProcessWire Modules Directory: http://modules.proce...er-field-links/Direct github download: https://github.com/s...elperFieldLinks 7 Link to comment Share on other sites More sharing options...
ryan Posted September 9, 2011 Share Posted September 9, 2011 Nice module Soma, and great (useful!) idea. I look forward to trying this one out later today. Link to comment Share on other sites More sharing options...
Soma Posted September 9, 2011 Author Share Posted September 9, 2011 Thanks Ryan. Got a new version with the gear icon added to make it a little more sexy... Link to comment Share on other sites More sharing options...
ryan Posted September 9, 2011 Share Posted September 9, 2011 Soma I tested out here–nice job and congrats on your first second module! Just a few suggestions: 1. It's not safe to assume that PW admin is at /processwire/. For instance, the one I tested in is at /mysite/processwire/ (off a subdirectory), and someone else's might be at /admin/ or /my-private-url/ or something like that. As a result, you'll want to replace this: <a href='/processwire/setup/field/edit?id={$id} ... with this: <a href='{$this->config->urls->admin}setup/field/edit?id={$id} ... And likewise with the templates one. 2. I'm getting double field links with Page reference fields. This is because Inputfield::render actually gets called twice for a Page reference. It's a little different than the other fields since it lets you delegate the input to another Inputfield (like select, select multiple, checkboxes, radios, etc.). So InputfieldPage::render gets called first, and then the delegate Inputfield gets called second. The result is two of your links appear. As a result, I would suggest preventing this by either keeping a list of field names you've already populated, or just checking if your markup already appears in the output, like: if(strpos($event->return, 'fieldEditLink')) return; 3. With hooks that get called multiple times, it's more efficient to move the if() before you add the hook, rather than have it within the hook. Or to word it differently, move this: if($this->process == 'ProcessPageEdit' && $this->user->hasRole('superuser')){ …out of addShortcutLinks(), and into init(). The only problem is that init() gets called before the page is even loaded, so you can't determine if($page->process == 'ProcessPageEdit') yet. However, you can do this: <?php public function init() { if(strpos($_SERVER['REQUEST_URI'], $this->config->urls->admin . 'page/edit/?id=') !== false && $this->user->hasRole('superuser')){ // add stylesheets $this->config->styles->add($this->config->urls->HelperFieldLinks . "HelperFieldLinks.css"); // add a hook after each inputfield is rendered and modify the output $this->addHookAfter('Inputfield::render', $this, 'addShortcutLinks'); } } The advantage of the approach above is that it significantly reduces the number of times your hook is called when it's not needed. There's nothing technically wrong with the way you were doing it before either, so I'm just mentioning this as an efficiency optimization. Lastly, and perhaps more importantly, move your stylesheet loader into that if() statement as well (like in the code example above). No need to have your stylesheet loading when it's not going to be used. Link to comment Share on other sites More sharing options...
Soma Posted September 9, 2011 Author Share Posted September 9, 2011 Thank you Ryan for taking the time to look at it, amazing suggestions with code examples, haven't really considered these things yet! That all makes sense. Thank you a bunch. But, it's actually my second module see here http://processwire.com/talk/index.php/topic,435.0.html ;D Link to comment Share on other sites More sharing options...
Soma Posted September 10, 2011 Author Share Posted September 10, 2011 Implemented the suggested changes. It's working good so far. Attached new version to first post. Link to comment Share on other sites More sharing options...
ryan Posted September 10, 2011 Share Posted September 10, 2011 Wow that was fast. Thanks for the update. I can't wait till I get back to the office Monday to try out these new modules. Link to comment Share on other sites More sharing options...
ryan Posted September 12, 2011 Share Posted September 12, 2011 Just tried it out, looks great and works great! Thanks Soma! Link to comment Share on other sites More sharing options...
Soma Posted September 20, 2011 Author Share Posted September 20, 2011 Thanks Ryan, glad you like it! Just wanted to mention, it's on github now: https://github.com/somatonic/HelperFieldLinks Link to comment Share on other sites More sharing options...
Soma Posted June 5, 2012 Author Share Posted June 5, 2012 I just commited a fix to this module causing some issues with a not well formed span tag. I noticed when I got problems with it adding other markup using hooks to inputfields. I've seen some people using this module so I thought I'd make a note . 1 Link to comment Share on other sites More sharing options...
recyclerobot Posted June 18, 2012 Share Posted June 18, 2012 Hi Soma, love your plugin, timesaver! just quick note: the link on the http://processwire.com/download/modules/ links to the old forumpost, maybe ryan can update it to the new one so more people can enjoy faster development 1 Link to comment Share on other sites More sharing options...
Soma Posted June 18, 2012 Author Share Posted June 18, 2012 Thanks recyclerobot! Just fixed the link, thanks for mention it. 1 Link to comment Share on other sites More sharing options...
alan Posted September 29, 2012 Share Posted September 29, 2012 Thank you very much for this Module Soma! Just seeing the real Field name is often a lovely time-saver Thanks! 1 Link to comment Share on other sites More sharing options...
diogo Posted September 29, 2012 Share Posted September 29, 2012 Somehow I missed this post before... nice module Soma! Thanks! And thanks Alan for bringing this up again 1 Link to comment Share on other sites More sharing options...
apeisa Posted September 30, 2012 Share Posted September 30, 2012 I should really start using this. My current method is to use Chrome's inspector to see the real field name from source html... 1 Link to comment Share on other sites More sharing options...
Soma Posted September 30, 2012 Author Share Posted September 30, 2012 I should really start using this. My current method is to use Chrome's inspector to see the real field name from source html... Wooot? Hehe, this module was one of my first helpers. Couldn't without it and I think it saved me hours already. 1 Link to comment Share on other sites More sharing options...
alan Posted September 30, 2012 Share Posted September 30, 2012 @diogo Happy if I accidentally helped And I used to be less efficient @apeisa than you, I hadn't realized the field name was in the page and visible in Chrome Inspector and used to go back to the field list all the time, oUCH, so Soma's Module is luxury! Link to comment Share on other sites More sharing options...
Soma Posted January 31, 2013 Author Share Posted January 31, 2013 Just updated to 1.0.3 with some fix and new feature. fixed issue with template edit link added support for repeater fields http://modules.processwire.com/modules/helper-field-links/ 2 Link to comment Share on other sites More sharing options...
Soma Posted November 22, 2013 Author Share Posted November 22, 2013 Just pushed an update to 1.0.5 to fix issues once again (!) - updated to account for current new development on admin theme - some optimizations - kinda fixed an issue with the new LanguageFieldsTabs. - It was getting overlayed by the tabs. Also the LanguageFieldTabs alters the field content via JS and appends the tabs, which results in my Helper links being at the top instead at the bottom! Annoying and not possible to fix from my side, but if LanguageFieldTabs.js would prepend() the tabs instead of append() it would be better. I don't see an easy way to account for this issue from my side, maybe someone has an good idea. - but for now it's on top of those fields using language tabs. - added new feature to toggle a layer when clicking on the little gear icon, with some infos on the field settings, which can be useful when developing without going to the field editing screen. There maybe still issues in some cases I haven't tested or thought of. Thanks 2 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted November 22, 2013 Share Posted November 22, 2013 @Soma great addition ps, There's a notice on line 80: Array to string conversion. 1 Link to comment Share on other sites More sharing options...
Soma Posted November 23, 2013 Author Share Posted November 23, 2013 Thanks Martijn. I can't see that notice here, I guess php version matters? Somehow the $value in some cases is still an array and my lazy method to get and render the settings may not account for all possible settings there is for different fields. I'm not sure it is gone now that some changes were made. I pushed another update to 1.0.6 - added settings toggle support for template field - there's even more settings being shown now for fields Thanks Link to comment Share on other sites More sharing options...
Martijn Geerts Posted November 24, 2013 Share Posted November 24, 2013 Update fixed the ‘notice’ issue. Tnx again Soma ! Link to comment Share on other sites More sharing options...
Martijn Geerts Posted November 24, 2013 Share Posted November 24, 2013 The notices comes from the all the 'roles' arrays. I don't see them anywhere in the helper text (weird that they're bugging me). These are: editRoles, addRoles, createRoles & roles. I changed the line 156 to this prevents the notices. if(is_array($data_value)) $data_value = implode(" ", $data_value); $settings_str .= "<h1>$data_key:</h1> $data_value<br/>"; 1 Link to comment Share on other sites More sharing options...
adrian Posted November 27, 2013 Share Posted November 27, 2013 The same error also occurs when editing any admin pages, eg: Pages > Home > Admin > Pages > Search Awesome enhancements though Soma! Link to comment Share on other sites More sharing options...
Martijn Geerts Posted November 27, 2013 Share Posted November 27, 2013 @adrian, yep same here, for now I just 'fixed' this local. 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