MarkE
Members-
Posts
1,051 -
Joined
-
Last visited
-
Days Won
12
Everything posted by MarkE
-
Sorry, the answer to that is a bit complicated. I am not using the RM module to refer to the css file. It is linked in the PHP script. This detects whether the host site (site 2) is on a permitted list stored in the availability page in site 1 which contains the RM field. There are two such lists - one for non-PW sites and one for PW sites. The script grants the permissions required for it to access the templates/fields it needs and also passes the css as an in-line style. So I just had to make sure that the path was correct for the css (and js) like this: } elseif (in_array($headers['Host'], $permittedPW)) { $currentPath = $files->currentPath(); $calendarUser = $config->admin_site->users->get("name=calendar"); // calendar has role that only allows access to the availability page $config->admin_site->users->setCurrentUser($calendarUser); $cssText = file_get_contents($currentPath . 'styles/Availability.less.css'); if ($cssText) { $out .= '<style>' . $cssText . '</style>'; } $js = file_get_contents($currentPath . 'scripts/Availability.js'); if ($js) { $out .= '<script>' . $js . '</script>'; } } else { Maybe a bit hacky - but works ? It makes no difference - I get the error from site 1 if the RM module is not in site 2, or from site 2 if it is in both.
-
I fixed the css and it all works. I'm getting PHP notice from Tracy: PHP Notice: Object of class ProcessWire\DefaultPage could not be converted to int in ...\FieldtypeRuntimeMarkup.module:536 That line is $root = $mode == 2... in public function getDefaultPath($defaultPath, $mode=1) { $config = $this->wire('config'); $root = $mode == 2 ? $config->urls : $config->paths; if(2 === (int) $defaultPath) $defaultPath = $root->siteModules;// /site/modules/ else $defaultPath = $root->templates;// /site/templates/ return $defaultPath; } Doing a bd(), it would seem that $mode is the host page for the RM field, not an integer! Not causing a problem in my case, since $root = $config->paths is OK, but odd. I wasn't getting this error with the previous version (or my hacked copy).
-
Many thanks for that @kongondo. Any reason for that? I need it on both sites (a really useful module ? ). A quick test seems to indicate that it works OK if installed on one or both sites, but I will investigate more. As you say, my css isn't working properly after this but hopefully I can fix that. I'll spend some time with it and let you know of any issues. Thanks again!
-
Here's what I have: public function getDefaultPath($defaultPath, $page, $mode=1) { bd($page, 'page'); $config = $this->wire('config'); if ($mode == 2) { $rootUrl = preg_replace('/assets.*/m','',$page->filesUrl()); $config->setUrl('templates_RM', $rootUrl . 'templates/'); $config->setUrl('siteModules_RM', $rootUrl . 'modules/'); $root = $config->urls; } else { $rootPath = preg_replace('/assets.*/m', '', $page->filesPath()); $config->setPath('templates_RM', $rootPath . 'templates/'); $config->setPath('siteModules_RM', $rootPath . 'modules/'); $root = $config->paths; } if(2 === (int) $defaultPath) $defaultPath = $root->siteModules_RM;// /site/modules/ else $defaultPath = $root->templates_RM;// /site/templates/ return $defaultPath; }
-
No. I can't use $site->config->paths->site inside your module, just $config->paths->site. But if I hooked it there would be more flexibility. Sorry, I missed that. I did originally add the domain parameter, but I got an "overloaded" error message, so I removed it. Here's the code: $config->admin_site = new ProcessWire($config->paths->root . 'site/'); Using $config means it's available everywhere in site 2 (which is actually called site-web).
-
You would need to add $page as a parameter to make it usable in the way I describe. That always returns site 2, so no use. It needs to be something that takes $page as its reference point.
-
As I mentioned earlier, this: $rootPath = preg_replace('/assets.*/m','',$page->filesPath()); $config->setPath('templates', $rootPath . '/templates/'); works. as $page is in the site-1 context.
-
Me too! But to clarify. The code I suggest will set the template path to that which hosts the page with the RM field (site 1 - the app - in this case, but should make no difference in a single-instance case). By the originating site, I meant site 2 - the public site.
-
A suggestion: In FieldTypeRuntimeMarkup.module, getDefaultPath method, set an additional parameter $page (and update references), then use the following: $rootPath = preg_replace('/assets.*/m','',$page->filesPath()); $config->setPath('templates', $rootPath . '/templates/'); (and similarly for /modules/ and $config->urls) This will set the paths for templates etc. relative to the site which hosts $page, rather than the originating site. There may be a better way of getting the root path without having to do the preg_replace, but I can't see one at the moment. EDIT: Then you need to use $defaultPath = $config->paths->templates; etc. I'll try and work this up more fully, but for my code to work properly, I also need to make my PHP for the RM field "multi-instance aware".
-
That might be possible, if that were to be the only method. However, methods 1 and 2 require the data to be processed in the admin app as the front-end for those methods is not PW (and both these methods work well). In any case, I have been experimenting a bit with your suggestion, by putting my RM code on site 2 (since that is where the module is looking for it) and have been running into problems with selectors not working properly - will continue to investigate this. Excerpts of code are given below. The page is rendered using the markup regions strategy. _init.php is loaded first, the template is in Prices.php and the rendering is via _main.php. In _init.php $admin = new ProcessWire($config->paths->root . 'site/'); In _main.php <div id="wrapper"> <!-- content replaced by template --> </div> In Prices.php <div id="wrapper"> ....... <div id="availability"> <?php $adminPage = $admin->pages->get("template=Availability, name=bawd-hall-availability"); $availabilityTable = $adminPage->runtime_markup_availability; bd($adminPage, 'admin page'); bd($adminPage->availabilityColumns, 'admin page columns'); bd($availabilityTable, 'admin page runtime'); ?> <?= $adminPage->title ?> <?= $adminPage->runtime_markup_test ?> <?= $availabilityTable ?> </div> ---- </div> The bardumps illustrate that the other fields appear OK (as do $adminPage->title and $adminPage->runtime_markup_test {your test field - only works with the PHP placed in site-2/templates}). $availabilityTable (the original RM field) does not work even after placing a copy of the php in site-2/templates and modifying the $pages-> to invoke the site-1 instance, owing to the selector issue mentioned above, which I am investigating. EDIT: The selector issue is my code, I think. I got the field to render eventually in site 2 (minus a lot of css) with replicating all the PHP for the field in site-2/templates and modifying $pages etc. to pick up the right instances. Part of the issue seemed to be the need to explicitly set the $user in site 1, otherwise the field could not pick up the required data. I was assuming that since the API was all in PW that superuser in site-2 would allow API access in site-1; it doesn't! So, if we can get the RM module to pick up the code from the correct place, it may all work nicely.
-
Yes. To explain further: Site 1 is a web app which handles the bookings. Site 2 is the public website for the property. I need to publish the availability from 1 to 2. The result is the availability table you see at https://www.bawdhall.co.uk/prices. The admin app will handle multiple properties, each with their own availability page. The availability page in the admin app hosts the RM field. It is intended that the publishing of availability could take place in one of 3 ways: iframe in the public site (which could be anywhere). The availability template in the admin app provides the rendering for this (using the RM field). access the admin app PW API from a non-PW site on the same server (this is the method used for the link given above and works very well using the RM field on the admin site). access the admin app PW API from another PW instance (what I am now trying to do). The code for the RM field is really rather big and accesses a lot of data from across the admin site (site 1), not just the (non RM) fields on the availability page. As well as the table you see, it also hosts a booking form. You will realise from the above that this code needs to sit within the admin site to handle cases 1 and 2 - I really don’t want to replicate it in a slightly different form for case 3 to access all the underlying data directly and re-build the table. Besides, it seems nonsensical that case 2 should work “out of the box” but not case 3. I don’t know if I have made things harder by putting both sites in a multi-site setting. Maybe it would help if they were completely separate sites, whilst still on the same server. However, I read Ryan’s comment that it would be good to use the same PW version so I though that multi-site was a sure way to achieve that. I’ll answer the last point on code in a later post.
-
OK. Results as follows: Undefined function Filename does not exist (it is looking on site 2, not site 1 - where the page and field are) render() on null call to undefined function wire() I tried them all with and without RM module in site 2. The results are exactly the same (if the site 2 module is present it will run that, otherwise it will run the site 1 module). If I put the file in site-2/templates then alternative (2) works (with and without the module in site 2). (But it makes no sense to have the file in a different site from the page and field).
-
Additional info. I have the RM module in both sites. It seems like the site 2 module is attempting to run the site 1 field. (EDIT - Background - I thought I'd try a work-round by putting a function call to the php in the paste PHP box. The page and RM field are in site 1 so that's where the PHP file and function are. However, the work-round fails because of "undefined function" being called from the RM module in site 2. I'm not sure how modules are supposed to operate in a multi-instance set-up, but it seems that any modules necessary to process site 1 fields need to be in site 2 as well and somehow be "multi-instance aware"). FURTHER EDIT! - The above is not entirely correct. If I remove the site 2 module, the site 1 module will run (in Paste PHP mode only).
-
That works fine! EDIT But if it's in a php file then it doesn't work
-
Used Tracy. The field is just shown as empty. Other fields from the same page are all OK. As a separate php file. plus I can see that it all renders OK on site 1.
-
I've now implemented a multi-site and multi-instance setup and it mostly works. For some reason, the 2nd site cannot access select options fields on pages on the 1st site - I changed these to page reference fields and that works. The only major problem so far is with runtime markup fields, which are pretty crucial to my app (great module btw @kongondo ? ). These don't seem to be accessible by the 2nd site at all - either directly or via $page->render(). Curiously, I had no problem accessing them from a non-PW site (on the same server).
-
? Whoops! Many thanks - I wasn't aware of that - I'll read up on it.
-
Am I right in thinking that dragging of selected items to sort them is not possible on an iPad (or other touch screen?). Or, if it is possible, how?
-
Thanks @kongondo, the standard API only works on the same server anyway - that works now with the non-pw site. I’ve used multi-site before, but I don’t see how I could access the API of the other site without namespace confusion.
-
Uploaded script to github at https://github.com/MetaTunes/Form-update This includes a force refresh of the target field in order to make it work in more instances (e.g. a nice new application for providing previews of multi-select page-per-image)
-
I'm building a holiday cottage management system and website. It's coming along very nicely. Originally the plan was for it to be fully integrated - i.e. public website in the same PW site as the booking admin app. As a temporary integration of the availability calendar from the admin site into the existing public site, I used the PW API as documented here. It works very well - see the calendar embedded here. That got me thinking that perhaps it would be better to keep the two sites separate in any case, even after re-engineering the public site into PW (for its better CMS capability). Having the sites separate would make maintenance easier as well as not confusing the two environments (one on Bootstrap, the other on UIKit, for example). Two questions arise: Has anyone else done something similar (i.e. split website and web app in PW) or otherwise have any views on the pros and cons? More specifically: How do I address the namespace issues when I have one PW site accessing the API of another? It isn't a problem at the moment because the public website is not in PW.
-
I am getting this error on my live site Fatal Error: Uncaught Error: Class 'ProcessModuleInstall' not found in wire/modules/Process/ProcessModule/ProcessModule.module:1075 when trying to download (any) module. I cleared the FileCompiler, but the error persists. I copied the database across to my dev site and everything works fine. So I can install on the dev site and then copy back, but this is obviously unsatisfactory. Any ideas? NB I can also install on the live site OK by uploading the php and then installing. It's just the "download" function that is failing.
-
Hi @Macrura - you can see my changes here: https://github.com/outflux3/AdminHelp/compare/master...MetaTunes:master I also think it would be a good idea to allow more than superusers to edit - say via a permission.
-
Thanks. That’s useful, in that it has no database component, but I really need a drop-down/dialog capability so I think I’ll have to stick with the “hybrid” route, where only standard code is in the back-end.