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

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 kixe
      Email Verification
      This module provides functions to validate email adresses and hosts. The module generates a textfile for blacklisted mailhosts (trashmail), which will be always up to date.
      Download
      https://modules.processwire.com/modules/email-verification/
      API
      // get module $mailcheck = $modules->get('EmailVerification'); // return bool/ string - automatted update of blacklist file $mailcheck->blacklisted(email|domain) // return bool - validate a top level domain, checks against IANA list $mailcheck->validTLD(tld) // return array of punycoded TLDs - cyclic updated, data pulled from IANA $mailcheck->getTLDs(cycle=2592000) // return bool - checks syntax converts to punycode $mailcheck->validDomainName(domain); // return bool - checks punycode encoded syntax $mailcheck->validHostName(host); // return bool - checks syntax and accessibility $mailcheck->validHost(email|domain) // add a single value to blacklist $mailcheck->addToBlacklist(email|domain) USAGE
      $mailcheck = $modules->get('EmailCheck'); $email = 'susi@trashmail.com'; if($mailcheck->blacklisted($email)) echo 'Email Provider not allowed'; if(!$mailcheck->validHost($email)) echo 'Mailhost not available'; Example blacklist file:  blacklist.txt
       
    • By teppo
      Code Blocks Textformatter is a tiny Textformatter module I cooked up to add support for code blocks to text/textarea/RTE fields on some of the sites I work with. Unlike a full-blown Markdown Textformatter – which is something that we already have in the core – this module simply adds support for fenced and inline code blocks.
      The syntax is based on the GitHub code block documentation, so please refer to that for additional instructions. The README at GitHub also includes some basic examples. As with any Textformatter, in order to enable this one, install it and enable it via field settings. Note that there's no syntax highlighting built in (at least for the time being), so use a tool of your choice for that – personally I prefer Prism.js.
      Since this module doesn't use a Markdown tool behind the scenes, but rather some home baked regular expressions, there's always the possibility that I've missed something – but please let me know if you use this module and run into any issues. On the other hand this module should be relatively fast and unobtrusive, as there are no unnecessary bits of code to run 
      GitHub repository: https://github.com/teppokoivula/TextformatterCodeBlocks Modules directory: http://modules.processwire.com/modules/textformatter-code-blocks/
    • By theo
      Here is my first processwire module (beta).
      https://github.com/theo222/ImagePickerField
      A lot of "first times". First time Github, Markdown and of course PW Modules.
      So be gentle please.
      I hope it works.

    • By horst
      Image Animated GIF  v 2.0.2
       
      Module for PW 2.5 stable or newer, but is obsolete for PW Versions greater then 3.0.89 (... read more ...)
       
      This module helps with resizing and cropping of animated GIFs when using the GD-Library.
      The GD-Library does not support this.


      This module is completely based upon the fantastic work of

         László Zsidi (http://www.gifs.hu/, builts the initial classes)
         xurei (https://github.com/xurei/GIFDecoder_optimized, enhanced the classes)


      I have ported it to a PW module and it works with core imagefields, together with Pia and with CropImagefields that uses the new naming scheme since PW 2.5.
       
      ------------------------------------------------------------------------------------------------------------------------------------------
      read more in this post about the rewrite from version 1.0.0 to version 2.0.0
      ------------------------------------------------------------------------------------------------------------------------------------------
      You can find it in the modules directory: https://modules.processwire.com/modules/image-animated-gif/
      and on Github: https://github.com/horst-n/ImageAnimatedGif
      ------
      A preview can be found here