-
Posts
26 -
Joined
-
Last visited
Everything posted by h4r4ld
-
Hi, I've got some datetime fields on my template and if I try to fill them with just a date and no time they save a wrong year. I tried to save the date like 2015-12-11 and it saves 5600-12-11 or different random years, also the datetime field sometimes isn't saved at all. I verified this by trying to save this fields by adminbackend, same result. Are there any threads/known problems to this topic?
-
I retake my old topic, because it somehow fits from the title. I want to add a dropdowninput field where the dropdown is filled by all given fieldvalues from one field of a template. I just need every value once, so I could do this with some php but I was wondering if PW has a function for that?
-
Thanks for the example, I'll try and refer back if I went into trouble (which will happen for sure ) And, yeah, you got me with that r, after adding it, it works like expected.
-
renderPager() should be correct -> https://processwire.com/api/modules/markup-pager-nav/ Thanks for that hint, got it working now. How about using 2 paginations for different tables on one page? For example, I have a landingpage showing the newest documents, newest users, ... now I would like to add pagination to every table of this. Is this possible or do I allways page every overview to page2 if I click on any of those /page2 links?
-
HI hi I'm currently working on pageination my documentlisting. I Have enabled the MarkupPagerNav module and activated allow page numbers on the documentholder template. I'm using some different selectors, but as for the tests I would go with this one : $documentHolder = $pages->find("template=documentHolder, status=hidden, limit=2, sort=created, docownerid={$user->id}"); the documentholder has 4 pages, so while using limit=2 there are 2 pages, which is working as expected. Next I try to give the 1,2, next appearing. Using this: echo $pagination = $documentHolder->renderPage(); I get an array to string conversion message and no pageitems. Using this: echo $documentHolder->render() Theres no error and the pageitems are showing up, but if I try to page to page 2 PW tries to open /?page=2 and fetches the same items as on default/page1. Where is my mistake? Thanks Harri
-
Gosh, I found it. The template is a hidden page and so I need to specifiy this in the selector.
-
Yep, not working with that either.
-
Ok, so I made a cache field like with autojoin on. If I'm right I should be able to do something like $allDocuments = $pages->count("doccache%=".$input->post->request) echo "There are " . $allDocuments . " docs containing your request"; Well, I don't get any results while using request that should match. I tried to add new document pages and regenerated the cache, but that ain't helped. Where's my mistake?
-
Thanks, that's what I was missing!
-
I don't see any cache fieldtype?
-
That would fit quiet well and is what I expected it to do, I just don't found information like: Is this cachefield generated automatically or on demand? If on demand, what do I have to do? Can I select fields which should be in or is it all fields of a template/page? Usage is exactly like a "normal" field in a selector?
-
Ok, that's what I found myself beside this : http://www.flamingruby.com/blog/processwire-caching-explained/ But is there any official documentation? I just recrawled the processwire site to find something without any result.
-
Thanks, exactly what I was looking for. Can you provide some documentation on this? I didn't find anything related?
-
Hi, I need to get all pages from a template where a searchstring matches any field of the page. $result = $pages->find('template=documentHolder, status=hidden, *=$string'); I know i could do something like $result = $pages->find('template=documentHolder, status=hidden, (field1=$string), (field2=$string), (field3=$string)'); But is there a way to do so without writing down every field the template has? Maybe something like a subselector? Best, Harri
-
Unlink should not effect files uploaded, but files that are linked to upload, so that shouldn't be any of a problem. *Edit: Uhuh, you got me there, seems like I totally messed up the upload script from soma. Thanks for open my eyes. Do i need to save them twice always? As far as I understood from the docs its only needed if the field is an imagefield? I just store the link to the uploaded files in a field, so its nothing more than text.
-
Hi, I'm going mad, but I bet its just a simple thing... I try to upload a file with wireupload, there is no error reported from WireUpload->getErrors and the page to store its data is beeing generated. Everything seems fine, the path to the newly uploaded file is stored and every value is fetched like suppost, there is just no file in the specified directory on my ftp. I even tried to chmod 0777 the upload directory, no change. <?php if($input->post->barcode){ $message = ''; $upload_path = $config->paths->root . "file_uploads/doctree/"; // new wire upload $u = new WireUpload('uploads'); $u->setMaxFiles(1); $u->setMaxFileSize(200*1024); $u->setOverwrite(false); $u->setDestinationPath($upload_path); $u->setValidExtensions(array('jpg', 'jpeg', 'gif', 'png', 'txt', 'pdf', 'tif')); // execute upload and check for errors $files = $u->execute(); if(!$u->getErrors()){ // create the new page to add the file $p = new Page(); $p->setOutputFormatting(false); $p->template = 'documentHolder'; $p->parent = wire('pages')->get('/doctree/'); $p->status = "hidden"; $barcode = mb_strtoupper($input->post->barcode, 'UTF-8'); $p->name = $barcode; $p->title = $barcode; $p->docdescription = $input->post->description; $p->doccaption = $input->post->title; $p->docownerid = $user->id; $p->docvalue = $input->post->value; $p->docvendor = $input->post->vendor; $p->doccategorie = $input->post->categorie; foreach($files as $filename) { $p->docfile = $upload_path . $filename; } // save page $p->save(); // remove all tmp files uploaded foreach($files as $filename) unlink($upload_path . $filename); $message .= "<p class='message'>Files uploaded!</p>"; } else { // remove files foreach($files as $filename) unlink($upload_path . $filename); // get the errors foreach($u->getErrors() as $error) $message .= "<p class='error'>$error</p>"; } } else { ?> <form action="./" class="form-horizontal row-border" method="post" data-validate="parsley" id="validate-form" enctype="multipart/form-data"> <div class="form-group"> <label class="col-sm-3 control-label">File input</label> <div class="col-sm-4"> <div class="fileinput fileinput-new" data-provides="fileinput"> <div class="input-group"> <div class="form-control uneditable-input" data-trigger="fileinput"> <i class="fa fa-file fileinput-exists"></i> <span class="fileinput-filename"></span> </div> <span class="input-group-addon btn btn-default btn-file"> <span class="fileinput-new">Select file</span> <span class="fileinput-exists">Change</span> <input type="file" name="uploads[]" id="uploads[]" size="40" accept="image/jpg,image/jpeg,image/gif,image/png,image/tiff,application/pdf,text/plain"/> </span> <a href="#" class="input-group-addon btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a> </div> Allowed filetypes : *.jpg, *.jpeg, *.gif, *.png, *.txt, *.pdf, *.tif </div> </div> </div> <!-- some more inputs... --> <button class="btn-midnightblue btn" type="submit" onclick="javascript:$( '#validate-form').parsley( 'validate' );">Submit</button> </form> <?php } ?> Based on this: https://gist.github.com/somatonic/4150974
-
Ok got that. Got this runing now and my form automatically adds a new page with all fields once a document is added. Is it in this kind of "datasource" possible to make a field unique or like primary? As there seems to be no real relation between each page I was wondering how I can keep track if not use the pagename? Like for example the barcodefield, where every barcode is only allowed to be used once.
-
That, in PW, will be done by selectors if I interpret Martijns post right? Putting pages in a pagecontainer would be more or less only for organizing the pages more nicely on adminpages from my view yet. I just don't know if I would break up some problems ahead while doing so. And before concentrating on quick search I need a good data storage where I can perform a search.
-
That's gone be my evening meal. Can anyone give a best practice advice on this: Should I put my documentpages into a parent "container" page?
-
Thanks for the welcome Coming to use pages, should I put them into a parent "container" page? Every document will get an ID (barcode), I thought about using this as the pagename? If I'm not totally wrong than I should be able to do something like this: // fetch one document $item = $pages->get($barcode); // fetch all documents $items = $pages->get("/parentpage/"); Is this the suggested way to do? How about using RegEx in the get function? *edit: Just looked into selectors, just like regex I can use something like this? // fetch all documents ; limit 10 $items = $pages->get("/parentpage/", limit=10);
-
Ok, so there is no limit in having documentpages at all? How about the speed compared to use a database directly while searching lots of documents?
-
Hi, I'm pretty new to processwire, but I'm digging in really fast. My actual project is an invoice management site where one can store data like in a document managment tool, organizing invoices, searching, keywording and so on. My actual problem is that I expect about 10.000 documents a year (based on what I bring myself ) and I'm not sure on how to do so. As far as I know yet, every fieldmap is stored in one page, which means I could try to handle every document in a hidden page, which would mean my pages will probably exceed all given limits? I need to work with those fields, so I need direct access to them aswell as a good speed fetching all of them (at once, filtered, ...). So I'm a bit aware what could be the best way to do this with PW (and if so, how?) or handle a new database for this without PW? Best, Harri
-
That helped, thanks. If anyone else is faceing a similar problem, here is what came out changed: Since I change fields which are in the $user page I need to bring the userid, also I need to know which type of field im handling to sanitize it. This is done by the pk field, where I connect the ID with _url, _email, _text or _textarea (not all sanitizes covered yet). // handleProfileFields.php include("./index.php"); $field = $_POST['name']; $value = $_POST['value']; $pk = explode('_',$_POST['pk']); $item = $wire->users->get($pk[0]); if(!empty($value)) { $item->setOutputFormatting(false); switch ($pk[1]) { case 'url': $item->$field = $sanitizer->url($value); $item->save(); break; case 'email': $item->$field = $sanitizer->email($value); $item->save(); break; case 'text': $item->$field = $sanitizer->text($value); $item->save(); break; case 'textarea': $item->$field = $sanitizer->textarea($value); $item->save(); break; } } else { header('HTTP 400 Bad Request', true, 400); echo "This field is required!"; } If someone knows better ways to do, I'm always up for new advices Best, Harri
-
Hi, I'm want to save my userfields on a userprofile frontpage with x-editables. Therefor I have a field in my userprofile page like : <a href="#" id="web" data-type="url" data-pk="1" data-title="Enter website"><?=$user->web?></a> onClick I get a popup with an inputfield, which works pretty nice, the javascriptcode is like : $('#web').editable({ type: 'text', pk: 1, name: 'web', url: 'http://pw.mysite.de/site/templates/assets/requests/handleProfileFields.php', title: 'Enter website' }); So if the user submits his changes, the handleProfileFields.php should be called which is like : $field = $_POST['name']; $value = $_POST['value']; if(!empty($value)) { $user->$field = $value; $user->save(); } else { header('HTTP 400 Bad Request', true, 400); echo "This field is required!"; } My problem is that as a *.php file I get a HTTP 404, renamed to *.txt I can open it. I guess it has something to do with pagerendering of process wire, so im aware if I put my assets to the right place or if I should put it somewhere else to be included as are. Also I'm wondering if this is the best way to save the data to database and if $user-save() will be available at this point? Best, Harri
-
Thanks for that link, I was crawling the forum for links/posts like this, wrong place. I was following another tutorial to add custom fields and added them to the wrong page.