-
Posts
189 -
Joined
-
Last visited
-
Days Won
1
Everything posted by thomas
-
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()]
-
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
-
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
-
Thanks @rickI saw that. I now label all my templates "product" and use `$this->addTemplates(\Processwire\wire('templates')->find("tags=product"));`
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
Thanks! So it was no dream after all
-
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
-
Check if $user is logged in without renewing cookie
thomas replied to thomas's topic in API & Templates
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 -
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
-
Best/fastest way to find all pages in a selections page field?
thomas replied to thomas's topic in General Support
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 ... -
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.
-
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
-
Saving form with data from AJAX (outputFormatting terror!)
thomas replied to thomas's topic in General Support
Thanks Kongondo, I put of(false) almost everywhere now and most of it seems to work. I still need to catch a few fieldtypes in order to get the right info out of them but I'm getting there. Thanks, thomas -
I have a site with lots of templates neatly ordered with tags in the admin. Now whenever I create a new template I have a hard time finding it, since there is no tag. So I'd like to see the ability to add tags to a new template right when I create it. Thanks, thomas
- 1 reply
-
- 1
-
You need to include a bunch of admin JS and CSS files. If you are determined to do this, take a look at /wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module, especially the AJAX save bit. But I would recommend using another upload script, like http://getuikit.com/docs/upload.html to build this instead of trying to reverse-engineer the whole back end.
-
The method InputfieldPage::getSelectablePages needs to know the page you are editing. This seems to be wrong and it is probably Fredi's fault since you are getting "his" ID. Try disabling Fredi and see if it works. Otherwise you can try to Hook before InputfieldPage::getSelectablePages and make sure it sees the right page $event->arguments(0, $page_you_want); I hope this helps.
-
Hello, I am trying to build a form which is saved via AJAX, containing text fields, selects and checkboxes. No matter what I do, I can't get rid of the error "Call $page->setOutputFormatting(false) before getting/setting values that will be modified and saved." The problem is mostly with data coming from selects. I compared my Ajax data with the post data from a regular form submit and afaict it matches. My special case right now is for two selects from inputfieldPage ("year" and "schaltgruppe_kurbel"), each configured to hold only one page. The form sends single values (page ids) and the error is thrown. I tried converting all single values to arrays with one element, but no success. This is my script to save the data. It runs in a module: $prod = $this->pages->get($this->id); $prod->of(false); # this doesn't really make a difference but it's here. $form = $this->modules->get('InputfieldForm'); $fields = $prod->getInputfields(); foreach($fields as $f) $form->append($f); $form->processInput($this->input->post); foreach($form as $f) $prod->set($f->name, $f->value); $prod->save(); # ERROR Can anyone help? I'm really stuck here ... Thanks, thomas PS I also tried leaving out the PW admin specific stuff like processInput and set the input data directly, but no change ...
-
It works! Thanks a lot! Vielen Dank!
-
Hello, I want to use two page fields, the first one to choose the selectable pages of another pages field. When the first Page Field (category) is selected, the second one appears (using category != "" which works fine). Now the second Page Field is supposed to show only the pages with the category (a field in the second selections template) selected in the first field. I used this as a custom selector: parent=/products/,category=category,sort=title Now this does not work. Am I doing something wrong or is this not supposed to work? Are there any ways to achieve this? (parent /products/ has a view thousand children so I need some sort of pre-selection) Thanks, thomas *Edit*: custom PHP code return $pages->find("parent=/produkte/,category=$page->category"); works, but the page needs to be saved first and it's not really dynamic ... I was hoping for a better solution ...