Jump to content
bernhard

RockMarkup2 - Inputfield to easily include any PHP/HTML/JS/CSS in the PW Admin

Recommended Posts

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

  • Like 12

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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!

  • Like 1

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

@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.

Share this post


Link to post
Share on other sites
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 ^^

Share this post


Link to post
Share on other sites

The point is that we have Fieldtype modules for that...

Share this post


Link to post
Share on other sites

Just added support for really easy translation of all aspects of your field 😎

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Pushed a fix for RockMarkup2 and related modules (RockTabulator) not working in subdir installations. Thx for finding that @dragan

  • Like 2

Share this post


Link to post
Share on other sites

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

  • Like 3

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...