Jump to content

picarica

Members
  • Posts

    68
  • Joined

  • Last visited

Everything posted by picarica

  1. 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
  2. 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
  3. 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
  4. 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; }); ?>
  5. 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
  6. yes the title updates everything else updates but title only updates if its empty before saving, thats the issue
  7. 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
  8. wow that worked, but why, i kinda dont get it? root of children dont get change when on child url, why did it worked?
  9. 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 ?
  10. 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");
  11. 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 ?
  12. 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); } }
  13. 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 ?
  14. 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
  15. 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
  16. 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
  17. oh nevermind i gues this works ? if($media->r_soc->title == 'facebook') { $soc = 'facebook'; } elseif($media->r_soc->title == 'twitter') { $soc = 'twitter';
  18. 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
  19. 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
  20. 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
  21. 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 😕
  22. oh well i tried googling 'processwire how to get images dimension' but didnt found anything, thanks for the tip i'll try it out
  23. so i am trying to fetch dimensions of image using getimagesize() but it returns nothing, at least i think so, i want to feed it to data attribute, bit its emtpy, i tried feeding it the image directly or just image->url here is my source code foreach($page->repeat_body as $r_body) { /* other code here*/ if ($r_body->gallery_check == 1) { echo "<div class='my-gallery' id='grid-gallery' itemscope itemtype='http://schema.org/ImageGallery'>"; foreach($r_body->image as $image) { $options = array('quality' => 80, 'upscaling' => true, 'cropping' => 'north', 'sharpening'=>'medium'); $thumb = $image->size(400, 400, $options); $large = $image->size(1280, 0, $options); list($width, $height) = getimagesize($image->url); echo " <figure itemprop='associatedMedia' itemscope itemtype='http://schema.org/ImageObject'> <a href='$large->url' itemprop='contentUrl' data-size='$widthx$height' data-index='0'> <img src='$thumb->url' height='$height' width='$width' itemprop='thumbnail' alt='Beach'> </a> </figure>"; } echo "</div>"; } /* other code here*/ } now, the images are outputted correctly, i can open then and browse them
  24. ye that link just links to my-url.com/processwire/repeaters/for-field-158/for-page-1240/1604946038-3619-1/ so i guess it works? or odesnt not sure. EDIT: okey it works like that echo $child->repeat_body->first()->body; i dont know what happend probably mistyped, okay it works thanks !
  25. so i am trying to fetch repeat field from page and output it, but only first one !, i thought first() would work and i googled something and came up with this if ($pages->get('/ponuka/')->title) { $ponuka = $pages->get('/ponuka/'); } else { $ponuka = $pages->get(1239); } //echo $ponuka; foreach($ponuka->children as $child) { $first = $child->repeat_body->find("limit=1"); $image = $child->pod_thumb; $options = array('quality' => 70, 'upscaling' => true, 'cropping' => 'north', 'sharpening'=>'medium'); $thumb = $image->size(400, 300, $options); echo " <li> <h3>$child->title</h3> <div class='split reversed'> <div class='content'>"; foreach($ponuka->repeat_body->find("limit=1") as $rep) { echo $rep->body; } echo "<ul class='actions'> <li><a href='{$child->repeat_body->first()->url}' class='button'>Pokračovať</a></li> </ul> </div> <div class='image'><img src='$thumb->url' alt='' /></div> </div> </li>"; } first check is just, if client somehow renames the site or changes url of that site, that it would fall back to fetching it from ID, and if they delete that site and create new one but with same name it will still work, so i hope that wont be a problem, then i output some stuff from that site, but i have trouble outputting the repeat field, as you can i see i tried it with find but didnt worked, what is the correct way to approach this ?
×
×
  • Create New...