bernhard Posted July 19, 2019 Share Posted July 19, 2019 Please don't use this module any more. I think in the end it just adds more complexity (and dependencies) than benefits. See this tutorial how simple it is to create a custom runtime-only Inputfield: WHY? I've started building this module because the existing solutions by @kongondo and @kixe (https://modules.processwire.com/modules/fieldtype-runtime-markup/ and https://github.com/kixe/FieldtypeMarkup) did not exactly fit my needs. Actually this module is aimed to be a base module that can easily be extended by other modules. It takes care of the heavy lifting that has to be done when working with custom fieldtypes in ProcessWire (injecting scripts and styles, handling JS events, doing translations). See RockTabulator as an example. I'm quite sure more will follow (eg ChartJS)... WHAT? This module helps you injecting ANY php/html/js/css into any PW backend form (either on a page or in custom process modules). It also comes with a sandbox process module that helps you setup your fields and provides handy shortcuts that integrate with TracyDebugger and your IDE: WHERE ...to get it? At the moment the module is released as early alpha and available only on github: https://github.com/BernhardBaumrock/RockMarkup2 If you have any questions or ideas please let me know ? PS: This module shows how easy it is to extend this module for your very own needs. All you need to do is providing the module's info arrays and then overwrite any methods that you have to modify (eg the InputField's render() method): https://github.com/BernhardBaumrock/RockMarkupExtensionExample 12 Link to comment Share on other sites More sharing options...
dotnetic Posted July 23, 2019 Share Posted July 23, 2019 This is so awesome. Thank you @bernhard. Testing some things right now 1 Link to comment Share on other sites More sharing options...
dotnetic Posted July 23, 2019 Share Posted July 23, 2019 Can I save a value for the custom markup field and output it's value on the edit page? Right now I have a calculation field whose value is calculated via JavaScript (depending on other fields). But now on page save, I want to save the calculated value to the field, so I can possibly output it in a Lister Pro column. Is this possible or can you make it possible? I think this would be a cool addition, because you can use the value on pages/listers, where the other dependend fields are not available. Link to comment Share on other sites More sharing options...
bernhard Posted July 23, 2019 Author Share Posted July 23, 2019 Well... the proper way would be to develop a fieldtype for that. Hacking this together with RockMarkup should be quite easy though: Just add a hidden inputfield for that purpose and populate it via JS whenever you update the value of the RockMarkup field. But you need to be careful with that approach because the value transmitted can be manipulated easily via browser devtools if you don't do server side validation! 1 Link to comment Share on other sites More sharing options...
bernhard Posted July 29, 2019 Author Share Posted July 29, 2019 @jens.martsch any experiences to share with us so far? Link to comment Share on other sites More sharing options...
dragan Posted July 29, 2019 Share Posted July 29, 2019 On 7/23/2019 at 4:59 PM, jens.martsch said: Right now I have a calculation field whose value is calculated via JavaScript (depending on other fields). But now on page save, I want to save the calculated value to the field I guess this should be possible with a good old hook, too. Link to comment Share on other sites More sharing options...
dotnetic Posted July 30, 2019 Share Posted July 30, 2019 @dragan Sure, this is possible with a hook and thats how I do it now (without using RockMarkup). @bernhard It would be ideal, if RockMarkup could create an additional field on demand for saving the value (but then we should be able to select the options, like an integer with max 10 digits, for this hidden field), or if you could connect/link RockMarkup to an existing field, which has it's type and validation defined, because it is a regular ProcessWire field. So the result of a calculation would be saved in this field. Right now I just experimented with RockMarkup and it worked as expected, but saving the value is stopping me from using it right now for this purpose. But I think I will have other uses for it in the future. Link to comment Share on other sites More sharing options...
bernhard Posted July 30, 2019 Author Share Posted July 30, 2019 18 minutes ago, jens.martsch said: It would be ideal, if RockMarkup could create an additional field on demand for saving the value (but then we should be able to select the options, like an integer with max 10 digits, for this hidden field), or if you could connect/link RockMarkup to an existing field, which has it's type and validation defined, because it is a regular ProcessWire field. So the result of a calculation would be saved in this field. I have to think about that... It was not built for such tasks, but it might be a good addition. We'd have to think about a new name for the module then ^^ Link to comment Share on other sites More sharing options...
dotnetic Posted July 30, 2019 Share Posted July 30, 2019 Yes, I thought about an addition. Right now it's a general purpose module, and a calculation result field would be an enhancement. Besides of that, I really like RockMarkup Link to comment Share on other sites More sharing options...
bernhard Posted July 30, 2019 Author Share Posted July 30, 2019 The point is that we have Fieldtype modules for that... Link to comment Share on other sites More sharing options...
bernhard Posted September 5, 2019 Author Share Posted September 5, 2019 Just added support for really easy translation of all aspects of your field ? 1 1 Link to comment Share on other sites More sharing options...
bernhard Posted September 8, 2019 Author Share Posted September 8, 2019 Pushed a fix for RockMarkup2 and related modules (RockTabulator) not working in subdir installations. Thx for finding that @dragan 2 Link to comment Share on other sites More sharing options...
bernhard Posted September 9, 2019 Author Share Posted September 9, 2019 Pushed a new version yesterday that fixes the issue that .ready and .hooks files might be publicly readable thanks to @jens.martsch and @teppo Please update the module to the latest master version and rename all your .ready and .hooks files to .ready.php and .hooks.php! https://github.com/BernhardBaumrock/RockMarkup2/commit/e9c0bcf43d84078e36ee9e219d19b911c180e168 3 Link to comment Share on other sites More sharing options...
jploch Posted September 27, 2019 Share Posted September 27, 2019 this looks very promising! Can you give an example on how to render a page reference field with this module. I tried it with this code in the the markup field: <?php // Render for frontend and Backend if($page->block_page) echo "{$page->block_page->render()}"; ?> My template has the block_page as well as the markup field. Link to comment Share on other sites More sharing options...
bernhard Posted September 28, 2019 Author Share Posted September 28, 2019 if($page->block_page) echo "{$page->block_page->title}"; Link to comment Share on other sites More sharing options...
bernhard Posted October 17, 2019 Author Share Posted October 17, 2019 Just pushed an update to make the currently edited page available to the rendered PHP file: // before $editPage = $pages->get($input->get('id', 'int')); echo $editPage->path; // now echo $editPage->path; thx to @psy for the idea 1 Link to comment Share on other sites More sharing options...
psy Posted June 9, 2020 Share Posted June 9, 2020 I realise this module is deprecated but it is in use on a site I'm working on. I needed to add a RM2 field into a repeater and it didn't work due to the unique nature of repeaters. A little hack to RM2 Inputfield module solved 2 problems at once. The Inputfield works in repeaters AND the repeater item ID is accessible in the parent page via the $session var. <?php /** * Set the field content from the file with the same name */ public function ___getContent() { $out = ''; // get file $name = $this->name; /****** hack - breaks on repeater fields ******/ if (strpos($name,'_repeater') !== false) { // it's in a repeater field $ary = explode('_repeater', $name); $name = $ary[0]; // save the repeater item ID with the original fieldname as the key for future use wire('session')->set($name, $ary[1]); } /****** end of hack - breaks on repeater fields ******/ $file = $this->main()->getFile($name); if(!$file) return "No file found for field $name"; // if a value was set return it if($this->value) $out = $this->value; else { // otherwise try to render the file try { // get page object $page = $this->page; if($this->process == 'ProcessPageEdit') { $page = $this->process->getPage(); } // get markup $out = $this->files->render($file->path, [ 'inputfield' => $this, 'rm' => $this->rm, ], [ 'allowedPaths' => [$file->path], ]); } catch (\Throwable $th) { $out = $th->getMessage(); } } return $out; } It's a bit rough but it works for me and maybe this tip can help others working with repeater fields. 1 Link to comment Share on other sites More sharing options...
psy Posted June 9, 2020 Share Posted June 9, 2020 Thanks for liking @bernhard Another tip... not only doesn't it work, but who wants multiple CSS files for a repeater? In this scenario, the page template had another RM2 field - simple field on the main template. All CSS for the repeater RM2 field went into the other RM2 field's CSS file, not the repeater field's CSS. I'm sure there are other ways to get the RM2-in-a-repeater's CSS to work - just needs thinking outside the square ? 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