Jump to content

Jonathan Lahijani

Members
  • Posts

    631
  • Joined

  • Last visited

  • Days Won

    23

Everything posted by Jonathan Lahijani

  1. Add this to the array: 'currentLinkMarkup' => "<a class='page-link' href='{url}'>{out}</a>",
  2. Yea, it's going to create a lot of database tables. I don't see how any Profields would help in this scenario either. I suppose a custom field would be optimal, although I've never had to create one in my 4+ years with PW. But optimal might be a relative word... 100 questions might still be manageable? Also, one thing to be careful about is if you remove a question (as in remove the field from the template), it will delete any saved data associated with it, which you may need to keep. Maybe hiding it (but still keeping it assigned to the template) would be an alternative approach to preserve data.
  3. The sort box will go back to the default/first option, unless you program some basic logic to make it selected. Something like this should work: <?php $sort = $input->get->string('sort'); // sanitize url variable shorthand ?> <select name="sort"> <option value=""></option> <option value="title" <?php if($sort=="title"): ?>selected<?php endif; ?>>Title (Asc)</option> <option value="-title" <?php if($sort=="-title"): ?>selected<?php endif; ?>>Title (Desc)</option> <option value="price" <?php if($sort=="price"): ?>selected<?php endif; ?>>Price (Asc)</option> <option value="-price" <?php if($sort=="-price"): ?>selected<?php endif; ?>>Price (Desc)</option> </select>
  4. Are they filling out this form on the frontend of your site or through some sort of protected backend? If frontend, are you building the form using FormBuilder, the PW Form API, or custom? How many questions are there? If it's like 10-50, that means another 10-50 extra fields for the "Comments" fields related to the question field as you stated. Why not just make those individual fields in ProcessWire (assuming I understand your question correctly)?
  5. Try doubling the values above? How long does it take to upload 400mb on your server?
  6. When you changed the settings in php.ini, did they in fact apply? You might want to double check by outputting phpinfo().
  7. I have a site that I oftentimes sync the live database to my dev database (I made a bash script to automate the process). I generally like to "clean" the database once it has been copied over to my dev machine, which involves running a script that deletes 15,000 pages (orders in my case), among other things. Doing this using $page->delete() in a script (which I'm running through the command line for added performance), takes about 30 minutes which is painful. I thought it through further and I came up with the following relatively simple script that can achieve the same result in a few seconds! It achieves this speed by running MySQL delete queries directly, bypassing PW's API. Here it is (modify accordingly): <?php namespace ProcessWire; ?> <?php include(dirname(__FILE__).'/index.php'); // bootstrap pw $order_ids = $pages->findIDs('parent=/orders/,template=order'); if(!count($order_ids)) exit; $order_ids = implode(",", $order_ids); $t = $templates->get("order"); foreach($t->fields as $f) { if( $f->type!="FieldtypeFieldsetOpen" && $f->type!="FieldtypeFieldsetClose" ) { $table = "field_".$f->name; $database->query("DELETE FROM $table WHERE pages_id IN ($order_ids)"); } } $database->query("DELETE FROM pages WHERE id IN ($order_ids)");
  8. Thanks Robin, this worked well and avoids the approach of having to hack PW and make InputfieldPage::getPageLabel hookable. Note: In order for it to work, you must edit the field's "Label field" under the "Input" tab. It must be changed from "title (default)" to "Custom format (multiple fields) ..." and a value must be put in the "Custom page label format" field, even if it's just a temp value (I put "x").
  9. Looks like CKEditor 5 is on the way: https://ckeditor.com/blog/CKEditor-5-A-new-era-for-rich-text-editing/ https://news.ycombinator.com/item?id=15497972 (HackerNews comments of the above article) Home page: https://ckeditor.com/ Demo: https://ckeditor5.github.io/ Feature Video:
  10. If a client is dead-set on WordPress, it's worth communicating to them that every developer has their own go-to approach with the system, to the point where I would say it's not even "WordPress" anymore. So even if another developer were to take over it, it's still foreign territory to an extent, followed up with continuously saying "why the hell did the previous developer do things in X way instead of Y?" and a lack of productivity. Just check out all the starter themes, mega themes (ugh... ... ... ugh), and different approaches to custom fields. It's pretty terrible. For me, ProcessWire + UIkit solves like 95% of my challenges, and solves them WELL.
  11. I have a script that deletes a bunch of pages and it's very slow too, but I'm not sure if it's normal or if something's wrong. In addition, I'm running it from Bash. Did you have any luck with improving the speed?
  12. I have a Page Reference field (ASM Select) and I am utilizing the "Custom Format" for the "Label field". However even the custom format itself is a bit limiting for a particular use case I have. Is it possible to hook into it and modify the output cleanly with PHP? I can't seem to find a proper hook. Somewhat related... it's possible to do this for the Tree page labels via ProcessPageListRender::getPageLabel.
  13. I just hit this same issue as well. My resolution was to break up my script into two separate files (first one deletes a bunch of pages, second one adds a bunch).
  14. https://deliciousbrains.com/craft-cms-self-hosted-wordpress-alternatives/ This article came out today. Delicious Brains is known for some popular plugins. I dropped a reference to PW in the comments. Perhaps others here can add to the discussion.
  15. Ryan has a habit of developing features we didn't even know we needed!
  16. +1 for WSL. It works wonderfully and has a lot of resources behind it. Getting better all the time.
  17. Atomic Design: http://bradfrost.com/blog/post/atomic-web-design/
  18. I tested out the new version and it works really well. Thanks @Robin S.
  19. Shouldn't it actually be this? $form->insertAfter($field, $form->getChildByName('tags'));
  20. Yea there's a trade-off here. Personally, I think inserting the IDs is the best route since IDs do not change (while text does). Unless there's a really fancy way to satisfy both needs through some sort of richer CKEditor widget?
  21. When making a new booking, you have the 'room' dropdown (well perhaps it should be "Rooms" since one customer may be able to book more than one room) as I described, however you obviously don't want to a room to be double-booked, meaning that dopdown should only show available/unbooked rooms. You can determine that by writing a custom query for that ASM-select field (using PW's Custom PHP Code feature). I think the selector would be something like (well you'd need to finish it off and also make it handle whether the current booking has a room selected): // this will find all the unbooked rooms of the selected boat $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->name == 'rooms') { $booking = $this->pages->get($this->input->id); $cruise = $booking->cruise; $boat = $cruise->boat; $allRooms = $boat->children; $availableRooms = new PageArray(); foreach($allRooms as $room) { if( ! $this->pages->count("write query here to determine if the room has been booked") ) { $availableRooms->add($room); } } $event->return = $availableRooms; } }); Hope this helps.
  22. Sounds like you would want to handle 5 data types: boats rooms cruises customers bookings A boat I'm assuming has a fixed number of rooms. Perhaps start with a data model like this which takes everything into consideration: Boats (boats.php) Boat A (boat.php) Room 1 (room.php) Room 2 Room 3 ... Boat B Room 1 Room 2 ... Customers (customers.php) Customer 1 (customer.php) Customer 2 ... Bookings (bookings.php) Booking 1 (booking.php) Booking 2 ... Cruises (cruises.php) Cruise 1 (cruise.php) Cruise 2 ... Cruise template fields: title date boat (page-select to /boats/, boat.php) Customer template fields: first name last name (other typical fields) Cruise template fields: title boat (page-select to /boats/, boat.php) date Booking template fields: customer (page-select to /customers/, customer.php) cruise (page-select to /cruise/, cruise.php) rooms (based on cruise->boat, select for the rooms that the boat has) I'm assuming the interface would be PW's admin. Perhaps use some hooks and ListerPro to tie it all together. Make it as user-friendly as possible. Maybe have a page within the admin outputs each cruise with which rooms have been booked vs. unbooked which would be friendly to the site admins.
  23. To what extent are you storing a customer's information as part of booking a room? Or do you simply just need to indicate whether a room is taken?
  24. The page exporter/importer sounds very exciting. I think it would be pretty slick if you can choose access the export/import action from within the page tree itself (next to the new, edit, view etc. page action buttons). I'm also curious to know how merging would occur and the options around it. Can't wait!
  25. Let's say you're doing a redirect like this in your template: $session->redirect( $pages->get("/some-page/")->url ); Would halting be good practice after redirecting or does it not make a difference? return $this->halt(); It wasn't clear in the blog post that introduced halting: https://processwire.com/blog/posts/processwire-2.6.8-brings-new-version-of-reno-admin-theme-and-more/#new-this-gt-halt-method-for-use-in-template-files
×
×
  • Create New...