Jump to content

alexcapes

Members
  • Posts

    120
  • Joined

  • Last visited

Everything posted by alexcapes

  1. Ryan, thanks for the quick answer. If I add in your updates to /wire/modules/Page/PageFrontEdit/PageFrontEdit.js and then add this to my JS: $(document).on('pwreloaded', function() { console.log("reloaded"); }); Nothing appears in the console when I save edits on the front-end. Any ideas on where it's going wrong?
  2. Hi, I'm using the excellent new front-end editing in PW 3.0.30 on a new project. I have a slick carousel that contains editable content. I'm able to edit the content in the slideshow fine but when I save, the page shows without the carousel initialized. Is it therefore possible to reinitialize something like slick after saving in front-end editing?
  3. Amazing! I got there with some minor updates to LostKobrakai's code... $start_val = (($input->pageNum * $limit) - $limit); $matches->setStart($start_val); $matches->setTotal($matches->count); $matches->setLimit($limit); $matches_limit = $matches->slice($start_val, $limit); Created a variable $start_val for the start value and updated the sum to -$limit value. I created a variable called $matches_limit for displaying the search results, as I can't put slice() into the pagination renderPager(). The slice() uses the $start_val to correctly get the pages for each paginated results page too. Thanks as always LostKobrakai.
  4. Thanks LostKobrakai, that works! However I do need to paginate the results and using slice() breaks the Processwire pagination. Any ideas on how pagination can work with a solution?
  5. Hi, I have an array of Page IDs ($matches) which I'm using in a PageArray ($matches_limit): $matches_limit = $pages->find("id=$matches, limit=$page_limit"); This is working fine but I need to maintain the sort order of $matches, however $matches_limit reorders the $matches (I guess to sort=sort). Is it possible somehow to maintain the order $matches when outputted in the pagearray?
  6. This is been resolved by the tech team that look after the servers. The issue was one of incorrect file permissions on assets/files.
  7. Hi, I have a bug that has seemingly popped up out of nowhere. On some pages in admin when I try to edit, they return an error "The process returned no content." I've checked the exceptions log and this is the error there: DirectoryIterator::__construct(/data/www/**domain-omitted**/site/assets/files/34935/): failed to open dir: No such file or directory (in /wire/core/Pageimages.php line 100) I'm a bit at a loss as to why this is happening. I've checked and the folders the pages are looking for do not correspond with the images on the page. (Note that the pages are displaying fine on the front-end). Can anyone help shed light on this error and why it might have appeared? **Update** It's more serious that I thought, when I try to create new pages I get the same error: "The process returned no content." Any help would be massively appreciated.
  8. Looking back at my code I did exactly what you suggest here and made the video field required.
  9. 1. Would you mind pointing me to the process of reporting bugs? 2. Good point although from what I remember (it was a while ago!) it was needed tobe required so the client didn't publish without an image. 3. Noted on this as a better approach. 4. The module was for a specific client who uploads videos in HD only so I was pretty confident no video would be without maxresdefault.jpg.
  10. Hi, Just added some 'Language-alternate fields' to a page fieldtype and I'm seeing the language displayed twice in admin under the field name... Is this a bug? I'm running 2.7.2 and the fields are set to 'Multiple pages (PageArray)'.
  11. Ahh hah! Lighbulb moment, thanks @LostKobrakai! I also located a bit of info in an old post from Ryan... "Both the trash() and restore() functions are triggered by $pages->save() when it detects that the parent has changed to or from the trash" In that post he says you can use this to check if a page has moved... if($page->parentPrevious Also checking if it is in trash makes sense too.
  12. I have a simple module that creates a page when another page is saved with a checkbox field checked. My code below works well but I have one issue, it runs when the page is trashed as well as saved (creating an erroneous second duplication of the page). <? public function init() { $this->pages->addHookAfter('save', $this, 'dupeStandalone'); } public function dupeStandalone($event) { $page = $event->arguments[0]; if($page->template->name == "article_language" && $page->article_standalone == 1) { $a = new Page(); $a->template = 'article_standalone'; $a->parent = wire('pages')->get('/article/'); $a->name = $page->name; $a->title = "{$page->title} (standalone placeholder post for {$page->parent->parent->title}-only article)"; $a->save(); } } Could anyone help as to why it runs the function on trash as well as save?
  13. Nope, there was no field called 'published' previously and no warning of any conflicts when I upgraded. Could it be something to do with the hosting environment? PHP version? etc?
  14. Hi, I've just upgraded a site from 2.6.1 to 2.7 and have noticed that the 'published' date does not seem to be working on new content I publish. Under the settings tab the info looks like this: Published on [?] If I try to output the date anywhere it comes out as: 1970-01-01 01:00:00 Does anyone know why this may not be outputting correctly?
  15. Hi, I have a small module I created that copies across field content from one page to multiple other pages. I just added a repeater field and while it copies across to the other pages it has caused timeout/memory issues with PHP. I think this is because of the multiple fields within the repeater (title, text caption, image) each being copied multiple times. I thought one way to help would be to not copy images across as they're not needed in the other pages. However I'm unable to figure out how to copy a repeater field excluding one field within the repeater itself. This is my current code: // Inline gallery 1 if(count($page->article_inline_gallery_1)) { $translation->of(false); $translation->article_inline_gallery_1->removeAll(); $gallery = $page->article_inline_gallery_1; foreach($gallery as $item) { $translation->article_inline_gallery_1->import($item); $translation->save("article_inline_gallery_1"); } } At the point that each repeater imported as a whole ->import($item) could anyone help to exclude one of the fields within the repeater?
  16. Wonderfully simple solution - thank you LostKobrakai! For anyone interested this was my final code - all working correctly: $list = $page->siblings("content_type!=6,sort=article_publish_date"); $prevPage = $list->getPrev($page); $nextPage = $list->getNext($page); if($prevPage) echo "<i class='icon-chevron-left'></i> <a href='{$prevPage->url}'>" . ${'previous_'.$countryCode} . "</a>"; if($nextPage) echo "<a href='{$nextPage->url}'>" . ${'next_'.$countryCode} . "</a> <i class='icon-chevron-right'></i>";
  17. . @dannymHAA talking artificial intelligence and the singularity for screening of #exmachina on the roof of @mcann_ww http://t.co/BRQw7MJqLE

  18. Hi all, I have the following simple code for next/previous links on article pages: <!-- Next article --> <?if($page->next->id) { ?><i class="icon-chevron-left"></i> <a href="<?echo $page->next->url; ?>"> <?=${'previous_'.$countryCode}; ?></a><? } ?> <!-- /Next article --> <!-- Previous article --> <?if($page->prev->id) { ?> <a href="<?echo $page->prev->url; ?>"><?=${'next_'.$countryCode}; ?></a> <i class="icon-chevron-right"></i> <? } ?> <!-- /Previous article --> It all works correctly but there's a certain type of article I need to exclude from the next/previous links (any page that has options field 'content_type' with a value of '6'). I'm trying to figure out a way to get 'next' and 'previous' but if 'content_type' on that page has a value of '6' then skip it. Can anyone help with some clues on how this might be done? I've had a look at using the pagination code as well as looking at grabbing 'siblings' and filtering them but come to a dead end. Thanks!
  19. I think you're right here - removed any saving from the module itself and the image still saves correctly. ... and added 'saveReady' instead of 'save' but it's still throwing up the 'Missing required field' error.
  20. No worries and thank you for your help Was trying to work out if I needed to be calling the wire function but can't see that's a solution (or at least I can't see where it would be required). Just to be clear the module is working correctly, it's just that Processwire is throwing a 'Missing required field' error even though the field is not missing (the image has been correctly uploaded). It's probably something I could live with but the client will definitely get confused by the incorrect error.
  21. Hi cstevensjr, apologies would you mind explaining where my module could be helped with the info posted by Horst on the above link?
  22. $page->article_visual_snippet->add("path or URL to image") also works but Missing required value error still appears after the page has saved and the image is in the field. Thanks for reminder of this - I always seem to forget that this outputting formatting changes things to multi-field value.
  23. I have made the following module that automatically grabs images from Youtube and Vimeo URLs and adds them to an image field ('article_visual_snippet'). public function init() { $this->pages->addHookBefore('save', $this, 'getvideoimage'); } public function getvideoimage($event) { $page = $event->arguments[0]; $url = $page->article_snippet_video; if ($page->parent_id == 1023) { if (strpos($url, 'youtube') > 0) { parse_str( parse_url( $url, PHP_URL_QUERY ), $id ); $ytURL = 'http://img.youtube.com/vi/' . $id['v'] . '/maxresdefault.jpg'; if($page->article_visual_snippet->count() < 1){ $page->of(false); $page->article_visual_snippet = 'http://img.youtube.com/vi/' . $id['v'] . '/maxresdefault.jpg'; $page->save(); } } if (strpos($url, 'vimeo') > 0) { $id = substr( parse_url( $url, PHP_URL_PATH ), $id ); if($page->article_visual_snippet->count() < 1){ $page->of(false); $response = file_get_contents("https://vimeo.com/api/oembed.json?url=https%3A//vimeo.com$id"); $jsonobj = json_decode($response); $page->article_visual_snippet = $jsonobj->thumbnail_url; $page->save(); } } } } } It's all working perfectly but for one slight problem. The image field ('article_visual_snippet') is a required field and when the page is saved I get 'Missing required value' error even though the image has successfully uploaded to the field. Does anyone know how I can circumvent this error?
×
×
  • Create New...