-
Posts
6,798 -
Joined
-
Last visited
-
Days Won
158
Everything posted by Soma
-
Is there a auto level or auto adjust function in gd like with imagemagick?
-
How to stop TinyMCE links from appending to current url?
Soma replied to Godfrey's topic in General Support
Have you added http://? -
How to retrieve AllowedTemplates inside a Module
Soma replied to Martijn Geerts's topic in API & Templates
$templates = $event->return; ... since the method returns the templates -
Yeah I like it better.
-
I looked closer and it doesn't work as simple, you have to call trackChange on image field for basename and remove variations too. So this will work: $old_name = 'wizard.jpg'; $new_name = 'lizard'; $p = $pages->get("image.data=$old_name"); $p->of(false); // outputformatting off, single and multiple image fields are from now on wire array's // get the image and the extension $image = $p->image->find("name=$old_name")->first(); $ext = $image->ext; $newFilename = $new_name . "." . $ext; $p->image->trackChange("basename"); $image->removeVariations(); $image->rename($newFilename); $p->save("image");
-
Ahhh Mr. ImageHorstManipulation No it doesn't work I'm afraid to say. Also the image variations doesn't get deleted and the image will not be changed in DB.
-
To delete pages you may use delete. http://cheatsheet.processwire.com/?filter=delete (must have been still in m clipboard ) $pages->delete($page, true); // recursive with children $pages->delete($page); $page->delete(); To get pages from the trash you would need include all $pa = $pages->find("parent=/trash/,include=all"); $pages->get() will give you only 1 page. http://cheatsheet.processwire.com/?filter=pages-%3Eget
-
Or a bit of API vodoo. $old_name = 'lizard.jpg'; $new_name = 'wizard'; $p = $pages->find("image.data=$old_name")->first; $p->of(false); // outputformatting off, single and multiple image fields are from now on wire array's $path = $p->image->path; $page_image = $p->image->first(); $ext = $page_image->ext; $orig_image = $page_image->filename $new_image = $path . $new_name . "." . $ext; echo "orig: " . $orig_image . "<br/>"; echo "path: " . $path . "<br/>"; echo "ext: " . $ext . "<br/>"; echo "new: " . $new_image . "<br/>"; // copy and rename copy($orig_image, $new_image); // remove old, add new image to page $p->image->remove($page_image); // orig, will get deleted $p->image->add($new_image); // new $p->save(); Or in a shorter code: https://gist.github.com/somatonic/6282944
-
If that's right it would the the first child or the first child that has children? Not sure. But he's speaking of a "parent"? So this would be easy with $page->child("template=xy, children.count>0"); To get the first child of a page: $page->child() will give you the first child with regarding to the sorting. $page->child("template=sowieso") same as $page->children("template=xy")->first();
-
$page->parents("template=thing"); $page->parent("template=thing"); Look cheat sheet for reference. But then I don't understand at all what exactly you looking for.
-
-
It doesn't do anything. Ok strange, now it works, and I only added some echo "test" inside the getPageImageManipulator() and uploaded. So I think I got when testing added a exit() there and haven't uploaded the module when removing it. Darn. Thanks for your time.
-
You can't just rename them physically and then think PW magically still knows which file it is. This is because PW saves the name of the file to the db. It's like the key! So you'd also have to rename it in the DB table field_yourfieldname also and you'll see.
-
Ditto, I have created some routine in a module to create fields and templates via API which would have taken maybe 400 lines of code to 100. https://gist.github.com/somatonic/6272112 To delete the fields and template from this it's also easy. I know there will be soon something based on array or json/yaml to create fields and export/import those things more easy. But just maybe find it useful.
-
Edit: just updated the module to 1.2.0 to commit addition I've done regarding the hook I've used in the original example. Now the MarkupSimpleNavigation::getItemString() exists if you update to the latest version and can be used instead of getTagsString(). I know it sound strange but I didn't like the function name for the hook and didn't want to break backward compatibility that's why I added an additional function that suits better.
-
Ah, now I see there's a change in my local MarkupSimpleNavigation module I did and haven't committed. So when using my code exmple with 1.1.9 it throws this error: Error: Exception: Method MarkupSimpleNavigation::___getItemString() does not exist (in /Applications/XAMPP/xamppfiles/htdocs/pw2-dev/wire/core/HookEvent.php line 153) #0 /Applications/XAMPP/xamppfiles/htdocs/pw2-dev/wire/core/HookEvent.php(153): ReflectionMethod->__construct(Object(MarkupSimpleNavigation), '___getItemStrin...') THere's a hook function I added which doesn't exist in current latest version, so it doesn't work. If you'd told me the error it would've been easy... I updated my code example and will delete your code to keep this thread cleaner.
-
When searching pages with images field, there's no subfield "name" for images, but you can use images.data. And you won't get the image but a page(s) $p = $wire->pages->get("images.data%=mode"); // get return the first match echo $p->images->get("filename%=mode")->url; Or $p = $wire->pages->find("images.data=modelifestyle.jpg")->first(); // returns a pagearray and we access first echo $p->images->get("filename%=mode")->url; Or echo $p->images->get("name%=mode")->url; Or echo $p->images->find("filename%=mode")->first()->url; Or echo $p->images->get("modelifestyle.jpg")->url; Or echo $p->images->get("modelifestyle.jpg")->name; // image name or echo $p->images->get("modelifestyle.jpg")->filename; // full path
-
Ah subdirectory... but then it should work as is. Do you have the latest version of the module?
-
Where is the Language Support Page Names module settings screen
Soma replied to NikNak's topic in Multi-Language Support
I can update and unupdate without problems between stable and dev. There's been quite some changes now from stable to dev, but none that caused any major problems so far. But maybe if you're installing and uninstalling language support modules along with that, it can screw up things, but even that I've been doing all the time with my test install and it's still running fine. Maybe if you could tell what went so horribly wrong, we can tell you more. -
Well apart from I don't know "what does not work" ... as I can't see your screen from here... Looks like you don't render the menu from the root level, although you don't give another root page to the nav render, so makes no sense to me. <li class="dropdown"><a href="/corpetrol/programas-tecnicos/">Programas Técnicos</a> This should be the first level dropdown, and it's missing the class and data attribute, but the URL is showing it's not a root page but a second level page already. So the hooks check for the level and since you seem to be on another level you'd have to change that to fit you structure. Those are the count($item->parents) if($item->numChildren(true) && count($item->parents) < 2){ ... } // only on level 1 I guess you have to adapt those.
-
As I wrote the example is for Bootstrap 2.3.2. I have no idea what BS 3.0 needs... but I'm lucky I don't use Bootstrap because it's annoying
-
@hosrt yes it works as usual/normal.
-
No there's no image created and it silently fails, means code after doing the image doesn't get executed at all. I tried locally and it works, so it's the server I'm working on... although it's php 5.3 and GD 2...
-
Refreshing $page object after deleting child records
Soma replied to Peter Falkenberg Brown's topic in API & Templates
$pages->delete($page, true); http://cheatsheet.processwire.com/?filter=delete -
Request to add Class to Submit Button in Comment Form
Soma replied to Zahari M.'s topic in Wishlist & Roadmap
http://processwire.com/talk/topic/696-quick-guide-to-the-comments-system/page-3