Jump to content

cosmicsafari

Members
  • Content Count

    71
  • Joined

  • Last visited

Everything posted by cosmicsafari

  1. Not sure why the embed version didn't work but I changed it to render and it started working. That said according to here it looks like the original should have worked also? https://processwire.com/api/ref/form-builder/embed/ <?php echo $forms->render ('my-form-name', array('hidden_field_name' => '666')); ?>
  2. Hi all, I have the same form on multiple pages, the idea being that I can populated a hidden field with a page specific value automatically. I figured this should be reasonably straight forward but I can't seem to get the following to take effect. <?php echo $forms->embed ('my-form-name', array('hidden_field_name' => '666')); ?> No matter what I do, it never updates the default value currently set for said hidden field. Feels like I'm missing something really obvious? Any ideas?
  3. Ok well that would explain that then, any particular reason why out of curiosity?
  4. Hi all, I have need to dynamically set InputFieldMultiSelect to selected on page load based on the status of some items within a database table. However I keep running into issues when trying to do this via InputfieldSelect::setOptionAttributes() https://processwire.com/api/ref/inputfield-select/set-option-attributes/ Going by the above it sounds like it should be pretty straight forward, and for certain values it seems to work but not when I wanted to set it to 'selected'. For example: $f->setOptionAttributes(1030,['foo' => 'test']); The above works as I would have wanted, in that it updates the option with the value 1030, to include the attribute foo="test" But the same code above edited to the following: $f->setOptionAttributes(1030,['selected' => 'selected']); Doesn't seem to do anything? I assume I'm missing something or trying to implement the 'selected' wrongly but I'm not sure how else I should approach this, any advice would be much appreciated.
  5. Thank you for the suggestions. I did have a look at the content within the BCE module but found it hard to follow. Its a fantastic module but its far more advanced than anything I have ever put together but I will continue to look into it. Apologies I should have mentioned it does work with a small enough CSV file. However I will make some changes and see how I get on. I'm not sure if its relevant but the storage engine of the database is InnoDB.
  6. Hi all, Just looking for some advice. I have created an admin page where the user can upload a fairly simple csv, in order to create a bunch of pages in batch. I have recently been trying to update it so that it wipes the existing pages created by the last upload before creating new pages based on the newly uploaded CSV. I'm obviously missing something as any CSV or indeed any attempt to batch import/delete always results in a 504 Timeout. Figured this was just something we would just have to work around and likely due to server constraints. However I recently installed the Batch Child Editor module (http://modules.processwire.com/modules/batch-child-editor) out of curiosity. Anyway too my point, I can use this module to delete the same number or indeed import the same number of items that my implementation struggles to cope with. So I was hoping if I posted a snippet of my own simple version, I could get some pointers as to where we think the bottleneck is as im clearly doing something wrong. Any thoughts and advice are welcome. <?php if ( isset($_POST["submit"]) ) { if ( isset($_FILES["file"])) { //if there was an error uploading the file if ($_FILES["file"]["error"] > 0) { echo "Error Uploading File (Return Code: " . $_FILES["file"]["error"] . ")<br />"; } else { $created = 0; //if file already exists if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { //Store file in directory "upload" with the name of "uploaded_file.txt" $storagename = "../assets/csv/uploaded_file.txt"; move_uploaded_file($_FILES["file"]["tmp_name"], $storagename); if(($handle = fopen($storagename, 'r')) !== false) { // get the first row, which contains the column-titles (if necessary) $header = fgetcsv($handle); $x=0; $group_settings = wire('pages')->get('name="group-settings"'); // loop through the file line-by-line while(($data = fgetcsv($handle)) !== false) { $lng = $data[0]; $lat = $data[1]; $name = $data[2]; $contact = $data[3]; $email = $data[4]; $phone = $data[5]; //CREATE error_log('('.$name.') CREATE'); $p = new Processwire\Page(); $p->template = 'group'; $p->name = $name.'('.$lat.','.$lng.')'; $p->title = $name.'('.$lat.','.$lng.')'; $p->parent = $group_settings; $p->text_a = $name; $p->text_b = $contact; $p->group_location->lat = $lat; $p->group_location->lng = $lng; $p->email = $email; $p->phone_number = $phone; $p->save(); $created++; unset($data); } fclose($handle); } } } } else if ( isset($_REQUEST["delete"]) ) { //Delete existing locations $p = $pages->get('/settings/group-settings/'); foreach($p->children as $child){ $child->delete(); } } else { echo "No file selected <br />"; } } ?>
  7. Managed to solve my issue, documenting what I done here for others and future reference. So basically I never actually figured out the specifics of what was causing the fatal error, however as mentioned previously it did seem related to the custom module that was setting up numerous webhooks. After trying numerous things, I ended up deleting the contents of the cache table within the database, which got rid of my inital fatal error and let me render pages. Now that I could see pages, albeit with some errors I was able to then log into the backend. Wherein I refreshed the module cache which appears to have resolved the issue. Hopefully the above will be of use to someone in future... more than likely myself as I have a habit of running into the same odd errors. ๐Ÿ˜‹
  8. Thanks for that, clears things up a bit for me. Useful information for future reference ๐Ÿ˜‹
  9. Hi all, I have need to disable a module but the module itself is causing a fatal error on every page so I can't actually get into the backend to do it as normal. The fatal error is also occuring before I can even run $modules->uninstall("ModuleClassName");๏ปฟ to disable it via the code. Any ides what database tables I would need to edit in order to safely disable only the module in question? Also while im on the subject, what is the signifcance of the flag column within the modules table of the database, struggling to find any documentation about the DB structure generally.
  10. So I have done some more digging with this one and worked backwords to find that the issue appears to be the one of the many $page->render calls within ProcessPageView.module, within the __execute method to be precise. Aside from that im still completely stumped as to why it wouldn't be callable. Find it quite strange as at first I thought maybe it couldn't get the page object in order to run the render method, but I added in some logging within ProcessPageView.module around the offending lines of code. I can get the page title & according to gettype() its an object, so im well confused at this point. ๐Ÿค” The code of the __execute method, including my added logging incase its of any use: public function ___execute($internal = true) { error_log('ProcessPageView'); if(!$internal) return $this->executeExternal(); $this->responseType = self::responseTypeNormal; $config = $this->config; $debug = $config->debug; if($config->usePoweredBy !== null) header('X-Powered-By:' . ($config->usePoweredBy ? ' ProcessWire CMS' : '')); if(is_array($config->pageNumUrlPrefixes)) foreach($config->pageNumUrlPrefixes as $prefix) { $this->pageNumUrlPrefixes[$prefix] = $prefix; } if(!count($this->pageNumUrlPrefixes)) { $prefix = $this->config->pageNumUrlPrefix; if(strlen($prefix)) $this->pageNumUrlPrefixes[$prefix] = $prefix; } $this->pages->setOutputFormatting(true); if($debug) Debug::timer('ProcessPageView.getPage()'); $page = $this->getPage(); if($page && $page->id) { if($debug) Debug::saveTimer('ProcessPageView.getPage()', $page->path); $page->setOutputFormatting(true); $_page = $page; $page = $this->checkAccess($page); if(!$page || $_page->id == $config->http404PageID) { return $this->pageNotFound($_page, $this->requestURL, true, 'access not allowed'); } if(!$this->delayRedirects) { $this->checkProtocol($page); if($this->redirectURL) $this->session->redirect($this->redirectURL); } $this->wire('page', $page); $this->ready(); $page = $this->wire('page'); // in case anything changed it if($this->delayRedirects) { $this->checkProtocol($page); if($this->redirectURL) $this->session->redirect($this->redirectURL); } try { $this->wire()->setStatus(ProcessWire::statusRender); if($this->requestFile) { $this->responseType = self::responseTypeFile; $this->sendFile($page, $this->requestFile); } else { $contentType = $page->template->contentType; error_log('Page: '.$page->title); error_log(gettype($page)); if($contentType) { if(strpos($contentType, '/') === false) { if(isset($config->contentTypes[$contentType])) { $contentType = $config->contentTypes[$contentType]; } else { $contentType = ''; } } if($contentType) header("Content-Type: $contentType"); } if($config->ajax) { $this->responseType = self::responseTypeAjax; return $page->render(); } else { error_log('ERRORS AT THIS POINT'); return $page->render(); } } } catch(Wire404Exception $e) { return $this->pageNotFound($page, $this->requestURL, false, '404 thrown during render'); } } else { return $this->pageNotFound(new NullPage(), $this->requestURL, true, 'requested page resolved to NullPage'); } }
  11. It occurs regardless of the debug settings and happens on every page, can't access admin login page to get any further. I'm just about to try it out on a machine running PHP 5.6, out of curiosity to see whether I run into the same error. From doing some more investigations, I think it may be related to a custom module which appears to use a lot of web hooks.
  12. Hi all, Starting work for a new client, so pulled down a copy of their existing PW site. All looks normal in terms of the codebase structure, set it up as I would normally for any PW site yet I everytime I attempt to view a page I get: From what I can gather its running PW version 2.8. On the live environment where I copied it from and its working fine, they are apparently running PHP 7.1 whereas I am running PHP 7.3 locally, just incase that may be a cause for the issue. Any ideas as nothing seems obvious to me at this point.
  13. Thats exactly the kind of thing I was looking for! ๐Ÿ˜ If im ever anywhere near Munich i'll buy you as many beers as you can drink ๐Ÿ‘
  14. Hi all, This is probably a stupid question but is there anyway to select from the database all the images as Pageimage objects? The idea being so that I could have just a 1 level deep array of Pageimage objects so that I can loop through and run the removeVariations() method on them? My original idea was something along the lines of: $query = $this->database->prepare('SELECT name FROM FIELDS WHERE TYPE = "FieldtypeImage"'); $query->execute(); $results = $query->fetchAll(); foreach ($results as $row) { $query = $this->database->prepare('SELECT * FROM FIELD_'.$row[0]); $query->execute(); $images = $query->fetchAll(); foreach($images as $image){ // my thinking was at this point if said results where Pageimage objects or // could be turned into one I could then run the removeVariations() method on them ie. // $image->removeVariations() } } I tried working with the above results within my module code but I could never get them into the correct context to run the method in question. The above implentation obviously doesn't work but is the idea sound? Could it ever work in this fashion or do you only have access to Pageimage::removeVariations() in the context of starting with a page selection ie. $page->image->removeVariations(); The reason I ask is that I have a solution using the built in selectors which partially works. However it comes up short when attempting to remove the image variations for image fields within repeaters, theres also the issue of images fields within nested repeaters. Any ideas are much appreciated.
  15. So if im understanding that correctly then its doesn't create them anew like $page->image->width() would, rather it attempts to recreate them using what already exists? That definitely would explain the results I was seeing, as it did work if some variations existed already but not if it was just the originals.
  16. Hi all, Just wondering if someone with a bit more PW knowledge than me could give a run down of what this method actually does and how its achieved. I get that it rebuilds image variations but based on what settings? If I wanted to rebuild all the websites image variations but at say a reduced image quality can this be set somewhere globally that this method would take into account? For some context I have built a fairly simple module to delete all the image variations connected to any FieldtypeImage which is being used on the website, for the most part this works quite well. As I was quite happy with how that turned out I figured I would give the module another option to rebuild the images also. So there would be a 'Remove' and 'Rebuild' button on the modules config page. The idea being that I could use this tool to delete all the image variations, update some global settings then regenerate them all but currently it doesn't appear to do that. I assume this is either because my codes borked or im misunderstanding something fundamental about how rebuildVariations() works.
  17. Thanks for the replies folks. Given the above response does the following hypothetical setup sound reasonable. Primary DB with mirrors hosted on Azure Rsync contents of Assets/Files folder between primary server and mirrors Enable database driven sessions, that way we don't need to copy Assets/Sessions between the servers Obviously thats very vague in the details but as a general proposal is there anything glaring wrong with this approach?
  18. Hi all, I have been asked by a client whether we can setup load balancing for their existing Processwire site. From my investigations on Google and within these forums, it definitely seems possible but as a newbie with a basic understanding of the subject im a bit lost. Does anyone know of any existing tutorials for settings up load balancing with PW? What items would need to be changed on their current stand alone install, is there a list of best practices worth consulting etc? As I understand it we would need to have some sort of copying mechanism (rsync script most likely) in order to make sure any uploaded assets are shared between the main server and the fallback ones, other than that im not sure what else would need to be ammended. Any thoughts/help would be greatly appreciated.
  19. Good to know im not going mad and its supposed to work that way. Both seem like good solutions, will try both and see which works best for my project. Many thanks! ๐Ÿ‘
  20. Hi all, This is more of a general question than a problem per say. Anyway I have been using the AssistedURL module for call to action links among other things, on the whole its a great module so shout out to the developers. That said I just noticed that if you update a linked PW page's name/url any link field on other pages using AssistedURL don't update automatically. If this is a limitation then thats fine just thought I would ask incase there is a setting either at module or sitewide level that I am missing that enables this to happen.
  21. Not an explanation as to what caused the issue, however this workaround got me back up an running. I deleted the language page record from pages table of the DB, this allowed me to create a new language while still keeping the same name. I then receated the the language from within the backend and readded in the alternative language content to the fields in the effected pages. So to summarise I have it working again but still have no idea what caused the intial problem
  22. Hi all, Thought I had the language translation working but now when I attempt to access the language through the backend (Setup > Languages > My Language) it throws an error: Recoverable Fatal Error: Argument 3 passed to ProcessWire\LanguageTranslator::textdomainTemplate() must be of the type array, null given Can anybody shed any light on what would cause this error when trying to access my language through the settings in the backend, or attempting to view it on the frontend with its language specific URL. The only thing I have changed recently was moving the DB to a different location however the one exported was the one that I previoulsy had my custom language working on it previoulsy. Any ideas, im at a bit of a lose as to what would have caused this when it was working previously.
  23. Thanks for the replies, its much appreciated. From reading your responses I think I have a handle on it now. Will report back once I no doubt prove that above statement wrong though ๐Ÿ˜€
  24. Hi all, This is my first foray into a multi lingual PW site, what i'm unsre about is whether the frontend output is translated automatically or do I have to provide the content in another language also? As it stands I have installed the following modules: And have created and uploaded the Chinese language pack. At this point I can successfully change my profile and the backend successfully displays in Chinese. However I am confused about how I now get that translation to work on the frontend? I have setup the alternative url for the page I wish to view in Chinese So as a basic test I tried adding the following into the template used for the page above. However both urls still display the message in English? I take it I have missed something, do I then need to enter the frontend output in Chinese in another field within the backend to enable Chinese url to output the content? Any ideas would be greatly appreciated.
  25. Hi all, I see that @wumbo mentioned that the 'Link Attributes' where specifically removed from the modal which pops up. However is it possible to enable the 'Link Attributes' tab for this field type, seems like it would be very useful for my current project.
ร—
ร—
  • Create New...