Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

14 Good

About joe_g

  • Rank
    Sr. Member

Recent Profile Visitors

4,115 profile views
  1. Yes, that's one way - but slow. Four words would be a lot of searches, then some PageArray gymnastics to remove duplicates...
  2. When doing an OR search like text~=A|B|C This gives results that contains just "A", as well as "A B C". The results gets ordered in whatever manner they are ordered in the CMS, unless specifically sorted on a field. What I want, however, is to show the results that contain "A B C" first, then the results that contain "A C", "B C", "A B" afterwards, and then finally the results that contain only "A", or "B" or "C" possible? Thanks! Bonus points for being able to de-emphasize filler words like "my", "if", etc. But I realize this might be a bit too advanced?
  3. Yeah, I can see how things leans towards twig and similar. What I run into with twig and the likes is lots of small annoying exceptions: Like, I have to do something with the second last item in a list, for example. My sites are usually quite simple, mostly pulling stuff from the API and showing it. So there isn't enough actual 'logic' to warrant MVC, only simpler "layout logic" (like re-order, truncate, etc). This is why I'm mourning the loss of the (to me) perfect solution of <?foreach():?> One confusing thing is that quite a lot of hosts still allow shorttags with php 7+, just not all..... I'm sure there is a discussion somewhere about shorttags, but it seems it's not 100% consensus that they need to go. But I should probably just get used to some MVC templating 🙂
  4. Yes, it's not finished. My point is the syntax. I'm looking for a way to avoid having html inside php. In other words avoid this $imgOrCount = '<img src="'. $project->iconimage->size(800,800,['upscaling'=>false, 'cropping'=>false]). '">'; for me personally, this way of writing makes it a bit harder to spot errors (like forgetting a ", or similar). It's just that <?php foreach($projects as $project):?> is a lot less readable than <?foreach($projects as $project):?> if you write a lot of this type of statements
  5. I'm currently doing this. But it makes my eyes bleeeeed. On top of that, sublime can't handle the tabulation properly with this syntax 😮 <div class="projects"> <?php foreach($projects as $project):?> <div class="project"> <?php if($project->iconimage):?> <?php $thumb = $project->iconimage->size(800,800,['upscaling'=>false, 'cropping'=>false]); ?> <img src="<?=$thumb->url?>"> <?php else:?> <?php $total = count($pages->get('/missingimages')->missingimages); ?> <img src="<?=$thumb->url?>"> <?php endif;?> </div> <?php endforeach;?> </div>
  6. Hi everyone, I just wanted to see what your opinions were on this matter. I'm a big fan of php's template syntax: <?foreach():?> <?endforeach?> It produces nice HTML highlighting. I've notices that some hosting companies removing the support for short tags while upgrading to PHP 7. This makes the template syntax a lot less attractive. What do you use? Am I stuck in the past? Should I just use twig? thank you, j
  7. thanks! yes indeed — very sharp-eyed — that seemed to be causing the problem. not sure i understand fully what you mean with created and saved vs. added. But the created date is used on purpose so that it only happens once.
  8. Hi there, I have the following hook that loops through and overloads a date. It's a template type book page. This page also has the field image. My problem is, with this code I need to save the book page twice for an image thumbnail to be generated - even there is no mentioning of the image field in the code. (I need to press publish, then save). If I only press "publish" once, the 'book' page will not get an image thumbnail. In some way the code below cancels the image generation for this page, but I can't figure out why - or how it's connected..? $pages->addHookAfter('saveReady', function($event) { $p = $event->arguments(0); if($p->template->name == 'book') { $lastcreated = $parent->lastcreated; if($p->created > $lastcreated) { $p->parent->lastcreated = $p->created; } $p->parent->save(); } });
  9. Hi, is there a way I can do something like? $p->find->('sort=-children:eq(0).created,limit='.$limit); In other words, sort by the first childs value of a field. thanks, J
  10. Interesting! times is a repeater with "startdate" (date) "enddate" (date) and "occasion" (string). My function above loops through them to get the earliest start date and latest enddate, and store them in the parent page event, The clients adds a bunch of times (repeater), saves the "event", and then the times are gone. They would have to enter the times again. Now after testing a bunch of times, it does seem to relate to required field: If i skip the required startdate, create 3 times, and press save one of the times was missing. But this only happened twice, then not at all when trying to 10 times more ! Strange, but not the end of the world. But it does seem that the required error message does affect saving a bit.....
  11. tx I'll try that and see if it helps!
  12. Hi there, I have "events" with lots of children "times", to make some queries possible, I copy the earliest / latest time-child into the parent event with this code: This works MOST of the time (99.9%), but the client has been complaining for a long time that this sometimes fails. I've been quite a lot with trying to reproduce the error with no luck. It's maybe because I don't know exactly how hooks work. So, my question is, is this a safe way to do this? Or is it a bad idea to modify a page while saving, like this? $time->startdate is mandatory, but the enddate isn't. Thats why I copy startdate to enddate, if enddate is empty. thanks! $pages->addHook('saveReady', function($event) { $p = $event->arguments(0); if($p->template->name == 'event') { $p->of(false); $enddate = 0; $startdate = 2147483646; foreach($p->times as $time) { if(!$time->enddate) { $time->enddate = $time->startdate; } if($time->enddate > $enddate) $enddate = $time->enddate; if($time->startdate < $startdate) $startdate = $time->startdate; } $p->enddate = $enddate; $p->startdate = $startdate; } });
  13. So I ran into this peculiarity: If I put this piece of code at the end of my 'util.php' (included first on my head.php) — then things work: <? function totallyRandomFunctionName() { /* wire('pages');*/ } ?> Note how wire('pages') is commented out, but it still somehow does the job. Now, if I remove the commented line: <? function totallyRandomFunctionName() { } ?> Then I get this error earlier in util.php, suddenly the wire function isn't existing...: Uncaught Error: Call to undefined function wire() in /xx/util.php:86 Line 86 has: "wire('config')->urls->root" in it. I'm quite curious what goes on here!
  14. "Page::addable", that is what I was looking for - thank you.
  • Create New...