Soma

Moderators
  • Content count

    6,612
  • Joined

  • Last visited

  • Days Won

    154

Soma last won the day on January 23

Soma had the most liked content!

Community Reputation

6,245 Excellent

2 Followers

About Soma

  • Rank
    Dreamer
  • Birthday 03/31/1975

Contact Methods

  • Website URL
    http://soma.urlich.ch

Profile Information

  • Gender
    Male
  • Location
    SH, Switzerland

Recent Profile Visitors

35,561 profile views
  1. I wonder why you need something like this in the first place "to have at least one date". wire()->addHookBefore('Pages::trash', null, 'hookTrashDelete'); wire()->addHookBefore('Pages::delete', null, 'hookTrashDelete'); function hookTrashDelete($event) { $page = $event->arguments("page"); //prevent deletion of last child $preventTpls = [ 'single-date', 'single-event', 'single-business-vacation', 'single-special-business-hours' ]; if(in_array($page->template, $preventTpls)) { preventDeleteDateEntry($event, $page); } } function preventDeleteDateEntry($event, $page){ if($page->parent->numChildren() === 1) { $event->replace = true; // now original function won't be called wire()->warning(__("Deleting of the last date is not allowed. There must be at least 1 date.")); } else { wire()->message(__("1 date was deleted.")); } } I would code it like this. So the hook could be used for different things. Also some code formatting for better reading. Use $page->numChildren(), in case you have thousands/millions of children you'd get a server out of memory Don't use $event->return = error.
  2. https://processwire.com/api/ref/input/page-num/
  3. What's the difference? Pagetable are pages that are edited in the modal. Your screenshot in OP doesn't show a pagetable btw.
  4. I can't reproduce and it works flawless in pw2.7.2 float. Whether , or . PW handles it. Locale is important only for Date strings and Number formats. So unless you use strftime() to print "Montag, 1. April 2018" it can be ignored.
  5. Yes, you just have to make sure the hook doesn't loop into nirvana. That's one way yes, but maybe the ID isn't always there. It's not so much a problem that the hook get's called multiple times if you restrict it via the template or something else (ie a $this->skip flag you set to true) but maybe some code in there gets executed still, like your message idk. It depends a lot what you do and possibly trigger in your hook. I found myself often tracking and trying to figure out what's going wrong for hours and hours, which is not fun at all. Sometimes it's a side effect or even possibly a bug you never know.
  6. Well look into that translation to see the locale.
  7. I mean you hook into save and you create pages that you save triggering the hook again and again and again.
  8. It most likely the locale setting in the de language pack that affects numbers. There was once a fix I thought around that time.
  9. In my case this works all normal. Message is shown not matter what I do. But I wonder how your complete code looks like. For example you can't just create pages in a saveReady hook without handling the endless recursion you will get. It would give a 500 server error. Also creating and deleting pages could be something as the message session flash could get cleared out on something. My experience is once you get down that rabbit hole with lots of hooks on saved or especially saveReady it can get very hard to find the issue. Chances are we can't help you without having the whole thing and sitting in front. Edit: aka we don't even know what PW version you're using.
  10. ProCache, Apache *hugahuga*.
  11. We have it in use for years now on a very large site 400'000+ pages, no obvious issues so far.
  12. Yes is normal. _init.php the page is already rendering and the APi vars are extracted.
  13. I don't think you want to have 'show_root' => true, There's no root to show if you add a $entries PageArray. It's only for if you add 1 root page to the navigation options
  14. There's no option for this. There's some jquery code I posted to do this client side. https://processwire.com/talk/topic/1036-markupsimplenavigation/?page=22&tab=comments#comment-139794
  15. There's no image ID, but the page ID plus the image name are unique. Also you code example works fine. You could use a <img src="xxx/some.jpg" data-pageid="1001" data-imageid="some.jpg"> Then you know which page and image it is. $image = $pages->get(pageid)->images->get("name=imageid"); No need for extras fields or hooks.