• Content count

  • Joined

  • Last visited

Community Reputation

45 Excellent

About Harmen

  • Rank
    Full Member

Profile Information

  • Gender
  • Location
    The Netherlands

Recent Profile Visitors

432 profile views
  1. @Robin S, thanks for the links. I fixed or cheated it in a bit different way. In the success function of the AJAX Post, I check for the reply if it is success or not. If it is equal to success I redirect to the same page with a query behind the normal URL. In the file I check if the query is in the URL and if so I push the file as a download. The only thing insecure to this method is that if you know the query you can still get the file without a serialnumber. Anyway, it works for the time being, hopefully this helps someone else
  2. Hi folks, On the website I am working on I do have a form which needs to be filled in (duh) and when the user clicks on download, the data is send with ajax and processed in the same file by using the ProcessWire API with $config->ajax; The data which is provided by the user will be checked with data in my database. If the data is correct I want to push a file download. But this is not working at the moment. It seems like the content of the (.exe) file is pasted in the console instead of pushing the file. My code looks like this: if ($config->ajax){ $serial = $input->post('serial'); $DB = DB(); $query = $DB->prepare("/*My query here*/"); $query->bindParam("comparision", $serial, PDO::PARAM_STR); $query->execute(); $reply = ''; $SN_rows = $query->rowCount(); if (!$SN_rows > 0) { $reply = 'error'; } else { $reply = 'success'; $installer = $page->attachments->eq(1); $filename = "Filename"; $filepath = $installer->filename; $options = array( 'forceDownload' => true, 'exit' => true, 'downloadFilename' => $filename ); wireSendFile($filepath, $options); } echo $reply; exit(); } What am I doing wrong here or is it a bug? Is there another way to do this with the processwire API? Thanks in advance, ~Harmen
  3. Hi all, I do have a form in the 'backend' of my website which has a fieldtype of ASMSelect. I gave all the options of that field a custom attribute with a value: foreach ($feature_group['features'] as $feature_id => $feature) { $field->addOption($feature_id, $feature['name'], array('data-feature_group' => $feature_group_id)); } How can I read out the value of that custom attribute named data-feature group? I've tried it with $selected_feature_groups = $form->get($category_id)->getAttribute('data-feature_group'); //AND selected_feature_groups = $form->get($category_id)->feature_group; but that doesn't work. How can I get this to work? ~Harmen
  4. Shame to me, didn't notice that.
  5. Have you tried to put only the plugin file there and not in a directory? I mean, PW says to put the plugin file directly in the plugin folder so that should work I guess
  6. Thanks, didn't know that! Changed the $this into wire(' ') and now it works! ~Harmen
  7. Hi all, Currently I am working on a filter for all the products in a category. So I've set up a class and built a (PW) form in it. When the user clicks on continue the form should return a processform function which sets the variable of the form in a session. Later in the file I want to read out that session and use that variable to select which products should show up and which should be hidden. So now with code examples to make it a bit more clear for you: In my file I start with a class: class classname { public function ShowForm() { $form = $this->Form1(); if ($this->input->post->submit) { if ($this->processForm1($form)) $this->session->redirect("./"); } return $form->render(); } Then a form inside the class: protected function Form1() { $form = wire('modules')->get("InputfieldForm"); $form->description = "Fill in the fields to find the mouse which fits your wishes"; $form->label = "Mouse Selector"; $form->action = "./"; $form->method = 'post'; $f = wire('modules')->get("InputfieldRadios"); $f->name = "Hand"; $f->label = "label"; $f->addOption(1, "1"); $f->addOption(2, "2"); $form->add($f); $this->addSubmit($form, 'Continue'); return $form; } This function is called when the user submits: protected function ProcessForm1($form) { $form->processInput($this->input->post); $this->session->hand = (int)$form->get("Hand")->value; } As you see I store the variable of the submitted form in a session. After closing the class I continue with building the page and then I want to read out that variable: $value = $this->session->hand; $content .= "Value of 'Hand': " . $value; But when I execute this on my website I cannot see the value of the form. Have I done something wrong or how can I fix this? Thanks in advance, ~Harmen
  8. Do you mean the core modules or the modules at /site/modules? And is that really a problem to refresh once to initialise the modules?
  9. Looks great! Looking forward to implement this!
  10. I think this can be done with a simple if statement.... Don't have the time to provide a snippet for you at the moment, I'm sorry. Something like this: if ($image->caption){ //Output markup 1 } else { //Output markup 2 }
  11. Hi Manlio, Are you sure you've set a name in different languages? So if your page is called 'Prodotti' in Italiano, is it 'Products' in English? ~Harmen
  12. Hi, I am not familiar with the specific settings and configurations for the CKEditor, but I've found something: Have you applied this to your field using the CKEditor? Maybe <br /> works? ~Harmen
  13. You're right, but as I said. I did not tested it, and wrote this piece of code in a rush. Thanks for the addition. I think it is, most of the time I use it at the end of operations.
  14. Hi, I think this is not that difficult, you work already with an id which you can use now: You could add a if statement for the very first id in your foreach loop: $id = 0; // set it to zero foreach ($sections as $item) { if ($id == 0) continue else { echo "<li><a href='#section-$id'>$item->title</a></li>"; } $id ++; } NOTE: Haven't tested this As you want to skip the first element, which id is equal to 0, the first rendered <li> will have id 1, so if you add another if statement in your foreach loop for id ==1 you can filter that item out and the rest gets the normal tags. See code below: $id = 0; // set it to zero foreach ($sections as $item) { if ($id == 0) continue else { if ($id == 1){ echo "<li class='yourclassforfirstitem'><a href='#section-$id'>$item->title</a></li>"; } echo "<li><a href='#section-$id'>$item->title</a></li>"; } $id ++; } Haven't tested it so far, but I expect this works (maybe with some adjustments)
  15. module

    New version is launched! I've added some new features/options - Earlier I've launched a version with a new option to import the reference codes of your products and the EAN-numbers too - Added a link to module info which links to this module in the module section of processwire. - If you used this module before and only want to update your data, you don't need to first import your categories, then products etc. You can directly click on the import button you want to use. - Revised this module to make translations available. Also made a dutch translation for this module. Download the .zip file (attached to this post or get it via my github) and add it to your dutch language site translations file. Enjoy the new features! NL-Translations.zip