Jump to content

picarica

Members
  • Posts

    71
  • Joined

  • Last visited

Everything posted by picarica

  1. So hello i have been using processwire for a while and the only consistent problem is with images, when i have large site with many images generating it sometimes takes 5-15 minutes, until we can see it, i tested it with site with 2 images, and it generated all variations withint 40 seconds, this includes, thumbnail variation, Large variaton (when opened) and also webp version of all images, and how can this take 40s on 24 threaded processor? i know php is singelthreaded but how is it this slow, barerly 8 images relatively small in size one is roughly 500kb original and is also downsized in processwire CMS so how can we speed this up? and arent we just using gd instead of imagemagick? how can we check this, i was also thinking can we somehow group all 24 thhreads into one, that way it would be faster, so that php used all 24 threads, can docker or something like that do that ? also attatching image of said issue, all threads resting just one maxed out,
  2. hello so i am trying to resize all image when uploading, or when saving, i tried so hard but i failed, i tried firstly when saving, to foreach every image and resize them down and then delete the old one Result? the newly generated image was blank, 0x0 0bytes , empty files i dont know why here is code to that <?php #$this->addHookBefore('Pages::saveReady', function(HookEvent $event) { $wire->addHookBefore("InputfieldFile::fileAdded", function(HookEvent $event) { // Get the object the event occurred on, if needed $pages = $event->object; // An 'after' hook can retrieve and/or modify the return value $return = $event->return; // Get values of arguments sent to hook (if needed) $page = $event->arguments(0); $event->return = $return; foreach($page->repeat_page as $repeat) { foreach($repeat->image_slider as $slider_i) { if ($slider_i->width > 1601 || $slider_i->height > 1601) { $slider_i_w = $slider_i->width; $slider_i_h = $slider_i->height; if ($slider_i_h > $slider_i_w) { $which = "height"; } if ($which == "height") { $slider_new = $slider_i->size(0,1600); } else { $slider_new = $slider_i->size(1600, 0); } $page->save(); //$repeat->image_slider->replace($slider_i->filename, $slider_new->filename); $repeat->image_slider->insertBefore($slider_new, $slider_i); $page->save(); //$repeat->image_slider = $slider_new->filename; $repeat->image_slider->delete($slider_i); $page->save(); } } foreach($page->repeat_page as $repeat) { } } $event->return = $return; }); ?> so this failed but it worked when the old one wasnt deleted, but only after saving second time, also failed to mention all field are in repeat field my next attempt was this wire()->addHookAfter('InputfieldFile::fileAdded', function($event) { $inputField = $event->object; $image = $event->argumentsByName('pagefile'); if ($inputField->name == 'image_slider') { // Do whatever you want with $image here $image->size(0, 1600, ['upscaling' => true]); } // Process other image fields here }); this also failed, infinite hang never completes not sure why? i dont understand hooks that much what am i doing wrong
  3. okay i solved it, but yes with that configuration next page button worked but i wasnt translated correctly to the ajax scrool, i fixed it by createing pagination with default settings
  4. Hello so i am loking for somehow to generate image variatoons before image visit, let me give u a scenario clinet makes new page in CMS adds tons of images and i in backend have $large = $image->size(1200, 0); $thumb = $image->size(0, 350); but none of us visit the page, so no variations are generated, but then when customer visits the pages only then the content is being generated, and it takes roughly about 1-2 minutes to generate 50 images, and customer doesnt want to wait that long, so i am asking if i can somehow pre-render this proccess without anyone visiting that current page
  5. So hello i tried using infinite ajax scroll in my website but it appended content that was already loaded before, so it just repeated itself,i am not sure why this is my js for the ajax scroll <script src="https://unpkg.com/@webcreate/infinite-ajax-scroll@^3.0.0-beta.6/dist/infinite-ajax-scroll.min.js"></script> <script> let ias = new InfiniteAjaxScroll('#grid-game', { item: '.GameTile.card.game', //next: document.getElementByClassName(".pagination").lastChild, next: '.pagination li:last-child', pagination: '.pagination' }); </script> and my pagination optionsa are $paginatioarr = array( 'nextItemClass' => "next", 'previousItemClass' => "prev", 'listMarkup' => "<ul class='pagination'>{out}</ul>", 'itemMarkup' => "<li>{out}</li>", 'currentItemClass' => "active", 'numPageLinks' => 3, 'nextItemLabel' => '>', 'previousItemLabel' => '<', ); now this pagination works flawlessly by itself but the infinite ajax scroll append the same page everytime? idk why HTML of pagination on page is simply <ul class="pagination"> <li> <a href="/"><span>1</span></a> </li> <li><a class="page active" href="/page2/">2</a></li> <li><a class="page active" href="/page3/">3</a></li> <li>…</li> <li><a class="page active" href="/page8/">8</a></li> <li><a class="page active" href="/page2/">&gt;</a></li> </ul> now idk why it has active on every pagination, but it works the last li, points to next page , it works when i click on it so i dont know what is the problem here maybe infinite ajax scroll log would be helpfull here Start loading undefined infinite-ajax-scroll.min.js:11:8776 Next page triggered [pageIndex=1] infinite-ajax-scroll.min.js:11:8695 Hit scroll threshold infinite-ajax-scroll.min.js:11:8525 Finished loading infinite-ajax-scroll.min.js:11:8831 Start appending items infinite-ajax-scroll.min.js:11:8882 Finished appending 35 item(s) infinite-ajax-scroll.min.js:11:8941 Page changed [pageIndex=1] infinite-ajax-scroll.min.js:11:9079 Start loading undefined infinite-ajax-scroll.min.js:11:8776 Next page triggered [pageIndex=2] infinite-ajax-scroll.min.js:11:8695 Hit scroll threshold infinite-ajax-scroll.min.js:11:8525 Finished loading infinite-ajax-scroll.min.js:11:8831 Start appending items infinite-ajax-scroll.min.js:11:8882 Finished appending 35 item(s) infinite-ajax-scroll.min.js:11:8941 Page changed [pageIndex=2] thanks for helping
  6. Hello so i am working on a hook and this hook should include setup, 1. have one or multiple zip files in one file field, Run 1. let hook unzip each file and input the unziped files into newly created page the problem, i wanted to use $files->tempDir() method in hook but i guess it't not hookalbe so i get error Undefined variable: files in at line $page->title = $files->tempDir(); i did this as test and it doesnt work, i whole setup looks like this $this->addHookAfter('Pages::saveReady', function(HookEvent $event) { // Get the object the event occurred on, if needed $pages = $event->object; // An 'after' hook can retrieve and/or modify the return value $return = $event->return; // Get values of arguments sent to hook (if needed) $page = $event->arguments(0); if(empty($page->id)) return; if($page->template == "generator") { foreach($page->multi_gen as $gen){ wireUnzipFile($gen->url, "my-file/"); if($this->pages->get("parent={$page->name}, name={$gen->basename}")->id) continue; $np = new Page(); $np->of(false); $np->template = $this->templates->get("hry_home"); // I changed the template name here too //$np->title = $tatel; $np->name = $np->title; // I wanted the page name to match the title $np->parent = $page; $np->save(); //$np->image->add($image->filename); //$np->image->last()->description = $image->description; //$np->save(); //// These lines work to remove the image from the parent page ////$page->images->remove($image); $page->save(); } } $event->return = $return; }); and i still haven passed the frist line containint wireunzipfile, is there any other way to do this? i ran out of ideas, now i know of that i can check in a file field that automaticaly unzipes files, the problem will be that when there will be alot of zip files, its gonna be confusing nad it will be harder to move exact files to the newly created page
  7. tried it maybe my processwire instalation broken? or it doesnt work when its in ready.php but this is all i have and it's not working <?php $this->addHookAfter('Pages::saveReady', function(HookEvent $event) { // Get the object the event occurred on, if needed $pages = $event->object; // An 'after' hook can retrieve and/or modify the return value $return = $event->return; // Get values of arguments sent to hook (if needed) $page = $event->arguments(0); $page->title = "test?"; // Populate back return value, if you have modified it $event->return = $return; }); ?>
  8. well u can check ill put all hooks i have, and the behavies is still the same, i crea page with temporary title ex. "ss" i upload .xml file then save, name update but title remains "ss" here is my whole hook <?php $this->addHookAfter('Pages::saveReady', function(HookEvent $event) { // Get the object the event occurred on, if needed $pages = $event->object; // An 'after' hook can retrieve and/or modify the return value $return = $event->return; // Get values of arguments sent to hook (if needed) $page = $event->arguments(0); // tento hook pojde len na jeden template if($page->template != 'hry_home') return; // pokail stranka este neni vytvorena (Nema ID) tak nepokracuj zo scriptom if(empty($page->id)) return; if(count($page->subor_hry) < 1) return; if (count($page->subor_hry) > 1) { // TENTO HOOK VHADZUJE TITLE URL A DESSCRIPTION Z XMLka VELMI NEBEZPECNE $page->size = strlen($page->body); if(strlen($page->body)){ //not empty } else { $meta = "meta.xml"; foreach($page->subor_hry as $file) { if(strpos($file, $meta) !== false){ $xmlmeta = file_get_contents($file->filename()); } } $desc = new SimpleXMLElement($xmlmeta); $page->body = $desc->description; // $page->size = '222'; } $meta = "meta.xml"; foreach($page->subor_hry as $file) { if(strpos($file, $meta) !== false){ $xmlmeta = file_get_contents($file->filename()); } } $desc = new SimpleXMLElement($xmlmeta); // Provides: Hll Wrld f PHP $onlyconsonants = str_replace($vowels, "", "Hello World of PHP"); $badstring = array(" (Flash Game)", "(Flash Game)", "(flash game)", " (flash game)", "flash game", " flash game"); $newtitle = str_replace($badstring, "", $desc->title); $page->title = $newtitle; $page->name = $newtitle; // TENTO HOOK VHADZUJE TITLE URL A DESSCRIPTION Z XMLka VELMI NEBEZPECNE // Zobrat obrazok zo file fieldu a hodit do imagetype fieldu $word = ".png"; foreach($page->subor_hry as $file) { if(strpos($file, $word) !== false){ $png = new Pageimage($page->images_thumb, $file->filename()); } } $word = ".jpg"; foreach($page->subor_hry as $file) { if(strpos($file, $word) !== false){ $jpg = new Pageimage($page->images_thumb, $file->filename()); } } if(empty($png)){ $page->images_thumb = $jpg; } else { $page->images_thumb = $png; } } // Populate back return value, if you have modified it $event->return = $return; }); ?> i have no idea too why it happens i tried putting the title rewrite out of if statements but remains same, i only have condiditon if body isnt empty dont rewrite it but that' it
  9. yes the title updates everything else updates but title only updates if its empty before saving, thats the issue
  10. so i started recently working on hooks i makde hook that after page create i upload .xml file and from that i get title into variable and i paste it into name(url) and title, the name(url) is replaced but title isnt? why is that i have it like this $page->title = $newtitle; $page->name = $newtitle; and i have that in $this->addHookAfter('Pages::saveReady', function(HookEvent $event) { // Get the object the event occurred on, if needed $pages = $event->object; // An 'after' hook can retrieve and/or modify the return value $return = $event->return; // Get values of arguments sent to hook (if needed) $page = $event->arguments(0); // tento hook pojde len na jeden template if($page->template != 'hry_home') return; // pokail stranka este neni vytvorena (Nema ID) tak nepokracuj zo scriptom if(empty($page->id)) return; these are also my if statements so that it doesnt run off when it shouldn't, also this is in my ready.php file so question is how ca ni force to overwrite my title field ? after save
  11. wow that worked, but why, i kinda dont get it? root of children dont get change when on child url, why did it worked?
  12. Hello so i managed to implement pagination to my site, i have navigation rendering done like so $out = ''; $root = $pages->get("/"); $children = $root->children("limit=150"); // $children->prepend($root); foreach($children as $child) { if($child->numChildren && $child->id !== 1) {// @note: you could do some more checks here; $out .= "<li>"; $out .= "<a class='dropdown' href='javascript:void(0);'>{$child->title}</a>"; $out .= "<ul>"; foreach($child->children as $level1) { if ($level1->hasChildren()) { $out .= "<li>"; /* if ($level1->numChildren()) { $out .= "<a href='{$level1->url}'>{$level1->title}</a>"; $out .= "<ul>"; foreach($level1->children as $level2) { $out .= "<li>"; $out .= "<a href='$level2->url'>$level2->title</a>"; $out .= "</li>"; } $out .= "</ul>"; } else { */ $out .= "<a href='{$level1->url}'>{$level1->title}</a>"; /* } */ $out .= "</li>"; } } $out .= "</ul>"; $out .= "</li>"; } else { $out .= "<li><a href='{$child->url}'>{$child->title}</a></li>"; } } echo $out; echo "<li><a href='{$root->url}'>{$root->title}</a></li>"; which works flawlessy for my page withing children any page, except when i enter pagination the whole menu entry dissapears as i click link to page2 in pagination, idk why but when my url is www.page.sk/page2/ my navigation dissapears except the last entry which is echo "<li><a href='{$root->url}'>{$root->title}</a></li>"; i tried debugging it and i found out that variable $children is just empty like why would $root->children("limit=150"); wouldn't work in url segment? is this some sort of bug ?
  13. no i wasnt aware of -> not() functinon this works fine i found out one workaround by myself i checked if field which as every page isnt empty but this is very good solution thanks $kat = $pages->find("subor_hry>1, $limiter");
  14. so i want to $pages->find find pages only that dont have children i didnt see any options for this so i tried this $kate = $pages->find("template=hry_home"); foreach ($kate as $bruh) { if($bruh->hasChildren()) { $kate->remove($bruh); } } this works incredibly good but i need it for pagination so i still need to limit it and thats where i got stuck simply $kat = $pages->find("$kate ,limit=5"); doesnt work, how do you work around this problem? every page has the same template, so i cannot use just different selector in find command are there any other quirsk i could use ?
  15. i have been trying this for a while and what even is imageSizer? is it like a hook ? if so i get error everytime i try ti save it ProcessPageEdit: Unable to read: /site-hry/assets/files/1027/flash_fishy_screenshot.png and when i put it into template i get different error do i understand it incorrectly ? i have this setup $word = ".png"; foreach($page->subor_hry as $file) { if(strpos($file, $word) !== false){ $image = new Pageimage($page->images_thumb, $file->url); } }
  16. So hello i am trying to get a .png file from file field and put it automatically to image field, why png image is in the file field is because i already have a hook that extracts .zip and uploads all content into file field, but i just realizes i cant use size() function on image in file field so i am tryin got reupload it to images field i already have something like this in ready.php $word = ".png"; foreach($page->subor_hry as $file) { if(strpos($file, $word) !== false){ $page->images_thumb = $file->url; } } by my logic it should work but it dosnt i get error ProcessPageEdit: Unable to read: /site-hry/assets/files/1027/flash_fishy_screenshot.png when i remove url from $file->url i just get ProcessPageEdit: Item added to ProcessWire\Pageimages is not an allowed type so what am i doing wrong? is there some other way to do this ? also can i have all this in $this->addHookAfter('Pages::saveReady', function(HookEvent $event) { whats the correct function to have it apply on all pages ?
  17. ye welp, its still an image, so ill probably have to make some sort of hook to put image into image field and then output them, well thanks for confirmation
  18. so hello there i have fiel field type i have lots of stuff there, and also an image i can easily get image from that field using $options = array('quality' => 85, 'upscaling' => true, 'cropping' => 'north', 'sharpening' => 'medium'); $word = ".png"; // Test if string contains the word foreach($childgames->subor_hry as $file) { if(strpos($file, $word) !== false){ /* $imger = $file->size(473, 266, $options); */ echo $file; /* echo $file->url; */ } } so i get the fiel i tried invoking size on it like the commented out part and it doesnt work i get error Oh snizzle… Error: Exception: Method Pagefile::size does not exist or is not callable in this context (in what am i doing wrong? can you guys help me by all logic this should work
  19. so what i am trying to do is that i uploded some files into file field, and then i want hook to get MD5sum and other stuff from .xml and put it into text field into it coresponding pages, pages like this are gonna be many, for each one i want it to output it into its fields
  20. oh nevermind i gues this works ? if($media->r_soc->title == 'facebook') { $soc = 'facebook'; } elseif($media->r_soc->title == 'twitter') { $soc = 'twitter';
  21. so i made some options in t he field type, and i want to check if selected title is that output this is my sample code if($media->r_soc == 'facebook') { $soc = 'facebook'; } elseif($media->r_soc == 'twitter') { $soc = 'twitter'; } i just basically want to check if the user in CMS selected option facebokk and then outpit it into variable which is later outputted into fa icon, oh and also this is all in repeat field foreach($ikonky as $media) { so thats why its $media, but as of now it outputs blank state, not sure why, it doesnt outpit anything none of the check goes throught these are options i have in the field 1=facebook 2=twitter 3=instagram 4=youtube 5=github 6=linkedin
  22. well, no it doesnt help, beacuse its in CKEDITOR, the text in the same editor is visible, but not the images, and the image filed where the iamges are uploaded is visible on the page but not when embeded into ckfield
  23. so this is really weird issue i am so confused about this, so i have setup 'images' field where i put images and the include them in CKeditor, should work right? well it works on some sites, i use it nearly in every page but at one page, the images included in that CKeditor only show up, when i am logged into processwire, when i turn on incognito mode the images dissapear, but only on this specific page, everywhere else it works perfectly, has anyone came across this issue? i have nowhere in the site login checker, i have no idea what is going on
  24. oh found it ! https://processwire.com/api/ref/pageimage/ thanks for the help, i didnt knew it was called pageimage :D. ill mark this as solved, it works perfectly, but i still wonder why getimagesize didnt worked ?
  25. oh well i tried googling 'processwire how to get images dimension' but didnt found anything, thanks for the tip i'll try it out
×
×
  • Create New...