Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

80 Excellent

About a-ok

  • Rank
    Hero Member

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Ah okay. In my /ajax/ I am doing some server side stuff (adding the form data to a ProTable as we discussed) so this is why I was initially confused.
  2. I did think this. Need to try again shortly. I’m basically posting form data to a page /ajax/ which is returning wireSendFile() if it meets the right requirements. Would it work in this respect? I’m assuming so?
  3. Thanks 🙂 I'm trying to use it but getting some odd errors/returns. Been testing it directly in TracyDebugger's console and it doesn't download anything. Code has been failing for me all over the place today though; lockdown meltdown.
  4. I'm looking to try to use the Processwire API to download the file: $pressDownload = $pages->get(1078)->pressDownload->filename(); wireSendFile($pressDownload, array('forceDownload' => true, 'exit' => false)); Is this possible or do I need to use the PHP method as demonstrated by @MoritzLost?
  5. @MoritzLost Thank you! I really appreciate your help and advice here. This all sounds good. I'll begin!
  6. I'm a fan of FormBuilder, but it's a bit overkill for what I need to do. I'm looking to have a simple email and password form set on a page; the password would be tied to a field in the CMS. It would just be a plain text field. Upon submission a file would automatically download (file located on the same page where the plain text password is set) and then the email address and timestamp would be sent to an entries list (similar to FormBuilder's). My question is... how possible is this without FormBuilder? If I was to create an 'entries' list of the submitted data on a page in the CMS; what's the best field to hook into to allow for this? Repeater seems a bit over the top? PageTable? Exporting? Or would you just use the FormBuilder? Or is there a way to have a custom form but send the data to a form within FormBuilder? Any advice would be great.
  7. Turns out getNext() works on the pageField whereas next isn’t contextually aware (so it gets the next item in the parent rather than in the pageField)
  8. I'm attempting to set up a 'NEXT PROJECT' link which is based on which category a project is in; so depending if the user accesses the project directly, or from the category page, the 'NEXT PROJECT' link should be based on either the next project in general OR the next project in that category. Projects are all entered under one tree and categories on another then I'm using a pageField to connect them. My question. Is there a way to get the next item (or first if the current item is last) from the current project's position in the pageField? I can get the pageField from the category page (which has all the projects) but I'm struggling to work out how I can find the project's position in that pageField then return either the next or first project in the list. Any thoughts? I tried searching the pageField for the current project but then all that does it return the project as a page and not within the pageField. Thanks in advance.
  9. Would you just add at the bottom, or create a new section '5B' or something so it keeps everything tidy or avoid this so you know what is yours/PWs standard?
  10. Thanks very much for the help everyone. Hopefully this'll help others too so much appreciated. This is what I ended up with (went with @Robin S's solution in the end). MUCH appreciated help @BitPoet 🙂 // Add annotations as anchor options within text $wire->addHookBefore('ProcessPageEditLink::execute', function(HookEvent $event) { $page = wire('pages')->get(wire('input')->get('id')); if ($page->template->name !== 'projectsSingle') return; $input = $event->wire('input'); $anchors = $input->get->anchors ? : []; $annotations = array(); foreach ($page->textAnnotations as $key => $annotation) { $annotationClean = 'annotation-' . wire('sanitizer')->pageName($annotation->id); $annotations[$annotationClean] = $annotation->text; } $anchors = array_merge($anchors, array_keys($annotations)); $input->get->anchors = $anchors; // $event->wire()->addHookBefore('InputfieldSelect::render', function(HookEvent $event) use ($annotations) { $inputfield = $event->object; if ($inputfield->name !== 'link_page_anchor') return; $options = $inputfield->options; $inputfield->options = []; foreach ($options as $option) { $anchorName = ltrim($option, '#'); if (isset($annotations[$anchorName])) {; $inputfield->addOption($option, $annotations[$anchorName]); } else { $inputfield->addOption($option); } } }); });
  11. I want to add disabling of hot-linking for webfonts to the .htaccess file but I kinda don't want to 'mess' with the one that comes with PW. What would you suggest? Does anyone else do specific .htaccess additions without adjusting the original PW version? Or am I just being silly? RewriteEngine On # RewriteCond %{HTTP_REFERER} !^http(.?)://(.+\.)?yourdomain\.com/ [NC] # RewriteRule .*\.(woff|ttf|eot|svg|php)$ - [F] AddType application/vnd.ms-fontobject .eot AddType application/x-font-woff .woff AddType font/ttf .ttf AddType image/svg+xml .svg AddType text/css .css <FilesMatch "\.(woff|ttf|svg|eot|css)$"> <IfModule mod_headers.c> Header set Access-Control-Allow-Origin "*" </IfModule> </FilesMatch>
  12. I'm currently appending page names, with a specific template, with a date. This works fine but as I have multi-languages set up it only appears (unless my code is wrong) to be applying it to the default language page name. Any thoughts on where I'm going wrong? function customPageName(HookEvent $event) { $page = $event->arguments(0); if ($page->template->name == 'about-events-single') { $eventDate = date("dmY", $page->global_date_end); $pageName = wire()->sanitizer->pageName($page->title . '-' . $eventDate, true); $page->setOutputFormatting(false); $page->name = $pageName; } } wire()->addHookAfter('Pages::saveReady', null, 'customPageName');
  13. Thanks so much for the help, @BitPoet. One final thing. Is it possible to keep the value of the select option as it is but change the label? My annotations list read as `#annotation-1020`, for example, which is super useful for some JS stuff I'll be doing with it, but ideally, for the user, it would be good to have these options a bit more descriptive. Any idea? I know you can add a label within the `InputfieldSelect::addOption()` method but obviously as I'm updating the anchors before it runs this I can't amend it. https://github.com/processwire/processwire/blob/51629cdd5f381d3881133baf83e1bd2d9306f867/wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.module#L203 I guess having the option on this line to pass in a key/value (key would be the label) into the anchors array (otherwise label = null).
  • Create New...