adrian Posted July 31, 2015 Share Posted July 31, 2015 Would anyone else like to see the ability to make use of PW variables to build up dynamic descriptions and notes for fields? This is a very simplistic example and not that useful, but I do have some use cases where the ability to do something like this would be very handy: $f->description = __('Please make sure you fill out this field based on the content of the {page.parent.title} summary field.'); As I said - a bad example, but I think this could be a powerful addition in some scenarios. 6 Link to comment Share on other sites More sharing options...
bernhard Posted August 2, 2015 Share Posted August 2, 2015 sometimes i wished the descriptions support html for linking to something. if it supported html+php we could combine both: eg ...based on the content of <a href="<?php echo $page->parent->url; ?>"><?php echo $page->parent->title; ?></a>'s summary field... but i have absolutely no idea how much effort/overhead that would be 1 Link to comment Share on other sites More sharing options...
LostKobrakai Posted August 2, 2015 Share Posted August 2, 2015 You can link by using markdown [my-link](http://processwire.com). But be aware, it's not a full-blown markdown parser, which does this job, so other syntax might or might not work. About the overhead. Ryan did mention somewhere, when someone asked about better markdown support, that that would be a performance hit, so I'm not sure if it's wise to back notes/descriptions with features. It's really one of those "called everywhere and often" things. 2 Link to comment Share on other sites More sharing options...
bernhard Posted August 2, 2015 Share Posted August 2, 2015 thank you lostkobrakai, didn't know that possibility Link to comment Share on other sites More sharing options...
LostKobrakai Posted August 2, 2015 Share Posted August 2, 2015 Even the core does use links in notes, especially for the more documentation-needing features like for example the urlSegment whitelisting. So there needed to be a way to create those. 1 Link to comment Share on other sites More sharing options...
bernhard Posted September 3, 2015 Share Posted September 3, 2015 this new module could maybe do the job in most cases: https://processwire.com/talk/topic/10804-module-runtimemarkup-fieldtype-inputfield/ 2 Link to comment Share on other sites More sharing options...
bernhard Posted October 18, 2015 Share Posted October 18, 2015 for reference: TagReplacer can do it https://processwire.com/talk/topic/11208-inputfieldtagreplacer/ 1 Link to comment Share on other sites More sharing options...
adrian Posted October 19, 2015 Author Share Posted October 19, 2015 for reference: TagReplacer can do it https://processwire.com/talk/topic/11208-inputfieldtagreplacer/ Thanks Bernhard - your module looks great. I also put together something for this task myself. I just added it to my gists: https://gist.github.com/adrianbj/5dc1c00f1617b2639319 It allows you to do something like this in a field's description or notes text: [Click Here]({page.parent.url}) This will give you a "Click Here" link to the parent page. Of course you can also use "name", "title", and any other field from the current page, or it's parent, or parent above that. I haven't needed it yet, but I was thinking it might be nice to be able to do {page[xxxx].parent.title} so you can specify the ID of the page you want to reference. Maybe at some point I'll add that, or if anyone out there would make use of it, let me know and I'll add it sooner. While not as flexible as your module, it requires no setup so it really depends on what you need. 3 Link to comment Share on other sites More sharing options...
adrian Posted October 26, 2015 Author Share Posted October 26, 2015 Just made some changes to the gist. It now uses square brackets [ ] and not curly braces {} It now limits replacements to just description and notes paragraphs You can now define str_replace $search and $replace like this. In this example I needed the dashes in $page->name replaced with underscores, but you can use however you want. [page.name.(-|_)] Not sure that my code/regexes are the cleanest - I needed this is a bit of a rush, but it seems to work well and I am really finding this very useful in many of my fields. I'd definitely be keen on hearing feedback from anyone else who tries it and if you think it warrants being included in the modules directory. I think I will likely use it on most new sites, but maybe it's just me Link to comment Share on other sites More sharing options...
Martijn Geerts Posted October 26, 2015 Share Posted October 26, 2015 Ryan should consider this to be included in the core I think. 1 Link to comment Share on other sites More sharing options...
adrian Posted October 26, 2015 Author Share Posted October 26, 2015 Ryan should consider this to be included in the core I think. I completely agree - I think it would be more targeted and efficient that way, although I am guessing he probably won't want to bother with the str_replace option I just introduced. My need for that is probably an edge case though Link to comment Share on other sites More sharing options...
Martijn Geerts Posted October 26, 2015 Share Posted October 26, 2015 I agree and we should not need a hook for that. Link to comment Share on other sites More sharing options...
Martijn Geerts Posted October 26, 2015 Share Posted October 26, 2015 I would also love to see the ability of using unordered and ordered lists. 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