kongondo

Module: RuntimeMarkup Fieldtype & Inputfield

Recommended Posts

i have one type of button that submits via ajax so does all of the processing without opening a new window; some of my more primitive versions just open a new window to run the action...

  • Like 1

Share this post


Link to post
Share on other sites

yeah, i also went with ajax for now. but it's strange that it worked before... and it seems more complicated now than necessary and with pw that's usually the feeling when something is wrong :) 

Share this post


Link to post
Share on other sites
1 hour ago, bernhard said:

so what changed since your example here? and how could i detect clicks on buttons?

 

Nothing has changed. It works just fine. If you use $input->post in your 'my-file.php', it will work as expected. If used directly in 'Copy Paste' code, it won't.

 

1 hour ago, bernhard said:

and how could i detect clicks on buttons?

For buttons, that would have to be JS from what I see. E.g., dump this after if($copy) {} in my example in the quoted post:

echo '<pre>';
print_r($input->post);
echo '</pre>';
exit;

You will see all the POST values (but no 'submit_save' there; I guess the post is submitted in some other way) including the 'Create Copy' button, body fields, etc. So, to detect submit button, you could do the following in your 'my-file.php':

if($input->post->title) {
// blah blah
}

 

Share this post


Link to post
Share on other sites

Hi Kongondo

Thanks for this great module! I use it on several templates and in the frontend everything works fine. I use it mainly to concatenate text… Now i have a firstname and lastname field on the user that i combine into a single runtimemarkup field "fullname" – it displays correctly in the frontend but the backend profile page does not display the computed value: return $page->firstname." ".$page->lastname;

Any ideas on why that could happen?

Share this post


Link to post
Share on other sites

@noelboss - have you tried using TracyDebugger yet? You could get that going and then troubleshoot the contents of the $page in the profile editor; you may also be able to see warnings and errors when using Tracy. Using it is pretty much required if you are doing any serious dev work in the backend.

  • Like 3

Share this post


Link to post
Share on other sites
7 hours ago, noelboss said:

Hi Kongondo

Thanks for this great module! I use it on several templates and in the frontend everything works fine. I use it mainly to concatenate text… Now i have a firstname and lastname field on the user that i combine into a single runtimemarkup field "fullname" – it displays correctly in the frontend but the backend profile page does not display the computed value: return $page->firstname." ".$page->lastname;

Any ideas on why that could happen?

Welcome to the forums. Glad you find the module useful.

Regarding your question, it's hard to tell without seeing some code. Are you using the field directly in the ProcessWire user template or you have some other pseudo page for users?

Share this post


Link to post
Share on other sites
On 06/09/2017 at 4:57 AM, kongondo said:

Are you using the field directly in the ProcessWire user template or you have some other pseudo page for users?

I'm guessing he is talking about the profile edit interface (ProcessProfile). There are a couple of places where the module assumes/requires ProcessPageEdit.

Share this post


Link to post
Share on other sites

Hi all. 

I am intending to ONLY support ProcessWire 3.x starting from the next version of this module. Please have a read here and let me know what you think. Thanks.

Share this post


Link to post
Share on other sites

Is it possible to use field collapsed status with this - since the module itself doesn't have a value that can trigger 'populated' status (?)... I'm using a lot of these on a page , but need keep them all open...

Share this post


Link to post
Share on other sites
On 01/12/2017 at 3:35 PM, Macrura said:

but need keep them all open...

Aren't they all staying open?

 

On 01/12/2017 at 3:35 PM, Macrura said:

Is it possible to use field collapsed status

Will investigate. 

Share this post


Link to post
Share on other sites

oops, mis-typed, i meant keep closed when blank; they do stay open if set to open.

I guess maybe i need to make sure my code returns empty for this to work; will check again.

Share this post


Link to post
Share on other sites

Can't believe I discovered this awesome module only recently... I mean, it's over 2 years old now already :o

Here's another use-case: 

 

  • Like 3

Share this post


Link to post
Share on other sites

I'm getting a strange glitch with this.  I'm on PW 3.0.9.  If I put my code directly into the field it works fine, but if I try to use an external file using return ProcessWire\wireRenderFile('runtime.php');  the page is always returned as page id 10, not the the page I'm on.   

Not tragic as I can put the code directly in the field but would be better to have it external if possible.

Thanks!

Heather

Share this post


Link to post
Share on other sites

Hi @hezmann

33 minutes ago, hezmann said:

