Jump to content

Module: RuntimeMarkup Fieldtype & Inputfield


kongondo

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
Link to comment
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
}

 

Link to comment
Share on other sites

  • 1 month later...

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?

Link to comment
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
Link to comment
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?

Link to comment
Share on other sites

  • 2 weeks later...
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.

Link to comment
Share on other sites

  • 2 months later...
  • 2 weeks later...

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

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 month later...

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

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

  • 3 weeks later...

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 

:( 

Link to comment
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)

 

Link to comment
Share on other sites

  • 2 weeks later...

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!

Link to comment
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!

Link to comment
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.

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

  • 1 month later...

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
×
×
  • Create New...