bernhard Posted October 17, 2015 Posted October 17, 2015 What it does: you can easily define replacement-tags in your fields (also descriptions) like this: [demo] => '<span class="demo">some demo markup</span>', [demo2] => '<span class="demo">some other demo markup</span>', [demo3] => '<span class="demo">one more demo markup with a <a href="#" class="pw-modal">modal link</a>!</span>', Screenshot: Why? today i had to (to be more precise: i wanted to) have a link in one of my field-descriptions that opened a modal to a list of icons... basically i just wanted to add a "pw-modal" class to the link what is not possible through markdown [link](http://example.com) i ended up with the following little module: // removed - please see the code on github its also on github: https://github.com/BernhardBaumrock/ProcessWireModules/blob/master/InputfieldTagReplacer.module i know but didn't use RuntimeMarkup because i wanted the link in the description not in a separate field! Questions: would it be possible to get the currently edited $page somehow? the $page object i get now is the admin page with the according process.it would be nice to be able to do things like $page->parent or the like... would there be another method to hook into that would be more efficient or better in any other way? how can i debug the $event object?i tried var_dump($event); die(); but that showed nothingvar_dump($event->return); die(); shows the form/field markup would there have been an easier way to achieve this? 4
kongondo Posted October 17, 2015 Posted October 17, 2015 Questions: would it be possible to get the currently edited $page somehow? the $page object i get now is the admin page with the according process.it would be nice to be able to do things like $page->parent or the like... $process = $this->wire('process'); if($process && $process->className() == 'ProcessPageEdit') $page = $process->getPage(); 3
Macrura Posted March 11, 2017 Posted March 11, 2017 if found this module to be useful for enriching the field descriptions, in the most recent case i needed to output the page ID, and the full url to the frontend page, and did it by using this; not sure if there is any other easier way of parsing tokens in the field descriptions at this stage, this was the only way i could figure out how to do it.
bernhard Posted March 11, 2017 Author Posted March 11, 2017 hi @Macrura, glad you like it, but to be honest i don't think any more that this module has a big value now as i've done a lot more modules on my own, i would just put a simple hook into ready.php and hardcode the description. or get the description from a field in a custom settings page or the like... 1
Macrura Posted March 12, 2017 Posted March 12, 2017 right - yeah, i'm not actually using the module, just the function which is in my generic site utilities module; using this replacer method (as opposed to hardcode) though allows you to have a few frequently used replacements in a lot of fields, e.g: page.id page.httpUrl etc.. 1
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