Jump to content

kongondo

PW-Moderators
  • Posts

    7,529
  • Joined

  • Last visited

  • Days Won

    161

Everything posted by kongondo

  1. My bad...The child page has to be deleted first: $page = $this->wire('pages')->get(1234); $pages = $this->wire('pages'); $repeaterID = $this->wire('fields')->get('eventpricerepeater')->id; // this is the 'repeater_field_name' page $repeaterPage = $pages->get("parent.name=repeaters, name=for-field-$repeaterID"); foreach ($page->children("include=all") as $child) { $id = $child->id; // first delete the child page $child->delete(); // this is the 'name_of_page_with_repeater' $childRepeaterPage = $repeaterPage->child("name=for-page-$id"); // will also delete the repeate item pages, e.g. the '1234567890' if($childRepeaterPage->id) $pages->delete($childRepeaterPage, true); }
  2. Hi @workdreamer. Welcome to ProcessWire and the forums . You are right. Very bad practice to add/remove from the core . To override any core methods you use Hooks (as long as the method you want to override is hookable). There is an example here regarding Templates: And all about Hooks:
  3. I have re-read your post and I see where we went wrong. Each field has only one repeater page. Its child pages are the parents of the repeater items. Using true in the delete deletes the repeater parent page and its children. That's what my code would do. However, you want to delete only the children. So... Repeaters Hierarchy admin Repeaters repeater_field_name name_of_page_with_repeater 1234567890// repeater item #1 on "name_of_page_with_repeater" 1346798941// repeater item #2 You want to delete 'name_of_page_with_repeater' AND NOT the page 'repeater_field_name' The below (untested) should work (@see amended code in post below...$child has to be deleted first) $page = $this->wire('pages')->get(1234); $pages = $this->wire('pages'); $repeaterID = $this->wire('fields')->get('eventpricerepeater')->id; // this is the 'repeater_field_name' page $repeaterPage = $pages->get("parent.name=repeaters, name=for-field-$repeaterID"); foreach ($page->children("include=all") as $child) { // this is the 'name_of_page_with_repeater' $childRepeaterPage = $repeaterPage->child("name=for-page-{$child->id}"); // will also delete the repeate item pages, e.g. the '1234567890' if($childRepeaterPage->id) $pages->delete($childRepeaterPage, true); $child->delete(); }
  4. Repeaters pages need to be deleted a bit differently // delete repeater page: admin/repeaters/for-field-xxx $repeaterID = $fields->get('name_of_repeater_field')->id; // make sure you get the right repeater page $repeaterPage = $pages->get("parent.name=repeaters, name=for-field-$repeaterID"); if($repeaterPage->id) $pages->delete($repeaterPage, true); Regarding the error, not sure why you are getting it, but you can check like this: if($parent && $parent->id) { }
  5. $out = strip_tags($page->body); echo $out; strip_tags is one way to do it. I'm not sure about performance on a large body of text though. Maybe regex would be faster, I don't know
  6. Exactly. The more reason you should start migrating
  7. Yes, it's still true today (that's PW 3.x). If you can though, I'd urge you to migrate to PDO
  8. Checks if you already have an image in that image field. If count returns something, it means there's an image in the field already. It presupposes you've never added more than one image before. If its empty, you can add an image, if not empty, do something else. This is near-pseudo code so things can be changed around...Edited the code above for clarity
  9. if($page->template == 'one-image-template') { if(!count($page->multi_image_field)) { // add image, none added yet } } else { // add as many images as you like }
  10. This works for me $c = $page->child;// page here is the parent page //$repeaterItems = $page->repeater_test;// repeater with 6 fields (email, file, integer, text, single image, multi-images) x 2 repeater items //$c->repeater_test->import($repeaterItems);// alternative import $c->repeater_test->import($page->repeater_test);// import (into an existing repeater field in the child page) $c->of(false); $c->save('repeater_test');
  11. Hmm...or maybe import will be easier/faster?
  12. Edit @see post below...Use import instead! (duh!, early morning!) ------------------------------------------- The process then would be: Create the child page The child page's template should have the repeater field ready to receive items Add a repeater item(s) to the child page. See this (using API to add repeater items)....getting values from the parent page Maybe there's a different way of doing this....not sure...yes...import!
  13. Are you adding to a repeater field or a normal field? My code was for a normal field. If copying from REPEATER to REPEATER...then check out this thread
  14. More than a year later..... From the docs $building = $page->buildings->first(); // or whatever item you want to remove $page->buildings->remove($building); $page->save();
  15. If earlybookingdeadline is not an array itself, then this should work $k->earlybookingdeadline = $repeateritem->earlybookingdeadline;// earlybookingdeadline NOT an array; it just returns a value
  16. Or you, the module author, can click to edit the module and save (no need to make changes), and PW will fetch the latest version immediately.
  17. Yeah, ta. But that means I can't use System Notifications. It reverts to the old notifications. It also means that I need to tell users of my module to have that setting off (Leave them alone) if they want to see notices in modals. Not great. Anyway, thanks guys. Currently, I am using a custom jQuery solution to show notices in modals....but still curious why System Notifications is turned off in modals
  18. Benjamin, how please? I can't seem to find that setting.
  19. Hmm..I wonder what the reason behind that is.
  20. Yep...That was it. System Notifications notices don't show up when in a modal. The 'normal/older' notifications show up OK in a modal.
  21. I need to test with the older/original PW notifications then. See below for test with the 'new' System Notifications module: Normal window notices show up OK; modal window ones do not show up at all.
  22. Hmm. They've never showed up for me. What I want is for notices to show up as normal when I save, regardless of whether I am in a modal or a normal window. When I save any page in a modal (e.g. try editing a page in Batcher or a post in Blog) or when I edit and save any custom module page (e.g. some settings page in Media Manager) in a modal and call $this->message() or $this->error(), they never get shown.
  23. Media Manager version 009 (released 16/12/2016) Happy to announce the latest release of Media Manager. Changelog Filter Profiles: Feature enables configuring of various media filter interfaces (similar to ListerPro). This feature was requested here. Please see otes below Filter Profiles Usage To use the so-called Filter Profiles feature, you will first have to enable it in your settings (see images below). Head over to any media view. You will see a 'config' tab next to the Filters tab. Click on it. It will open a modal Create your profiles (one at a time). These are added to a table in that modal view. Click on the title of a filter profile to configure it's filters. Moves to 'single filter profile edit view' Set a filter as active by selecting it in the dropdown at the top of the modal view (#2) To delete one or more filter profiles, click their trash icon and save (there's a checkbox to confirm action) Close the modal. The Media Manager Library will reset and if you set an active filter in #5, your Media will be filtered according to your settings Currently, any user can create filters. Depending on your feedback, this might change. We might also add other features, e.g. locking down filters so they cannot be deleted. OK, that's it from Media Manager for this year. Hope it's been fun! Thanks.
  24. Welcome to ProcessWire and the forums @vvanasperen . A theme, in the sense you describe it, is a so-called 'site-profile'. We don't really have themes in ProcessWire. Personally, I think a great place to start is reading the docs, the basics. My motto would be I can make it all nice and shiny (theme) later, once I get to know the basics. If you already have a PHP background, great, you will be quite comfortable. If not, you will need to learn a few PHP basics in order to use ProcessWire, Here's a couple of docs to get you started: https://processwire.com/docs/tutorials/ http://processwire.com/api/variables/page/ : must know http://processwire.com/api/variables/pages/ : must know Sorry, typing in a hurry...but others will chime in am sure.
×
×
  • Create New...