-
Posts
7,479 -
Joined
-
Last visited
-
Days Won
146
Everything posted by kongondo
-
Sounds like you just need a form. OK, even a 'financial stuff shop' is just forms. I am assuming you are not taking payment with the orders (hence the without the financial stuff). On the frontend, at its simplest, depending on the number of products you have, you create a dropdown list (like an asm select) of products. The label is the product name/title, the value is the product (page) ID. A user selects a product, and it is added to a list or table below the dropdown using JavaScript (like jQuery). To get a bit fancy, you then disable that item in the dropdown list. Assuming you were using a table, each row is a unique product, The table can have several columns, one for title, one for a product description, one with an input for quantity, and one with a delete button/x plus a hidden input for product ID, etc. If an item is removed from the table (JavaScript), you delete the row and re-enable its selection in the dropdown. I am assuming you will at least be collecting the customer's email, so create an input for that. Create a submit button as well. When the submit button is pressed, we use JavaScript (simple using jQuery), to process the form. If there are no products selected, just return an error. If there are products, at the very least we want to send the product ID, its matching quantity and the customer's email. We use JavaScript to serialise these and submit the form. Server-side, you validate and sanitize the data. Product ID and quantities are just integers. You then do what you need to do....thank yous, create a record of the order, redirect, etc.
-
I'm not sure I follow. Doesn't that mean that every time the snippet is used, it will add the type hints? Doesn't that mean, if I use the variable again within the same code, the type hint will be printed out again? I'm sure am missing something here, please clarify/show me an example pseudo code ?
- 242 replies
-
- visual studio code
- vsc
-
(and 2 more)
Tagged with:
-
Welcome to the forums @Spiria. It could be a cache issue. Have a look here: This too may be of interest:
-
[SOLVED] Best way to assign properties but each properties only once
kongondo replied to dotnetic's topic in General Support
A descriptive name sometimes helps when searching the modules directory, me thinks... :-). -
What!? That's nasty man. Sorry to hear that. Hope it's nothing more than the antibiotics can handle and hope you feel better soon. Cat stays? (thinking of the kids here as well).
-
Aah. Thanks. I'm too lazy though. Auto close doesn't require me to press tab :-). Btw, auto close changes the matching tag if the opening tag is edited. If I have a <span> and want to change it to a div, I just type over/edit the span and the matching closing span tag will be changed to a </div> (but it fails sometimes). Not sure emmet can do that.
- 242 replies
-
- visual studio code
- vsc
-
(and 2 more)
Tagged with:
-
Interesting thought. Maybe a notice similar to when one is editing the same page in two or more places.
-
Prevent Page to be deleted when it is referenced by another page
kongondo replied to KarlvonKarton's topic in General Support
I didn't read that, sorry. Now, that I have, the discussion you are referring to, whilst related, is somewhat different, I think. That discussion was a bug/issue report. The issue is about Page Reference fields themselves, behaving in an unusual way...etc. The present issue, IMHO, is a not about the behaviour of page reference fields, but about pages referenced in those fields, specifically, whether they should be deletable or not. I think the present issue is not a bug report but a feature request. Namely, similar to locked items in the tree and in page edit, a trash icon/delete button(or link) should not be visible for referenced pages. In the API, one should not be able to delete such pages as well, unless they pass some flag...(my thought). What do you think? -
Prevent Page to be deleted when it is referenced by another page
kongondo replied to KarlvonKarton's topic in General Support
Makes sense. File a feature request ? -
I've gone back to using Auto Close tag extension as emmet only works with HTML files. It doesn't work with HTML inside PHP files. It's not auto-closing for me...
- 242 replies
-
- 1
-
- visual studio code
- vsc
-
(and 2 more)
Tagged with:
-
I'm not. All work as expected (kb+enter; kb+tab; mouse select). No errors in console. Win7, Chrome
-
Prevent Page to be deleted when it is referenced by another page
kongondo replied to KarlvonKarton's topic in General Support
Then you have to hook into something. If you want that referenced categories not to display the trash link, then you can hook into the tree render. Or, if you don't mind the display of the trash page link, then you can hook before pages::deleteReady. Alternatively, depending on who is administering the site, you can lock all your category pages and only unlock one you want to delete, at delete time :-). You can check if it is being referenced in a page field by going to the settings tab when editing the category page and scroll to 'What pages point to this one' section. -
Prevent Page to be deleted when it is referenced by another page
kongondo replied to KarlvonKarton's topic in General Support
Try (untested) $myCategoryPage = $pages->get('/path/to/an/example/category/page/); // if the category page is not referenced in a page reference field if(!$myCategoryPage->numReferences) { // safe to delete $pages->trash($myCategoryPage); } http://processwire.com/api/ref/page/ ps: if it doesn't work, try $myCategoryPage->numReferencing instead. I get confused which is which :-). Please report which one worked for you, thanks. -
I was replying as your reply came in :-). Yes, that is the issue. Is there any reason your discount page titles would be empty? I mean, would the selector still work without adding the title!=''?
-
[SOLVED] Best way to assign properties but each properties only once
kongondo replied to dotnetic's topic in General Support
Great, thanks for sharing! A little comment, if I may. Reading your original post (and to some extent the blog post), I got confused by what you meant by property. On the one hand, it seemed to refer to property in a OOP sense since you also talked of objects. It also seemed to refer to an actual physical property since you refer to a 'room' :-). My German is not great, so that didn't help :-). Reading the blog post, it also seems by property you mean an option in a select? Maybe you could clarify this and use options instead if that is what you mean? Thanks again! -
Looks OK. It's good to exit/halt() after echoing the JSON. Either of these (although halt() may be preferable in some cases). if($config->ajax) { echo $couponsJSON; return $this->halt(); // OR // exit; }
-
You should be able to do this for superusers only, if you need to :-); Read from here onward.
-
At the earliest opportunity possible when it hits the server. This means in the function, or an intermediary function first, which then passes the clean data to the function that creates the post. If the data does not pass the sanitise process, we redirect back to the form. The form can do client-side validation, e.g. was the email input filled, does that look like an email, etc?
-
Ah. I thought you were doing your own implementation.
-
Thx folks! I must have skimmed over the docs too quickly. I saw neither of 'expand' nor the '@' class :-).
-
Ok, so CSS is not my thing, but even by my (very low) standards, surely this ought to be rudimentary. I feel silly creating a whole thread for this but for the life of me, I'm unable to create a simple 3-column grid using ui-kit! The first and the third columns need to be 15% (or even 25%) in width each. The column in the middle should take the remainder. I've done the width thingy/class (ui-kit-width-blah-blah) , nesting 3 divs inside a parent div but it just wont play ball. The 3rd child div is collapsing to the next row. Please don't roll your eyes at me; I'm a noob :D. Help, anyone? Thanks.
-
Hi @Mustafa-Online. I've posted an answer in your original thread.
-
You can Hook into InputfieldFile::processInputFile. There are other places in that Class you could also hook into, but I think processInputFile works best. Throw the code below in ready.php Please note: Starter code: not much validation going on other than checking if the field the file was uploaded to is 'course_file' You will have to implement other logic yourself. For instance, the code copies the file immediately it is uploaded by ProcessWire Ajax. It doesn't check if the page is actually saved. If a page is not saved and the page is reloaded, as you know, files in file fields are deleted from disk. This code does not delete the corresponding file in your custom directory You might want the Hook to only run if you are in admin. You can add that logic I've purposefully left in verbose and debugging code in there (Tracy stuff) to help you ( maybe and others) understand what's going on. I suggest you test using Tracy Debugger for a better grasp of the file upload process. Delete the debugging stuff when you've got this working as you want :-). wire()->addHookAfter("InputfieldFile::processInputFile", function(HookEvent $event) { // @note: here, events are $input, $pagefile, $n @see: the method // get event we are hooking into // get arguments by index {a bit faster, but less-readable} /* $input = $event->arguments[0]; $pagefile = $event->arguments[1]; $n = $event->arguments[2]; */ // get arguments by name #$input = $event->argumentsByName('input'); $pagefile = $event->argumentsByName('pagefile'); #$n = $event->argumentsByName('n'); // $pagefile->field: The Field object that this file is part of. // limit to a specific field {course_file} if($pagefile->field->name != 'course_files') return; # intercept file // Tracy Debugger calls to see what's going on. Also logs Ajax inputs! #bd($input, 'input'); #bd($n, 'input'); // @see: http://processwire.com/api/ref/pagefile/ // pagefile object bd($pagefile, 'pagefile'); // name of the field uploading to {your 'course_file'} bd($pagefile->field->name, 'field pagefile is part of'); // file-sanitized name of the file we've added, e.g. 'checklist_install.pdf' bd($pagefile->basename, 'name of added file'); // full disk path where the file has been uploaded in this page's files folder... //... in /site/assets/files/1234 where 1234 is this page's ID // ... e.g. "F:/www/mysite/site/assets/files/1234/checklist_install.pdf" bd($pagefile->filename, 'full disk path name of added file'); // $pagefile->page: The Page object that this file is part of bd($pagefile->page->id, 'id of the page file added to'); // full disk path to your custom uploads directory $customDirectory = $this->wire('config')->paths->assets . 'custom_directory/'; bd($customDirectory,'custom directory for files'); # copy file // use ProcessWire's $files API // @see: http://processwire.com/api/ref/files/ $files = $this->wire('files'); // copy the file(s) $files->copy($pagefile->filename,$customDirectory . $pagefile->basename); });