Jump to content

a-ok

Members
  • Posts

    812
  • Joined

  • Last visited

Everything posted by a-ok

  1. Is it possible to run PW from an IP address before pointing the domain name at the server? The front end seems to be working okay but when I try to log in it just refreshes the page... is it possible to run it from an IP address (added to config as host too).
  2. I managed to work this out by doing the following... might be useful for others. function eSubmissionImageToRepeater($event) { $page = $event->arguments(0); if ($page->template->name == 'events-detail') { // What's On detail if (count($page->flexible_content) <= 1 && $page->flexible_content->first()->type == 'text') { $featuredImage = $page->featured_image->first(); $flexibleContentRepeater = $page->flexible_content->getNew(); $flexibleContentRepeater->of(false); $flexibleContentRepeater->save(); $flexibleContentRepeater->repeater_matrix_type = 2; // Image(s) $flexibleContentRepeater->save(); $flexibleContentRepeater->flexible_content_images->add($featuredImage->httpUrl); $flexibleContentRepeater->save(); $flexibleContentRepeaterID = $flexibleContentRepeater->parent_id; $firstItem = $event->pages->find("parent_id=$flexibleContentRepeaterID")->first(); $lastItem = $event->pages->find("parent_id=$flexibleContentRepeaterID")->last(); $event->pages->insertBefore($lastItem, $firstItem); } } } if ($user->hasRole('e-submission')) { // Ony required for 'e-submissions' $wire->addHookAfter("Pages::save", null, "eSubmissionImageToRepeater"); }
  3. Anyone got any other ideas? This seems to work: $flexibleContentRepeater->flexible_content_images->add("https://i.stack.imgur.com/bn9pu.png"); But this doesn't (bd'ing $page->featured_image->httpUrl returns the correct full URL...) $flexibleContentRepeater->flexible_content_images->add($page->featured_image->httpUrl); EDIT I think it's due to the ->op(false) which makes the featured_image field an array and thus this works... $featuredImage = $page->featured_image->first();
  4. Thanks! I think you're right re saving the page... I've removed that. The output formatting addition hasn't solved this though; still a blank image field. Hmm...
  5. Hi folks, I'm wanting to take an Image field and add the same image as the first row of a RepeaterMatrix field. If RepeaterField field rows already exist, it should shift it to the first row, and if the image has already been added then it shouldn't re-add it. I guess I could double check the image URL on this to prevent this? Anyway, I thought this would work... it's adding in a RepeaterMatrix row of the requested type but the image isn't being added. function eSubmissionImageToRepeater($event) { $page = $event->arguments(0); if ($page->template->name == 'events-detail') { // What's On detail $flexibleContentRepeater = $page->flexible_content->getNew(); $flexibleContentRepeater->save(); $flexibleContentRepeater->repeater_matrix_type = 2; $flexibleContentRepeater->save(); $flexibleContentRepeater->flexible_content_images->add($page->featured_image->httpUrl); $flexibleContentRepeater->flexible_content_images->save(); $flexibleContentRepeater->save(); $page->save(); } } $wire->addHookAfter("Pages::save", null, "eSubmissionImageToRepeater"); Any help?
  6. I believe it's to do with the Admin Restrict Branch module... which is still odd that text works but I had to exclude Admin > Repeaters from the Restrict Branch and seems to work...
  7. Hi folks, I have a contributors specific role set up on PW which allows them to add and edit only their own page(s) to a parent page (Events > event) and have managed to do this by setting up specific template permissions but also include the following in my ready.php file (so they only see their own pages) function eSubmissionPermissions($event) { $page = $event->object; if (!$event->return) return; if ($page->template->name == "events-detail" && $event->user->id !== $page->createdUser->id) { $event->return = false; } else { $event->return = true; } } if ($user->hasRole('e-submission')) { // Ony required for 'e-submissions' $wire->addHookAfter("Page::listable", null, "eSubmissionPermissions"); } This all works fine but there's one issue. I have a RepeaterMatrix set up for flexible content and the user/role can add to this fine if the content is text but when they go to add an image it states 'You don't have access to edit' when adding the image. Is there anything extra I should be doing in order to allow this? They can add an image fine that isn't in the RepeaterMatrix. I am using PW 3.0.80. It's also maybe worth noting that I am not allowing this user to publish pages (only save them) as this will be done by the admin on successful admission.
  8. Is there a way, without editing the module itself, to change the font sizes set in the CKEditor for h1, h2, h3 etc. They're just too big in proportion to the rest of the text. I'd like to be able to do it without amending the module in case of any updates. Any thoughts?
  9. It may have to do with having AJAX set on the repeater.
  10. Hmm it's okay actually because I can just use the first row as the thead and then the rest can follow and I can style the first row accordingly. However upon adding the table to a repeater, when I try to add a row... it doesn't work. It's hashed in the URL when clicking so I'm guessing some JS isn't firing/is missing because it's in a repeater?
  11. I'm looking at using ProFields Table for a specific layout. An attached image as an example. The client should be able to add as many tables as they want, and as many table rows with the option to change the thead titles. My thought was to put a table in a repeater field and then use ProFields Table. This is generally okay but the only issue is that the table headers (theads) aren't fixed and need to be changed also. Any thoughts on changing the text for these? Thanks!
  12. Is there any documentation on turning an array into a WireArray? ->makeNew() doesn’t accept arrays.
  13. Thanks for this. I didn't know you convert it into a WireArray tbh. This is what I currently have, which seems okay, but when I come to thinking about pagination... not sure how that'll work (so maybe WireArray is best if I can work it out). I haven't included my Instagram API fetch stuff here... just the variable. $news = $pages->find('parent=/news/, sort=-created, limit=16')->explode(['id', 'created', 'title', 'url', 'images', 'summary_text']); $instagrams = $instagram->getInstagramRecent(); $items = array_merge($news, $instagrams['data']); bd($items); foreach ($items as $key => $item) { if (isset($item['user']['id']) && $item['user']['id'] == '1907645821') { // Instagram post $sort[$key] = $item['caption']['created_time']; } else { // News article $sort[$key] = $item['created']; } } array_multisort($sort, SORT_DESC, $items); bd($items); if (isset($item['user']['id']) && $item['user']['id'] == '1907645821') { // Instagram post $type = 'Instagram'; $title = NULL; $image = $item['images']['standard_resolution']['url']; $text = '<p class="instagram">' . $item['caption']['text'] . '</p>'; $link = $item['link']; } else { // News article $type = 'News'; $title = $item['title']; foreach($item['images'] as $img) { $itemImage = $img->url; break; } $image = $itemImage; $text = $item['summary_text']; $link = $item['url']; }
  14. Very nice! I guess this is the best way, right? PW API offers nothing related? Thank you!
  15. Is it possible to combine a pageArray with a regular PHP array? I'm returning a list of news items from PW, which is fine, but I'm also returning Instagram and Twitter posts, from API endpoint URLs (which is JSON but I have converted to PHP arrays) and I'd like to then ultimately import them all into one big array then sort by a custom date field (that I'll build and store per loop) so you get a list of news items, Instagram posts and tweets all sorted by date. Any thoughts on importing a pageArray and a regular PHP array? Should I be using $a->getArray(); then combining them? Thanks!
  16. I guess I could use $image->removeVariations() or even https://modules.processwire.com/modules/pageimage-remove-variations/
  17. This is all super helpful, Robin. I think that imageSizerOption setup is working now. Hero. Thank you. As I'd need to re-upload all these images again to get the new options... is there a good way to do this via the API?
  18. Another example. The blacks are very pixelated and fuzzy... even after setting sharpening to none, quality to 100 and default gamma to -1
  19. If you click on these images you'll see the difference. I'm also using this within my template: $image = $images->size(1600,800, ['upscaling' => true, 'cropping' => 'center', 'quality' => 100, 'sharpening' => 'none', 'defaultGamma' => -1]); // 2:1 I have now added the below to my config.php file instead of the above and reuploaded the image but it still shows the same quality/colour loss on the resized image. $config->imageSizerOptions['sharpening'] = 'none'; $config->imageSizerOptions['quality'] = 100; $config->imageSizerOptions['defaultGamma'] = -1;
  20. Sorry to bring this back up but I'm still fairly confused at how to resolve this. See attached two images. One is the original uploaded and one is the resized version. I've checked the colour profile and it seems to be sRGB. I'm basically hoping that resized images are resized only (cropped) and no colour changes happen. Any further thoughts?
  21. @Robin S This is a GREAT explanation and is super appreciated. I totally get it... and now understand that some things don't work with in-memory selectors (modifying a PageFinder, in theory) – again I really appreciate your explanation.
  22. Thanks again, Robin. I thought, based on this page, https://processwire.com/api/selectors/#or-groups, that I was just using the OR groups inside a find() Page/WireArray? Or am I getting confused? Why would it work when doing one find() and not find()->find() for example?
  23. Thanks, Robin. That makes sense! Now the issue I seem to be experiencing is (when only have a single modifying query) is using an OR query... For example... $events = $pages->find("template=events-detail, events_detail_dates_final_date>=today"); $results = $events->find("(events_detail_dates_upcoming_start_date<=today)"); OR $results = $events->find("(events_detail_dates_upcoming_start_date<=1517174937,events_detail_dates_upcoming_start_date<=1517097600)"); Seems to remove all the items (itemsRemoved when using Tracey Debugger). If I remove the parenthesis from the top modifier, for example, it works fine but obviously the parenthesis is required for the OR group. Any further thoughts?
  24. Thanks for this again, Robin. After looking at this I'm unsure if this is working... $events = $pages->find("template=events-detail, events_detail_dates_final_date>=$today"); $calendar = $this->input->post->calendar; $query = $this->input->post->query; $results = $events->add($events->find("{$query}, {$calendar}")); In this above example the $query could be the following (if upcoming start date is equal to or less than today) events_detail_dates_upcoming_start_date<=1517171596 What result this is returning is the 'filtered' pages to the bottom off the original $events query... this is why the filter() option was good because it was removing any items that didn't match it the filter... not adding it to the original query. Any thoughts?
×
×
  • Create New...