Gazley Posted March 23, 2016 Share Posted March 23, 2016 @berhard - In the module when a RuntimeMarkupField runs inside a repeater, $page references the page that the repeater is on, not the repeater iteration instance. Link to comment Share on other sites More sharing options...
kongondo Posted March 23, 2016 Author Share Posted March 23, 2016 (edited) @Gazley, we can probably get around that. The main issue for me is how to reference the current repeater matrix item, basically the 'neighbouring' page field. In normal repeaters, fields are grouped (using their modified field-names) like so in one repeater item: email_repeater3157 page_field_name_repeater3157 runtime_markup_field_name3157 eq(0) email_repeater3179 page_field_name_repeater3179 runtime_markup_field_name3179 eq(1) What is needed is a way to get the eq(n) of the repeater or the 3157 (the ID of the page where the fields actually live - hidden repeater page in admin) Btw, $page->getForPage() won't cut it because this is the current page that has all those repeater items, in other words the $page in your RuntimeMarkup field. It seems the $page variable will do it? I don't even have a PW 3.x install ( ) which RepeaterMatrix requires to test this. Time, oh time... Edited March 23, 2016 by kongondo Link to comment Share on other sites More sharing options...
Macrura Posted May 13, 2016 Share Posted May 13, 2016 I added this small tweak to the FieldType, which allows me to use the Ace extended for my code editing.. if(wire('modules')->get('InputfieldAceExtended')) { $f = $this->modules->get('InputfieldAceExtended'); $f->mode = "php"; $f->theme = "monokai"; } else { $f = $this->modules->get('InputfieldTextarea'); } 4 Link to comment Share on other sites More sharing options...
kongondo Posted May 15, 2016 Author Share Posted May 15, 2016 Thanks Macrura...had let this slip under the radar. I'll add it as an option so users get to choose (and why wouldn't they?) if they want the textarea formatted with ace or not... 3 Link to comment Share on other sites More sharing options...
Macrura Posted May 16, 2016 Share Posted May 16, 2016 cool - yeah the only slight snafu is that if you want syntax highlighting, you have to add an opening php tag, so if i'm editing, i add that and then i delete it before saving; not sure though if there is any way around that, but haven't looked into it yet... Link to comment Share on other sites More sharing options...
bernhard Posted August 2, 2016 Share Posted August 2, 2016 Error: Call to undefined function wireRenderFile() (line 1 of .../FieldtypeRuntimeMarkup.module(98) : eval()'d code) This error message was shown because: you are logged in as a Superuser. Error has been logged. hi @kongondo i get this error after updating from pw 2.7.3 to pw 3.0.28 i have this in my custom php field: return wireRenderFile('_pageactions'); changing it to this: namespace Processwire; return wireRenderFile('_pageactions'); solves the problem. don't know how bullet-proof this is? maybe you could add this automatically when using namespaces? Link to comment Share on other sites More sharing options...
bernhard Posted September 16, 2016 Share Posted September 16, 2016 thanks again for this awesome field! if anybody needs excel-like tables this is easily possible like this (startingpoint): create a folder like /site/modules/HandsonTable copy https://github.com/handsontable/handsontable to this folder create a runtime field with this content: return wireRenderFile('../modules/HandsonTable/HandsonTable.php'); create your php-file /site/modules/HandsonTable/HandsonTable.php <?php $config->scripts->append($config->urls->siteModules . "HandsonTable/handsontable/dist/handsontable.full.js"); $config->scripts->append($config->urls->siteModules . "HandsonTable/handsontable/dist/moment/moment.js"); $config->scripts->append($config->urls->siteModules . "HandsonTable/handsontable/dist/pikaday/pikaday.js"); $config->styles->append($config->urls->siteModules . "HandsonTable/handsontable/dist/handsontable.full.css"); $config->styles->append($config->urls->siteModules . "HandsonTable/handsontable/dist/pikaday/pikaday.css"); ?> <div id="example"></div> <script> var data = [ ["", "Ford", "Volvo", "Toyota", "Honda"], ["2016", 10, 11, 12, 13], ["2017", 20, 11, 14, 13], ["2018", 30, 15, 12, 13] ]; var container = document.getElementById('example'); var hot = new Handsontable(container, { data: data, rowHeaders: true, colHeaders: true }); </script> moment and pickaday are not needed in this example and just as a showcase and reminder... It get's a little more complicated if you need storing/editing features but i need it only to show some data and my client can copy/paste data to excel/google drive sheets. 7 Link to comment Share on other sites More sharing options...
kongondo Posted November 30, 2016 Author Share Posted November 30, 2016 On 02/08/2016 at 11:31 AM, bernhard said: Error: Call to undefined function wireRenderFile() (line 1 of .../FieldtypeRuntimeMarkup.module(98) : eval()'d code) This error message was shown because: you are logged in as a Superuser. Error has been logged. hi @kongondo i get this error after updating from pw 2.7.3 to pw 3.0.28 i have this in my custom php field: return wireRenderFile('_pageactions'); changing it to this: namespace Processwire; return wireRenderFile('_pageactions'); solves the problem. don't know how bullet-proof this is? maybe you could add this automatically when using namespaces? I think it's easier if the dev themselves added the namespace. Even this one-liner would have worked for you... return ProcessWire\wireRenderFile('_pageactions'); Link to comment Share on other sites More sharing options...
kongondo Posted November 30, 2016 Author Share Posted November 30, 2016 Announcing that I've tested and can confirm that RuntimeMarkup is compatible with ProcessWire 2.8.x and ProcessWire 3.x 6 Link to comment Share on other sites More sharing options...
NikNak Posted December 14, 2016 Share Posted December 14, 2016 Hi Kongondo I have tried your master and dev versions with PW 3.0.36 and only get errors. Using your example code or something simple like 'return $page->parent->title;' gets the resulting error: Only strings and integers should be returned by your custom code! Check if your code is valid. 'return "hello";' works - but thats not so useful. I am running php 5.4.4 - might that be the issue? Kind regards Nik Link to comment Share on other sites More sharing options...
kongondo Posted December 14, 2016 Author Share Posted December 14, 2016 @NikNak. Works fine for me on PW 3.0.42 and PHP 5.4.22 . You need to ensure that your code returns a value. For wireRenderFile you will need to namespace the function in PW 3. Link to comment Share on other sites More sharing options...
NikNak Posted December 14, 2016 Share Posted December 14, 2016 Thanks. I tried the simplest of things, and namespaced it too, but couldnt get any output other than an error. Not to worry - I'll do more testing. Many thanks Nik Link to comment Share on other sites More sharing options...
adrian Posted December 14, 2016 Share Posted December 14, 2016 Any chance $page->parent->title; is returning an object due to multi-language? Link to comment Share on other sites More sharing options...
NikNak Posted December 14, 2016 Share Posted December 14, 2016 I've done some more testing. The module is working on normal pages whereas I was initially trying it out on $user pages, where it failed. Kind regards Nik Link to comment Share on other sites More sharing options...
kongondo Posted December 14, 2016 Author Share Posted December 14, 2016 return wire('users')->get(40)->name; @NikNak That will return guest. Only $page and $pages are locally scoped, as per the description right above the input for code. I guess that and the docs should perhaps be clearer. Link to comment Share on other sites More sharing options...
NikNak Posted December 15, 2016 Share Posted December 15, 2016 (edited) Thanks Kongondo - it's just me being thicker than usual - no problem with the description ;-) I assume this means that you cannot self reference fields on a $user page being edited. EDIT: The below solves what I was trying to do - thanks Kongondo $process = wire('process'); $u = $process->getPage(); $id = $u->id; return $id;// will return 40 for guest, 41 for superuser, etc... //return $process->className();// would return ProcessUser. Useful to know if you are using the field elsewhere and want to do different things based on context // return $u->email;// etc... Kind regards Nik Edited December 15, 2016 by NikNak Link to comment Share on other sites More sharing options...
elabx Posted January 11, 2017 Share Posted January 11, 2017 Just came here to say that this module works brilliantly! I have made an "email sender field" that uses the page's data to manage surveys for a certain product and right now I'm doing a "defaults selection for repeater field" for a repeatear field with page fields in it that will describe features of a product. It's really nice to just hack your way so fast with this! I use it with wireRenderFile() which rules because it lets me handle the markup nicely in a separate file in my preferred text editor. EDIT: Added "mail settings" screenshot. Jus realized my description text is all messed up engrish 4 Link to comment Share on other sites More sharing options...
kongondo Posted January 11, 2017 Author Share Posted January 11, 2017 It would be nice to see some screenshots, if at all possible 2 Link to comment Share on other sites More sharing options...
Sergio Posted January 25, 2017 Share Posted January 25, 2017 I tried this module today to output a video preview from a multilanguage field. Worked like a charm. See the screenshot. I created two fields, one for the default language (English) and one for Portuguese. Here's the code for both, if someone's interested: English field: return '<iframe src="https://www.youtube.com/embed/'.$page->youtube_id.'/?showinfo=0&iv_load_policy=3&controls=1" frameborder="0" allowfullscreen width="100%"></iframe>'; Portuguese field: //1021 is the 'portuguese' language page id $youtube_id = $page->youtube_id->getLanguageValue(1021); return '<iframe src="https://www.youtube.com/embed/'.$youtube_id.'/?showinfo=0&iv_load_policy=3&controls=1" frameborder="0" allowfullscreen width="100%"></iframe>'; Thanks @kongondo for this great module! 8 Link to comment Share on other sites More sharing options...
kongondo Posted January 25, 2017 Author Share Posted January 25, 2017 @Sérgio. Excellent! Thanks for sharing! 1 Link to comment Share on other sites More sharing options...
Juergen Posted February 2, 2017 Share Posted February 2, 2017 Hi there, I use this field type with translateable strings and it works. My problem is I cannot find where I could translate it in the backend. Example: Fieldname: calendarbox PHP code inside this field: The output in the backend works. Maybe I have to create the translateable file manually. Can anyone help me out? Best regards Link to comment Share on other sites More sharing options...
bernhard Posted February 2, 2017 Share Posted February 2, 2017 i guess you could use wireRenderFile, then it should show up in the backend. 2 Link to comment Share on other sites More sharing options...
kongondo Posted February 2, 2017 Author Share Posted February 2, 2017 Just a quick by the way, I recently updated the first post in this thread to state that the wireRenderFile() approach is the recommended way to use this module. I'll update the README too when I get the time. 4 Link to comment Share on other sites More sharing options...
bernhard Posted February 3, 2017 Share Posted February 3, 2017 you could also put everything in one file to have all translations aggregated in one page in the admin custom code: return wireRenderFile('fieldmarkup', array('field' => 'calendarbox')); fieldmarkup.php <?php switch ($field) { case 'calendarbox': $out = '<div>...</div>'; $out .= '<p>...</p>'; echo $out; break; } i guess for easy fields that would be better than having a file for each field... 4 Link to comment Share on other sites More sharing options...
Juergen Posted February 3, 2017 Share Posted February 3, 2017 Thanks @bernhard your solution works pretty well. 2 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