Jump to content

Robin S

Members
  • Posts

    5,009
  • Joined

  • Days Won

    333

Everything posted by Robin S

  1. Thanks @gebeer, I will definitely check out those parts of the PW code. I need to do more testing and will post back when I do, but based on some quick tests it seemed that the strtotime way was producing correct results while the native PW relative date was producing incorrect results. I do have the right timezone set in my config though.
  2. It's cool to be able to use relative times in selectors like: post_date>='90 minutes ago' But for debugging purposes I'd like to be able to get the timestamp that '90 minutes ago' actually results in. How can I do that? I thought it would be the same as PHP's strtotime, but in a selector: post_date>='90 minutes ago' Produces different results to: $mytime = strtotime('90 minutes ago'); ... post_date>=$mytime
  3. Currently you're getting your top-level menu items with: $pa = $homepage->children; Try changing to a find selector. If there is some common attribute of the pages you want for the footer menu (template, value of a field, etc) you could use that to exclude the pages, otherwise you'll need to exclude them by name or id. $pa = $pages->find("parent=1, id!=1050|1051|1052"); Edit: just noticed that you have added a checkbox to select pages for the footer nav. So you can do: $footer_nav = $pages->find("parent=1, footer_checkbox=1"); $main_nav = $pages->find("parent=1, footer_checkbox!=1");
  4. The demo shows an "insert paragraph here" feature when you hover on the bottom of the div. Not sure if that's part of the div plugin or a different plugin you'd need to install.
  5. There is a CKEditor plugin that looks like it's designed for what you want: http://ckeditor.com/addon/div You can try it out in the demo, third toolbar row.
  6. I think this is the problematic step. CKEditor can't know that you want to wrap these selected elements in a new element. Try creating an empty paragraph (maybe with a space or temporary character in it), select and apply the "Box" style, then cut and paste your paragraphs into it. You're probably aware of this already: it will be easier to see your box element if you add some styles for .box in your CKEditor "contents.css".
  7. Found some helpful discussion related to this issue here. The value of the inputfield must be set to a Pageimages object for an existing page. By default $page is used (which isn't what is wanted for this example) but it can be changed to a different page. In the context of Soma's gist the fix is to add the following at the end of the "success" section: $form->get("myimages")->attr("value", new Pageimages($uploadpage)); So the complete success section is if(!count($form->getErrors())){ // if no error occured // create new page and save values $uploadpage = new Page(); $uploadpage->template = "upload-entry"; $uploadpage->parent = $pages->get("/upload-api/"); // add title/name and make it unique with time and uniqid $uploadpage->title = date("d-m-Y H:i:s") . " - " . uniqid(); $uploadpage->addStatus(Page::statusUnpublished); $uploadpage->save(); // save uploaded files to new page and remove temp files $files = explode("|",$form->get("myimages")->value); foreach($files as $file){ if($file && file_exists($upload_path . $file)){ $uploadpage->myimages->add($upload_path . $file); unlink($upload_path . $file); } } $uploadpage->save(); $form->get("myimages")->attr("value", new Pageimages($uploadpage)); $sent = true; // or better do a redirect here before showing thank you text. }
  8. I'm trying Soma's gist for uploading a file from the frontend using the core File inputfield. After submit the file uploads just fine and I get the success message, but I also get an error when the form is re-rendered. Warning: filemtime(): stat failed for .../site/assets/files/1228/test-image.jpg in ...\wire\core\Pagefile.php on line 324 I believe the inputfield is trying to display information relating to the previously uploaded file, like it does in Admin. The reason this file can't be found at that location is because page 1228 is the page where the form is, whereas the file has been inserted into a different page. There's a line in the gist that looks like it's intended to solve this: // reset value before rendering the form again to prevent PW errors trying render files (as in admin) $form->get("myimages")->value = ''; // reset field value But maybe this isn't the right way to reset the value of a File inputfield? Edit: actually, the form isn't re-rendered on a successful submit, so not sure what is causing the submitted file to be looked for in this wrong location.
  9. Ahh, right. I was meaning the file I have auto-prepending to my templates, which I happen to have called init.php. I should have been clearer.
  10. Are you sure that's true? Good to know if it is, but tried testing it by putting die() in my init.php and admin is unaffected.
  11. Thanks. Probably the easiest thing for me is to put: $user->of(true); in my templates' auto-prepended init.php and then I can use the field consistently across $user and $page. (edited for clarity) Some of Ryan's comments in the old thread you linked to make it sound like having output formatting off for the user template is deliberate, but then the docs say and which make it sound like $user should be essentially the same as $page and will have outputting formatting on by default.
  12. Just struck this also. @Chris is right about the source of the problem... $storage->parent = $this->pages->get('/admin/'); ...should instead be... $storage->parent = $this->pages->get(2); Making the change above does allow the module to be installed but first you have to delete the fhStorage template from the failed installation attempt. And this isn't straightforward because the system flag is set, and can only be removed via the API. To do this... $t = $templates->get("fhStorage"); $t->flags = Template::flagSystemOverride; $t->flags = 0; $t->save(); Then the template may be deleted via the Admin (or the API).
  13. I have added an image field "avatar" to the user template. The field settings are "Maximum files: 1", "Formatted value: Single items (null if empty)". So I believe I should be able to get the URL of this image in my template with $user->avatar->url But this returns /site/assets/files/1217/ If I add the avatar field to any other template besides the User template I can get the URL as expected. For the user template if I use $user->avatar->first->url I get the URL okay. So it's like image fields added to the User template don't honour the "Formatted value" setting. Has anyone else experienced this? If so I guess it's bug and I'll file an issue on Github. Edit: If I get a specific User page it works normally $pages(1217)->avatar->url So it's just an issue when trying to get the image from the User object. Is this difference from the Page object likely to be intentional?
  14. Answered recently here.
  15. I believe I have sendmail set up correctly in my localhost environment, and I can send mail fine with WireMail like: wireMail('my@email.com', 'some@email.com', 'Message Subject', 'Message Body'); But when attempting to use the core "forgot password" feature WireMail throws an error: Invalid email address (processwire@myvirtualhost) Is there a config option to set this default "from" address to something that is better formed?
  16. @bernhard Just wanted to say thanks for this module. I prefer it to the Helper Field Links module because the link doesn't create any extra space in the inputfield, which is useful when setting the layout of inputfields as I see almost the same interface as site editors will see. Cheers!
  17. Another way you could do this (code style may not be to your taste): <?php $pagesWithImages = $pages->find("filter_image!=''"); ?> <?php foreach($pagesWithImages as $p): ?> <?php foreach($p->filter_image as $filter): ?> <div class="filter-box" style="background-image: url(<?= $filter->url ?>);"> <div class="uk-overlay uk-overlay-hover uk-position-cover"> <div class="uk-overlay-panel uk-position-cover uk-overlay-background uk-overlay-fade uk-flex uk-flex-center uk-flex-middle"> <a class="hover-btn" href="<?= $p->url ?>"><?= $filter->description ?></a> </div> </div> </div> <?php endforeach; ?> <?php endforeach; ?
  18. I'm don't follow exactly what you're wanting to do. For instance, child's parent's children is the same as just children and "new" and "before" is ambiguous. But maybe this works... $johns_comments = $pages->find("template=comment, comment_username=John"); $comments_after_johns = new PageArray; foreach($johns_comments as $j_comment) { $comments_after_johns->add($j_comment->nextAll); } Not tested.
  19. @netcarver That's perfect, thanks. Getting the full URL using API methods only is surprisingly long-winded. This is the best I could manage: $full_url = $page->url; if($input->urlSegmentsStr) { $full_url .= $input->urlSegmentsStr . "/"; } if($input->pageNum > 1) { $full_url .= $config->pageNumUrlPrefix . $input->pageNum; }
  20. @adrian Thanks, but $page->httpUrl doesn't include url segments or page numbers.
  21. Is there an API method that gives the complete URL of the currently viewed page as it is known to PW? So not including any hashes or other URL changes that might have been made by Javascript (PW can't know about those) but basically $page->url + any url segments + any page numbers. Or does this have to be built manually from the other $input methods?
  22. Just used this excellent suggestion and thought I might as well post some code here. $upcoming_events = $pages->find("template=event, event_date>=today, sort=event_date"); $prev_event_month = ""; foreach($upcoming_events as $upcoming_event) { $month = date("F", $upcoming_event->getUnformatted("event_date")); if($month !== $prev_event_month) { echo "<h2>{$month}</h2>"; } echo "<h3>{$upcoming_event->title}</h3>"; // more event markup here $prev_event_month = $month; }
  23. Ryan, you're a legend! Reviewing all that documentation must have been an enormous job. Having up-to-date docs is just so valuable to the PW community so a big thank you for this!
  24. Not sure what you mean; $tagless_images are your images without tags, for images with tags you use: $mytag_images = $page->images->findTag('mytag'); Count does not belong in your if expression: ->has() returns true or false so it doesn't make sense to count it.
  25. Not sure of the cause of that error but if your PW version is >= 2.6.9 you could try the setAndSave method and see if that works.
×
×
  • Create New...