Jump to content

bernhard

Members
  • Posts

    5,719
  • Joined

  • Last visited

  • Days Won

    270

Community Answers

  1. bernhard's post in File Download tracking/counting was marked as the answer   
    If you are using Google analytics you could easily use it to track your downloads and have nice statistics and setup conversion goals and so on. You would only have to change your template code. No extra fields... easier than it may sound from the docs: https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide#setting-up-event-tracking
  2. bernhard's post in Set page title automatically was marked as the answer   
    hi robin,
    as simple as this: (put it in your /site/ready.php file and adjust to your needs)
    $this->pages->addHookAfter('added', function($event) { $page = $event->arguments[0]; if($page->template != 'your-template-name') return; $page->setAndSave('title', 'my page - ' . date("YmdHis")); }); set page name format for children to something like Y/m/d H:i:s and set title to locked
  3. bernhard's post in Are child pages inheritance the role access permission from it's parent page? was marked as the answer   
    On mobile... There is a setting in the admin (access tab)
    If you select 'Yes' you can define what roles have access to pages using this template. If you select 'No' then pages using this template will inherit access from their parent pages.
  4. bernhard's post in Problem with images->removeAll() - Bug? was marked as the answer   
    ah, of course that was the problem! i had a save() directly after the removeAll() but that didn't make any difference. but adrian got me on the right track:
    removeAll() save() createPDF() add() save() // early return when no valid page object if(!$page->id) return false; $page->of(false); $page->stickerpdf->removeAll(); $page->save('stickerpdf'); // get mpdf instance $pdf = $this->modules->get('WirePDF'); $mpdf = $pdf->mpdf; // filename for generated pdf $filename = 'sticker.pdf'; $path = wire('config')->paths->files . $page->id . '/'; $filename = $path.$filename; $mpdf->WriteFixedPosHTML( '<div style="font-size: 10pt;">TEST ' . date('H:i:s') . '</div>', 29, 53, 67, 1 ); $mpdf->Output($filename, 'F'); $page->stickerpdf->add($filename); $page->save('stickerpdf'); thank you both!
  5. bernhard's post in Bootstrap ProcessWire - fields not working like expected was marked as the answer   
    Hi henrik,
    this problem comes from the fact, that there is no outputformatting when bootstrapping PW. therefore image fields are always arrays even if they are set to max = 1 and all your textformatters won't work.
    https://processwire.com/talk/topic/5375-image-paths-when-bootstrapping-pw/
    regarding your ajax problem: you don't need to create a file outside your site folder! you have two options:
    1) create a separate template only for ajax requests and also a page for that (eg hidden page /ajax) - then you can just call this page and return your content
    2) return your ajax content from within the same file. if you are using delayed output strategy that's really easy. all you have to do is put something like this on top of your template file:
    if($config->ajax) { // do your ajax stuff here echo 'i am an ajax response'; die(); } // regular call $headline = '<h1>' . $page->title . '</h1>'; $content = $page->body; and so on... hope that helps! good luck
  6. bernhard's post in Delayed output and markup files was marked as the answer   
    Hi and welcome combicart! You can use "wirerenderfile" for that. On mobile, so please use Google. It's very easy and i use it in all my projects
  7. bernhard's post in wireRenderFile not returning string output was marked as the answer   
    please mark your topic as solved so that others can immediately see it - saves time

  8. bernhard's post in mpdf storing pdf to file system was marked as the answer   
    ok it works now - you were both right (as expected)  it was important to use the PATH to the file (thanks tpr, $config->paths->templates)
    $filename = $config->paths->templates . $page->parent->invoice_type . '_' . $page->invoice_num . '_' . $page->invoice_to->client_company . '_' . $page->invoice_to->client_forename . '_' . $page->invoice_to->client_surname . '.pdf'; $mpdf->Output($filename, 'F'); $page->of(false); $page->invoice_pdfs->add($filename); $page->save(); unlink($filename); $session->redirect($page->invoice_pdfs->last()->url); one more question: 
    i was not able to save the pdf to the assets folder, so i guess this is because of some security issues? how would i create files in a different folder above the current working directory? just curious
  9. bernhard's post in admin template was marked as the answer   
    hi hansv, welcome to processwire
    visit your site unter /admin/page
    go to setup > templates
    click on filters > show system templates > yes
    go to family > allowed templates for parents > unselect "admin"
    now you can select template "admin" for the page /admin
    then go to /admin > edit
    process: ProcessHome
    and then set family for admin template back to "admin" that you can't select it again
    hope that helps
  10. bernhard's post in How to handle reviews? was marked as the answer   
    hi mattcohen,
    welcome to the forum!
    your code looks like you have not yet fully understood what processwire is and can do for you to make your life easy the key to success is structuring your content, then you can easily access all your data by simple
    foreach ($page->children() as $review) { echo $review->title ... $review->body ... $review->rating ... and so on } maybe this is a good read for you: https://processwire.com/talk/topic/3579-tutorial-approaches-to-categorising-site-content/
    did you go through the hello world tutorial? https://processwire.com/docs/tutorials/hello-worlds/
  11. bernhard's post in Preventing Duplicates with Repeater was marked as the answer   
    hi lauren,
    don't know if it is working with repeater fields, sorry - but repeaters are out anyway i think the PageTable is exactly what you are looking for and you should definitely try out this great field that opens tons of opportunities!
    this topic is exactly for you: https://processwire.com/talk/topic/6866-page-field-in-pagetable/
    in this image from the thread above you see repeaters (top) compared to pagetable (bottom):

    see how much space you will save  btw: looks like page field should work with repeaters?!
    here you go

    you can automatically follow topics you replied to: https://processwire.com/talk/index.php?app=core&module=usercp&tab=core&area=notifications

  12. bernhard's post in How to work with include() in templates? was marked as the answer   
    hi totoff,
    using the TemplateFile class is perfect for this, have a look at ryans blog profile: https://github.com/ryancramerdesign/BlogProfile/blob/master/templates/archives.php#L101
    simple way: file "site/templates/markup/contact-markup.php" (naming it -markup here to point out the difference to the standard template file)
    John Doe<br> Sample Street 1<br> Sample City template file eg "site/templates/contact.php
    $contact = new TemplateFile(wire('config')->paths->templates . 'markup/contact-markup.php'); echo $contact->render(); // don't forget to echo! more flexible: with variables! markup/contact-markup.php
    <?= $name ?><br> <?= $address ?><br> <?= $city ?> contact.php
    $contact = new TemplateFile(wire('config')->paths->templates . 'markup/contact-markup.php'); $contact->set('name', 'john doe'); $contact->set('address', 'sample street'); $contact->set('zip', 'sample city'); echo $contact->render(); edit: in your case you can do $sidebar = $contact->render() instead of echoing it... forgot the point of delayed output 
×
×
  • Create New...