I'm getting a strange glitch with this.  I'm on PW 3.0.9.  If I put my code directly into the field it works fine, but if I try to use an external file using return ProcessWire\wireRenderFile('runtime.php');  the page is always returned as page id 10, not the the page I'm on.   

That's because the code (in the field) is locally scoped so that $page refers to the page you are editing. However, if using wireRenderFile(), you need to get the page being edited yourself. When editing a page, the page (named) edit is what ProcessWire assigns to $page. The page edit has the id 10. So, what you need is code like below to get the page being edited:

$currentPage = '';
$process = wire('process'); 
if($process && $process->className() == 'ProcessPageEdit') $currentPage = $process->getPage();
if(!$currentPage) return;
// if you get here $currentPage is the page being edited

More in this post. Sorry, this should be in the docs. I will update the docs at some point (when I get the time).

Hope this helps.

Edited by kongondo
  • Like 1

Share this post


Link to post
Share on other sites

Is it possible to use this field on a custom user template ? 

I'm trying but if I just put "return $page->id" in the field I have an error  "Undefined variable: page" ...
If I try with a external file, I have $page but It's the "users" parent page and not the user I'm editing 

:( 

Share this post


Link to post
Share on other sites
8 hours ago, Sonia Margollé said:

Is it possible to use this field on a custom user template ? 

I haven't tried, sorry. I'll check when I get a bit of time. I've never used the custom user template feature so will have to do a bit of reading first. Have you tried with wire('page')? This post might also be handy (i.e. establishing process context)

 

Share this post


Link to post
Share on other sites

Hey @kongondo - would you consider adding this to the module please?

$f = $this->modules->isInstalled('InputfieldAceExtended') ? $this->modules->get('InputfieldAceExtended') : $this->modules->get('InputfieldTextarea');

in the ___getConfigInputfields method?

Thanks!

Share this post


Link to post
Share on other sites

It would also be good to have:

$f->rows = 20;

or even make it configurable.

One other thing - because InputfieldAceExtended is not in inline mode, you need <?php to force code highlighting, but your module doesn't allow this. Would you mind stripping out any <?php that is added so that this works? This should do it:

$str = eval(str_replace('<?php', '', $this->runtimeFields));
$str = eval(str_replace('<?php', '', $field->runtimeFields));

One each for FieldtypeRuntimMarkup and InputfieldRuntimeMarkup.

Thanks!

Share this post


Link to post
Share on other sites

;)

But still I think using your IDE is the best option for larger code snippets... No need for ACE then. I'm still unsing my render replacement hook

 

Share this post


Link to post
Share on other sites
2 minutes ago, bernhard said:

But still I think using your IDE is the best option for larger code snippets... No need for ACE then

I still think it's nice to have even for short snippets, but maybe that's just me? If nothing else it lets you actually use the tab key to indent which you can't do in a normal textarea.

Share this post


Link to post
Share on other sites

Sure it's nice :) I think this was lost in translation :) I meant if you are using the IDE you don't need ACE, but of course it's nice to have it in the backend. The Tracy Console is a perfect example. I'm using ACE myself in several projects

  • Like 1

Share this post


Link to post
Share on other sites

Sorry @kongondo - me again :)

I am noticing that the renderMarkup() method is called many times on the currently edited page and it's also called on page reference fields on the page being edited. This makes for a lot of calls to this method that don't seem necessary as far as I can tell. Do you think this can be improved?

As an example, I put: bd($page->id); at the top of that method and saw this:

image.thumb.png.37bb806099db03174abb5d1ffeea5e9a.png

I am currently editing page 1100, but there are a few page reference fields which are also showing up in that list.

Thanks for taking a look!

 

 

  • Like 2

Share this post


Link to post
Share on other sites

Thanks @adrian. I'll look at these when I upgrade the module to PW3.x-support only. I have no ETA though, I'm afraid.

  • Like 1

Share this post


Link to post
Share on other sites

Hey @kongondo - seems like it's all because of the ___wakeupValue and ___sleepValue methods. Is there any reason they can't just return true, rather than returning $this->renderMarkup($page, $field); ?

