Jump to content

picarica

Members
  • Posts

    66
  • Joined

  • Last visited

Everything posted by picarica

  1. 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
  2. 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; }); ?>
  3. 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
  4. yes the title updates everything else updates but title only updates if its empty before saving, thats the issue
  5. 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
  6. wow that worked, but why, i kinda dont get it? root of children dont get change when on child url, why did it worked?
  7. 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 ?
  8. 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");
  9. 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 ?
  10. 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); } }
  11. 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 ?
  12. 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
  13. 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
  14. 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
  15. oh nevermind i gues this works ? if($media->r_soc->title == 'facebook') { $soc = 'facebook'; } elseif($media->r_soc->title == 'twitter') { $soc = 'twitter';
  16. 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
  17. 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
  18. 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
  19. 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 😕
  20. oh well i tried googling 'processwire how to get images dimension' but didnt found anything, thanks for the tip i'll try it out
  21. 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
  22. 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 !
  23. 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 ?
  24. so am trying to make a simple navigation, just few dropdowns no custom classes nothing its so simple everything is dome but somehow that plugin markupmenubuilder? look how stupid it looks,i dont know why there is such a gap, and when i open submenu all the way to the right the dropdown is clipping into previous dropdown its all broken, deefault navigation has no problem what the hell is going on, i tried looking into code, and it seems that that plugin is applying left: internal css, not sure why? but how do i get rid of it? and its weird that the whole navigation is copied below footer, why is that ? why not use the HTML that already exists
  25. Hello si have this gallery, pretty good website, but yesterday client uploaded over 3000 images oto the site, and it cannot handle filtering them out and showing them at the same time , i wanted some simple pagination maybe infinite scrool or onclikc load whatever, but i cannot seem to implement infinite ajax scrool and any other JS methods, nut sure why i still got stuck at the next method, like there is not next page. so i wanted to implement PW method of paginating i wanted to use MarkupPagerNav so far i have this code for outputting images $pa = $pages->find("template=basic-page|art_gallery, images.tags!=''"); /* $pa = $pages->find("has_parent!=2,id!=2|7,status<".Page::statusTrash.",include=all"); */ echo "<div class='js-filter' id='gal' >"; /* row gtr-50 gtr-uniform */ $frame = $pages->get('/settings/')->watermark; foreach ($pa as $p) { foreach($p->images as $image) { if(!$image->hasTag("act")) { $options = array('quality' => 80, 'upscaling' => true, 'cropping' => 'north', 'sharpening'=>'medium'); $large = $image->size(1200, 0, $options); $wmImage = $large->pim2Load('wm1', ['quality'=>80, 'upscaling' => true, 'sharpening'=>'medium', 'defaultGamma'=>-1])->watermarkLogo($frame, $position='se',$padding=1.5)->pimSave(); /* zmazanie variacii, treba odpoznakovat ked sa menia nastavenie vyssie */ /* $image->pim2Load('wm1')->removePimVariations(); */ $thumb = $image->size(400, 300, $options); echo "<div class='$image->tags grid-item' style=''>"; echo "<span style='overflow:hidden;'class='image fit'>"; echo "<a class='hvr-reveal' href='$wmImage->url'>"; echo "<img uk-scrollspy='cls: uk-animation-fade; repeat: false' src='$thumb->url' alt='$image->tags'>"; echo "</a>"; echo "</span>"; echo "</div>"; } else { $options = array('quality' => 80, 'upscaling' => true, 'cropping' => 'north', 'sharpening'=>'medium'); $large = $image->size(1200, 0, $options); $wmImage = $large->pim2Load('wm2', ['quality'=>80, 'upscaling' => true, 'sharpening'=>'medium', 'defaultGamma'=>-1])->pixelate(25)->smooth(255)->watermarkLogo($frame, $position='se',$padding=1.5)->pimSave(); /* zmazanie variacii, treba odpoznakovat ked sa menia nastavenie vyssie */ /* $image->pim2Load('wm2')->removePimVariations(); */ $thumb = $image->size(400, 300, $options); echo "<div class='$image->tags blur grid-item' style=''>"; echo "<span style='overflow:hidden;'class='image fit'>"; echo "<a class='hvr-reveal' href='$wmImage->url'>"; echo "<img uk-scrollspy='cls: uk-animation-fade; repeat: false' src='$thumb->url' alt='$image->tags'><span>18+</span>"; /* <span>BY OPENING THIS IMAGE YOU CONSET THAT YOU'RE 18 YEARS OR OLDER</span> text copyraightova,y dat vedla obrazky potom */ echo "</a>"; echo "</span>"; echo "</div>"; } } }; to put it simply, it first searches for sites, and then outputs all images from those sites, pretty simple, it also uses watermarking and uikit filtering i have filtering done like this $num = 1; echo "<ul class='uk-subnav uk-subnav-pill'>"; foreach(array_unique($alltags) as $key => $tag) { echo"<li uk-filter-control='filter: .$tag;group: $num' class='butt$num' uk-toggle='target: .butt$num ; animation: uk-animation-fade; queued: true'><a href='#'>$tag</a></li>"; echo"<li uk-filter-control='group: $num' class='butt$num active' aria-hidden='true' hidden='' uk-toggle='target: .butt$num; animation: uk-animation-fade'><a href='#'>remove - $tag</a></li>"; $num++; } echo "</ul>"; simple, but i have NO idea how to implement pagination, just because it seems to work that it like find all images, and stores with limit, and then just paginates them, but i cannot apply this method in my code. any idea how to make any JS inifite scroll work ? or just how to make this work ? with my setup, or with some modifications, it just have to work as is now
×
×
  • Create New...