Jump to content


  • Posts

  • Joined

  • Last visited

Profile Information

  • Location
    Stuttgart, Germany

Recent Profile Visitors

1,092 profile views

rash's Achievements

Full Member

Full Member (4/6)



  1. @BillH Meanwhile the hook is working. All data is collected in one textarea that I’ve set to hidden. It still is a workaround in the sense of not going the direct way, but it does what I wanted to achieve without any noise or bad smell, so I would call it an excellent solution. Means: my efforts on searching for something different declined dramatically. Here is the complete hook – less for you as the "inventor", but for others that may get stuck at the same point. I keep the code in /site/templates/admin.php as it is admin related only, but /site/ready.php would work as well. <?php $wire->addHookAfter("Pages::saveReady", function($event) { $page = $event->arguments(0); $page->of(FALSE); // disable page formatting $cache = ""; // string collecting the single fragments if ($page->template == "invoice" || $page->template == "standard") { // blocks is a Repeater Matrix field with the types item and text foreach($page->blocks as $block) { if ($block->type == "item") { $cache .= $block->title." "; $cache .= $block->body." "; } else if ($block->type == "text") { $cache .= $block->body." "; } } // notes is a direct child of $page $cache .= $page->notes." "; } else if ($page->template == "customer") { // cust_base is of (pro) field type Combo, it stores data different // from Repeater Matrix fields but shares a similar syntax $cache .= $page->cust_base->street." "; $cache .= $page->cust_base->city." "; $cache .= $page->cust_base->shorthand." "; $cache .= $page->cust_base->phone." "; $cache .= $page->cust_base->email." "; $cache .= $page->notes." "; } else if ($page->template == "contact") { // cust_contact is a Combo field too $cache .= $page->cust_contact->prename." "; $cache .= $page->cust_contact->surname." "; $cache .= $page->cust_contact->phone." "; $cache .= $page->cust_contact->email." "; $cache .= $page->notes." "; } // searchcache is a simple Textarea field that can be included // as a searchable source in Modules/Core/ProcessPageSearch $page->searchcache = $cache; }); ?>
  2. I am happy too! Though I don't understand why the typecasting didn’t work, (int) "40000" (or intval("40000")) should result in 40000, not 0. Strange …
  3. The most simple way to achieve that is to call a detail page (based on a detail template) and specify the news item with a get parameter like so: <p><a href="/newsdetail/?newsid=<?= $item->id; ?>">read more</a></p> In this case, your detail template would contain only the logic to receive an id and render the markup for $item with the given id. If you don’t like get parameters, you could alternatively use form submits instead of <a href> and send the ids as post variables.
  4. You still didn’t reveal your results. Could you do something like that to see the four values and their according types? $raised = $page->get("raisedAmount$count"); $goal = $page->get("goalAmount$count"); $goalNum = (int) $goal; $raisedNum = (int) $raised; echo $raised; echo gettype($raised); echo $goal; echo gettype($goal); echo $goalNum; echo gettype($goalNum); echo $raisedNum; echo gettype($raisedNum); Normally it shouldn't be much of a problem to divide two integers in PHP, so I suspect it to be slightly more hidden.
  5. Ah, okay, I see. It was a bit confusing without knowing the context. But what values/types exactly do you get after typecasting $goal and $raised? Did you try intval($val) instead of (int) $val?
  6. What are raisedAmount$count and goalAmount$count you’re getting with $page->get? Fields that contain a dollar sign? Or is $count supposed to be a subfield of raisedAmount/goalAmount ? I’ve never seen a construction like that with dollar signs in, usually you do $page->field or $page->get('field') and field names cannot contain dollar signs, as far as I know. So what are the results of those two get calls if any and what are their types when you ask for gettype($goal) or gettype($goalNum)?
  7. I agree with your problem assessment and know the repeater.field construction from several front end searches/selectors. It’s probably a limit of dragging and dropping fields instead of setting up selectors manually. As fields inside a repeater stay ordinary fields with sort of a virtual framework around them, the field select lists only the basic fields without any knowledge of their repeater context. (If I remember it correctly, there is a similar limitation at FormBuilder’s drag & drop field mapping.) Your first solution proposal sounds very interesting, though I’ve never even recognized the existence of the field type Cache before. So I did what you suggested and got pretty excited, but only until I tried to include my astonishing new Cache field to the search list: it’s not offered as an option. Obviously the select is restricted to text and textarea fields with no exception. As long as I don’t find anything better, I will solve it with your proposal #2. It might not be the most elegant thing on earth, but definitely a sturdy workaround and therefore a very good idea. Thanks a lot for it!
  8. Thanks for yor reply @BillH, while it didn’t help me in a direct way, it did so indirectly. If A works on B but not on C, it’s a good idea to investigate the differences between B and C. Although I don't know your environment, I found one thing I suspected to be possibly specific and this first trial already brought the little devil on stage: all included fields reside in Repeater Matrix fields. As soon as I take them out and keep them as fields of the page itself, everything is running smooth. So I redefine my question: Is it possible to include text or textarea fields of Repeater Matrix fields into the admin search scope? (I guess the problem will be the same with simple Repeater fields.)
  9. Hi guys, I tried to customize the admin search by adding more fields to be searched, following this older thread. Modules/Core/ProcessPageSearch promised to be an easy thing, as you just select the (text/textarea) fields you want to include. Sadly, content in this additional fields doesn’t get found at all. I cleaned the module cache, saved a few test pages etc. but there’s nothing found beside text in the title field. Am I missing something?
  10. Yes, it does for me here too. Started to work immediately after I eliminated a typing error in my template name. (In fact I didn’t assume one second you would post non-working code, but was pretty sure the problem is located in front of my display.) So another big thanks, that was very instructive.
  11. Thanks a lot for you help, @Robin S – at least your first proposal ist working, while the alternative with Pages::saveReady doesn’t. Actually the loop problem is quite obvious, so shame on me for not detecting it myself, my brain sometimes seems to be somehow blocked. Anyway, just to consolidate the new enlightening: when I do $page->setAndSave("field", $value) before Pages::saved everything is fine. That’s because I’m saving field values whereas locking a page saves no field value but the page itself and therefore causes the loop. Is that correct? Nevertheless would it be interesting to understand why your alternative isn’t working.
  12. Hi all, I’m trying to lock a page before or after save if a field has one of two specific values. Sounds easy, but keeps me busy since hours. My hook: $wire->addHookAfter("Pages::saved", function($event) { $page = $event->arguments(0); if ($page->template == "invoice") { $page->of(FALSE); // lock page if inv_status = paid (1034) or cancelled (1038) if ($page->inv_status == 1034 || $page->inv_status == 1038) { $page->setAndSave("status", "locked"); // result: page gets locked, but I receive 'Service Unavailable' // I also tried this with the same result // $page->addStatus("locked"); // $page->save(); } } }); The page gets locked but I receive this notorious 'Service Unavailable' message that starts to bore me a bit. Tried several other variants with identical results, the same goes for firing the hook before instead of after. Maybe it’s illogical to lock a page and save this status change immediately after, but when I don’t save the change, of course nothing at all happens.
  13. Hi @netcarver, the combination of installation salt and password reset finally let me log in. The rest is easy though annoying work, but stupidity needs at least mild punishment. Thanks a lot for your help!
  14. Hi all, due to pure stupidity I managed to delete the complete root directory of a site without having a backup. [ short break to shake head, rofl etc. ] Luckily the database still exists and so do nearly 100 percent of the site directory. My first thought was to simply make a fresh install and change config.php data to use the existing database. Unfortunately the backend keeps me out and suspects whatever to be 'forged'. I guess it has to do with $config->userAuthSalt and/or $config->tableSalt. So is there any chance to connect a fresh install with an existing database? That would at least save me a few hours.
  15. @horst: Thanks a lot, that was very helpful. First I lost overview a bit, then I found this older thread with you being involved too, that brought the final kick. Now this is working fine: $img_url = "https://example.com/index.php?cust=foo&id=1234&filename=d9b88153-89e4.jpg"; $img_query = parse_url($img_url, PHP_URL_QUERY); parse_str($img_query, $params); $filename = $params["filename"]; // result: d9b88153-89e4.jpg $page->of(FALSE); $page->imgs->add($img_url); // add image to multi-image field $imgs $page->save("imgs"); // save added image with unwanted name index.php // w/o trackChange() file seems to get renamed in file system but not in db $page->imgs->trackChange("basename"); // eq(0) is the right image in my case, other selectors are possible $image = $page->imgs->eq(0); $image->removeVariations(); // delete variations (thumbnails etc.) $image->rename($filename); // rename index.php to d9b88153-89e4.jpg $page->save("imgs"); // save changes to $imgs field I’m pretty glad to have that annoyance solved, so thank you very much once more. PS: The mess in the dumps above resulted from a typo in deleteAll() before saving the new image, so more than one image was saved.
  • Create New...