Jump to content

thomas

Members
  • Posts

    196
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by thomas

  1. Hi everyone, I have a site which uses a bunch of images per page and now I am about to change the template. Problem is that the first call of those pages takes forever since it creates all image variants. Is there a method to iterate over all those pages and create the images or would I have to create a hook for that? Problem is that the actual size of those images is calculated individually in the template so I would either have to duplicate the logic in this hook or parse the templates which I wouldn't know how ... Anyone got an idea? Thanks!
  2. Hi, I want to regex-replace terms with are stored in a simple text filed within a TinyMCE textarea value. Now I found that TinyMCE seems to encode entities differently than $sanitizer->entities() does. German "Umlaute" öäüÜÖÄ are encoded, but $sanitizer encodes quotes while TinyMCE doesn't. Is there a way to match the two encodings for reliable regex-replaces? Thanks $text = preg_replace("/(^|\s|>)".wire("sanitizer")->entities($member->title)."(\s|,|\.)/",'${1}<a href="'.$member->url.'">'.$member->title.'</a>${2}',$text); ^^ This successfully replaces names with umlauts like "Günter" but fails on people with nicknames like Jake "The Snake" 😉
  3. Hi @BrendonKoz, thanks for reply! I tried exactly the same syntax but unfortunately that didn't work. I am working on a full text searchable archive of old special interest magazines where I just need an image per page, a large text field for the OCR'd text and maybe some tags. Meanwhile I stumbled upon the amazing plugin "RepeaterImages" by @Robin S which looks like it might just solve my problem 🙂
  4. Hi, I was wondering if it was possible to search in the custom field of multiple images? I am not really sure what I would expect for a result but I guess I am looking for a way to search for images by the description in a custom text field (it needs to hold a lot of text) and deep link to that very image. A quick test showed no result but maybe I am missing something? (I know a page reference would obviously be the better choice here but I kinda want/need the thumbnail display and visual sortability of the multiple image field) Thanks
  5. Thanks! I changed it to this and added the Javascript src to my package. Works fine but isn't really the proper way to use a ProcessWire Module I suppose. Let's hope @joshua fixes this 🙂 updateAllowedElementOther(el) { const { dataset } = el; el.type = dataset.type ?? "text/javascript"; ["src", "srcset", "srcdoc", "poster"].forEach((k) => { if (dataset[k] !== undefined) { el[k] = dataset[k]; } }); this.removeUnusedAttributesFromElement(el); }
  6. Hi @joshua, I am getting the following error while trying to implement cookie consent for a Youtube iFrame: Uncaught TypeError: "text/javascript".poster is undefined What am I doing wrong? I tried both Ryan's TextFormatterVideoEmbed and manually adding all the attributes. All works fine but the src of the iframe is never resolved which I guess is due to the error above. Any help is appreciated thanks Edit: I am pretty sure this is caused by an error/missing semicolon in the PrivacyWire JS. Not sure how this works for anyone??
  7. Hello, please excuse if this has been discussed before. I was wondering if I can sort a pages array by the admin sort order of items in a pages field? Explanation: I have several pages which all have one category attached to it (in a single item pages field). These categories are sorted in a specific way in the backend. I would now like to sort the pages so the ones from the first category show up first etc. I would really like to avoid splitting things up and iterating over categories as well. Second option might be to add 1, 2, 3 or something to the category names and later strip it for display but I was wondering if there is a more ProcessWire-y way of doing this 🙂 This is what didn't work: $pages->find("template=members,sort=kategorie.sort,sort=title); * EDIT * It does work! Sorry! (Ican't find an option to delete this post ...) Thanks thomas
  8. Hi, I'm fighting with a weird problem here. I'm trying to build a mass mailer app with personalized HTML emails. The workflow is as follows: foreach($recipients as $to) { $this->wire->set('recipient_email', $to->email); $htmlBody = $nl->render(); $key = $sanitizer->pageName($to->email.$nl->id.time()); $cache->get($key); $cache->save($htmlBody); $sendArray[] = ['to'=>$to->email,'cache_key'=>$key]; } So the personalized HTML is written into a MarkupCache and the key written to an array. In the next step I send the cached HTML to each of the recipients. The Newsletter template itself has an "articles" Pagefield which references articles included in the newsletter. I use $first = $page->articles->shift(); for the first article and then iterate over the rest. When simply displaying the Newsletter Page via it's url everything works perfect. Now when using $page->render(); the $first PageObject returns errors ("Trying to get property of non-object") I tried explicitly setting output formatting (always on), but that doesn't help. If I remove the whole $first set, everything works fine. My only guess is that this has to do with $page->render(). Is there anything I need to know? Thanks, thomas [Turns out this was a problem with the foreach loop using render(). The error always occured after the 6th iteration. I now switched to a single render() and replace the dynamic parts using preg_replace_callback()]
  9. I would like to extend the Admin Save button with another SaveAction but can't figure it out: $this->addHookAfter("ProcessPageEdit::buildForm", $this, "editForm"); public function editForm(\Processwire\HookEvent $form) { $target = $form->get('submit_save'); $target->addActionValue('test','Test',''); $form->return = $form; } This gives me another small dropdown button with a single option. I only managed to add another button to the form (not quite as elegant but would do the job) but my question is if it is possible to use ProcessPageEdits processSave() method and add to it? I need a button that would save the page, add a message and return to a custom URL in the admin. Thanks! thomas
  10. Hi, I was wondering if there was an fast & easy method to find out if a logged in user is allowed to duplicate a given page (or create a page with the same template & parent). This should take into account the template settings and user permissions. Is there? Thanks, thomas
  11. Thanks @rickI saw that. I now label all my templates "product" and use `$this->addTemplates(\Processwire\wire('templates')->find("tags=product"));`
  12. Hi, I want to extend PagesType to get a new `Product $products` variable in the API. Problem is, I have about a million (well, about 50) different templates for the products so `addTemplates()` can be difficult. Without a template, `pagesType` throws notices (`Trying to get property of non-object in wire/core/PagesType.php on line 161`). Is there a way to extend `pagesType` without specifing templates or by specifying a template group? Thanks, thomas
  13. Strange update: $pdf->save(); shows the images, but $pdf->download(); doesn't. Not sure what's going on here but I can work around that. Thanks, thomas
  14. Hi @Wanze, i tried it all: <img src="<?=$mandant->teaserbild->first()->height('100')->url;?>" width="<?=$mandant->teaserbild->first()->height('100')->width;?>" height="100" alt="logo" /> // AND <img src="<?=$mandant->teaserbild->first()->height('100')->httpUrl;?>" width="<?=$mandant->teaserbild->first()->height('100')->width;?>" height="100" alt="logo" /> // AND ALSO $imagedata = file_get_contents($mandant->teaserbild->first()->height('100')->filename); $base64Img = "data:image/png;base64," . base64_encode($imagedata); <img src="<?=$base64Img;?>" width="<?=$mandant->teaserbild->first()->height('100')->width;?>" height="100" alt="logo" /> but nothing works. How do I enable debug mode (showImageErrors) for the pdf module? Thanks, thomas
  15. Hello @Wanze and everyone else, i'm trying to get pages2pdf with @apeisas Padloper. They way I want to use it is: $t = $this->modules->get("PadRender")->getPadTemplate("invoice.php"); # this simply returns a TemplateFile $t->set("order", $order); $pdf = $this->modules->get("WirePDF"); $pdf->pageOrientation = 'P'; $pdf->pageFormat = 'A4'; $pdf->markupMain = $t->render(); $pdf->save($this->config->paths->assets.'/pdf/'.$order->rechnungsnummer.'.pdf'); I'm having problems with the images in the template. Only a red "x" is displayed. I tried full httpUrl and even including the base64 data. No success. Can anyone help out? Thanks, thomas
  16. I am trying to use `showif` on a field accompanying an image field. It's supposed to only be present if an image was uploaded. So far, so easy. `image.count>0` does the trick. But when I open the page for editing, the field stays closed, even though an image was uploaded before. What am I missing? Thanks, thomas
  17. Ever since I updated Safari to 9.0.3 I'm seeing this strange issue that if you try to select text in a CKEditor field, the page scrolls down for as long as you hold the click. This is pretty annoying and since my editors insist on using Safari (why I don't know) I need to fix this. This doesn't happen on the official CKEditor demo page so I believe it might be something with the plug-in. Has anyone seen this issue? I actually have one page where this doesn't happen but I can't find a difference or any reason what could cause this ... Thanks, thomas
  18. Hello Wanze, I'm trying to use your module to send PDF invoices to customers of my store and I was wondering if it was possible to pass an object to the template similar to $template->set() works ...? Thanks, thomas
  19. Hello, I feel like I read somewhere that you can create a PageArray with a delimiter string ie "313|34|23|978" ... like the opposite of (string)PageArray ... I can't find it though ... maybe it was just a dream and I have to iterate ... Can anyone help? Thanks, thomas
  20. Hallo Horst, thanks, that was actually quite helpful! My app reads alot of (personal) data on start up and only polls PW when data is edited. That's why I'd like it to log out when it sits idle for a wile. I already thought about using a timestamp in a session so that's want i'll try to do. Thanks, thomas
  21. I'm building my first AngularJS app on top of Processwire and I was wondering how I could check if the user is still logged in and has the neccessary permissions without actually renewing the cookie lifetime? On manual logout I could pass some session variable but if the session simply runs out (like leaving the browser window open over night) I'd like to periodically check $user and re-route to a log-in page when the session expires, but this seems to renew the cookie ... Can anyone help? thanks, thomas
  22. Thanks Kobrakai, so this method Ryan suggests will give me a list of all "marke" pages that are selected somewhere in a page field, right? This would certainly help (I'd iterate over 200 "Marken" instead of 3400 Products). I'll try some more raw MySQL queries to narrow it down ...
  23. I think something like "find in" would be great $pages->find("PageField in Selector"); This would return a PageArray of the pages which are selected in the Pages found by the selector.
  24. Hello, I have a bunch of pages ("Products") containing a Page field ("Brand"). Those products are narrowed down by category and then paginated. I want to show all the brands included in the current selection of products. Is there a better way than loading the whole selection (normally I would only load the pagination) and foreach over it? The categories contain as much as 300 products so I fear loading the whole selection and foreaching just to get the brands will slow things down. Anyone got a hint for me? Thanks, thomas
×
×
  • Create New...