Thanks!

  • Like 1

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/
    • By horst
      Croppable Image 3
      for PW 3.0.20+
      Module Version 1.1.16
      Sponsored by http://dreikon.de/, many thanks Timo & Niko!
      You can get it in the modules directory!
      Please refer to the readme on github for instructions.
       
      -------------------------------------------------------------------------
       
      Updating from prior versions:
       
      Updating from Croppable Image 3 with versions prior to 1.1.7, please do this as a one time step:
      In the PW Admin, go to side -> modules -> new, use "install via ClassName" and use CroppableImage3 for the Module Class Name. This will update your existing CroppableImage3 module sub directory, even if it is called a new install. After that, the module will be recogniced by the PW updater module, what makes it a lot easier on further updates.
      -------------------------------------------------------------------------
       
      For updating from the legacy Thumbnail / CropImage to CroppableImage3 read on here.
       
      -------------------------------------------------------------------------
       
    • By MoritzLost
      UPDATE: I have published a stable version of this module!
      Discussion thread:
      Github: https://github.com/MoritzLost/TextformatterPageTitleLinks
      ---
      Hello there,
      I'm working on a tiny textformatter module that searches the text for titles of other pages on your site and creates hyperlinks to them. I'm not sure if something like this exists already, but I haven't found anything in the module directory, so I wrote my own solution 🙂
      It's not properly tested yet and is still missing some functionality I would like to implement, so at the moment it should be considered in BETA. Features include limiting the pages that will get searched by template, and adding a custom CSS class to the generated hyperlinks. As I'm writing this I noticed that it will probably include unpublished and hidden pages at the moment, so yeah ... it's still in development alright 😅
      You can download the module from Github:
      https://github.com/MoritzLost/TextformatterPageTitleLinks
      There's some more information in the readme as well.
      Anyway, let me know what you think! I'm happy about any feedback, possible improvements or ideas on how to improve the module. Cheers.
    • By blad
      Hi guys!
      I just uploaded a module to explore files based on elFinder. By default it will show the "Files" folder.
      Screenshots:

      Video:
       
      To do:
       More options To fix:
       The function of rotating or scaling an image fails  Image editors V 1.01 (view issue)
      Fixed the bug working with the Multi-Language support ( translation of folders ). Fixed the name of elfinder.en  Github:
      https://github.com/LuisSantiago/ProcessElFinder/
      I hope you like it.
    • By BitPoet
      I'm really in love with FormBuilder, but the one thing missing to match all my end users' expectations were repeatable field groups. Think repeaters, in ProcessWire terms. Our primary application of PW is our corporate intranet, so "lines" of fields are quite common in the forms I build. We have all kinds of request forms where the information for a varying number of colleagues needs to be entered (from meal order to flight booking request) and where it is simply impractical to send a form for each, and I don't want to clutter my forms with multiple instances of fields that may only get used ten percent of the time.
      That's why I started to build FormBuilderMultiplier (link to GitHub).
      What it does:
      Adds an option to make a regular Fieldgroup repeatable Lets you limit the number of instances of a Fieldgroup on the form Adds an "Add row" button the form that adds another instance of the Fieldgroup's fields Adds a counter suffix at the end of every affected field's label Stores the entered values just like regular fields Makes the entered values available in preview and email notifications Supports most text based fields, textareas and selects (really, I haven't had enough time to test all the available choices yet) What it doesn't do (yet):
      Support saving to ProcessWire pages (i.e. real Repeaters) I haven't tested all the validation stuff, Date/Time inputs etc. yet, but since I'm utterly swamped with other stuff at work, I didn't want to wait until I have it polished. Any feedback is welcome. There might also be some issues with different output frameworks that I haven't encountered yet. The forms I work with mostly use UIKit.
      Status:
      Still alpha, so test well before using it in the field.
      Known issues:
      When rows are added, the form's iframe needs to be resized, which isn't completely clean yet.
      How it works:
      The Fieldgroup settings are added through regular hooks, as is the logic that adds the necessary field copies for processing the form and displaying previews.
      "Multiplied" field instances are suffixed with _NUM, where NUM is an incremental integer starting from 1. So if you have add two fields named "surname" and "givenname" to a fieldgroup and check the "multiply" checkbox, the form will initially have "surname_1" and "givenname_1" field (I'm still considering changing that to make the risk to shoot oneself into the foot by having a regular "surname_1" field somewhere else in the form less likely).
      When a "row" is added, the first row is cloned through JS and the counter in the fields' IDs, names and "for" attributes as well as the counter in the label are incremented before appending the copies to the Fieldset container in the form.
      To keep backend and frontend in sync, a hidden field named [name of the fieldset]__multiplier_rows is added to the form. Both the backend and the frontend script use this to store and retrieve the number of "rows".
      ToDo:
      Naturally, add the option to store the data in real repeaters when saving to pages. Do a lot of testing (and likely fixing). Make a few things (like the "Add row" button label etc.) configurable in field(set) context. Add a smooth API to retrieve the multiplied values as WireArrays. The mandatory moving screenshot: