Jump to content

Soma

Moderators
  • Posts

    6,798
  • Joined

  • Last visited

  • Days Won

    158

Everything posted by Soma

  1. Thanks diogo. I just recognized that I forgot to remove a testing code in the resize function for crop images. I got it fixed and commited. Only drawback is that for the resize of the crop images it does it every time you load the tree, so there could be, depending on the size of the thumbnails, quite some overhead in generating those. Since I can't use size() function of PW it doesn't check if the resized file already exists. I could do a check too, but it would not work when updating the croped image, as it would be named the same and thus not update in the tree view.
  2. Good news for your Marty. I got the resizing working for crop images! I did some magic resizing using PW ImageSizer class. It now generates a extra thumbnail of the thumbnail using the size you specify in the module settings. They get named "widthxheight_thumbnail_imagename.jpg". I just commited an update. Let me now if any issue arises.
  3. I knew you would ask this question. No it's not possible cause the crop images aren't regular PW images. At least not without changing the Thumbnail module or write my own functions to resize the croped image. Have to further investigate and ask apeisa or ryan if there would be an easy way. For now it would only be possible over the css.
  4. Outputformatting is turned on! I had to turn it off to get it to work with testing only for "Pageimages". With the OF turned on, it is not possible with single image field. If the image field isn't populated, it will never be true wether with Pageimages nor with Pageimage. So it's all a bit wierd. So I have OF turned off. But strange thing is, then I have to test again inside the if($v instanceof Pageimages){..} routine for if(count($v) && $v instanceof Pageimages){..} to test for if it's a multi or a single, to then call it with first() or without if it's single. Like this: if(count($v) && $v instanceof Pageimages){ $thumb_url = $page->$field->first()->size($size[0],$size[1])->url; } else if(count($v)) $thumb_url = $page->$field->size($size[0],$size[1])->url; Don't really understand why.
  5. Ryan, does the profile exporter also export users and premissions?
  6. You could also use the php $GLOBALS to define global variables throughout the script if you want to. $GLOBALS['label'] = (object) array('text'=>'Das ist ein text'); function renderLabel(){ return $GLOBALS['label']->text; } echo renderLabel();
  7. Ahhh sorry for being so dumb ... about the pagination. I assumed you're using the PW pagination modul... I have to take back what I said about the limit greater than 1 to work. I'm not sure about the global, I rarely use it. Could it be that you define it an object? It's not a real array this way. Try just $label = array(...)
  8. Here I have one issue when set limit = 1, the pager don't work... Solution? It says in the docs that limit needs n= greater 1. This came up recently and in the past, so Ryan mentioned he will make it work with 1 any time rather sooner than later down the road. Yes and it's not in the scope of the function. You either need to pass it to the function or make it global inside the function.
  9. I don't know if I understand. $label? That isn't a PW template variable.
  10. Long story short. You're most likely looking for wire(). You can use also in function scope. wire("pages")->find(...) wire("sanitizer")-> etc...
  11. Some time ago there was a question if it's possible to change the "name" field on the users to "Username". Here's how I answered with a module example. May it be helpful to someone. <?php class UserNameLabel extends WireData implements Module{ public static function getModuleInfo() { return array( 'title' => __('UserNameLabel', __FILE__), // Module Title 'version' => 100, 'summary' => __('Overwrite User Name Label', __FILE__), // Module Summary 'autoload' => true ); } public function init() { // only add hook if on user pages if(strpos($_SERVER['REQUEST_URI'],'/users/') !== FALSE ) $this->addHookAfter("Inputfield::render", $this, "changeLabel"); } public function changeLabel($event){ $inputfield = $event->object; // only if the right inputfield if(!$inputfield instanceof InputfieldName ) return; // overwrite the label return $event->object = $inputfield->label = __("Username"); } } UserNameLabel.module.zip
  12. Sorry for the triple post. Again. I'm testing with if there's not image populated. It doesn't work same with single image fields. I'm doing a check if(($v instanceof Pageimage) || ($v instanceof Pageimages)){ ... If it's a multi mage field (Pageimages) it returns true and the magic happens even if the field is empty. If it's a single image field (Pageimage) it doesn't return true if the field is empty. So it doesn't return the "no-image" text as I wanted. Have you any idea why?
  13. I sense a simple module coming...
  14. Hmm, I can't see any broken image when there's none on the field. It doesn't output anything if there's no image when I test. Although looking at my own code I can't see why, cause it should. So it seems the only reason is because ($v instanceof Pageimage) does fail if there's no image. Edit: Even bigger HMM, ok now I see it. It only happens with "multiple" images fields. Edit2: Ok I fixed all, and have added new option to specify an No-Image Text and text color. Also the module options are populated with the defaults at first run. May need deinstall and reinstall to have a default install. Just commited an update: https://github.com/somatonic/PageListImageLabel
  15. Ahh cool. That works only if the var $defaults is static. Well I don't understand enough why, but It works! Thanks Ryan. Is it correct that I can't merge the defaults to a local ($this->key) in the init() and have it available in the hook "addImageLabel" function? Is that because it is a hook. I had to put the merging (foreach loop) in the function to get it work.
  16. Thanks Ryan! About the defaults. How can I get the defaults in the getModuleConfigInputfields function? I wasn't able to access them from there. How is the simplest way to handle it?
  17. You could also create various templates for the sections, and create them as pages underneath your parent/home. The php template would be just the section html markup with some content from the page. <section> <h2><?php echo $page->title; ?></h2> <?php echo $page->body ?> <img src="<?php echo $page->image->size(100,100)->url; ?>"/>; </section> Then in your top page (home) php template you'll be able to render them out simply with something like: foreach($page->children() as $p){ echo $p->render(); // will render the above }
  18. Hey smd, glad it works well for you. I just pushed an update. Fixed border and removed comma after thumbnail.
  19. Here it is a first test version. Got it working with regular image fields, or thumbnail cropimages fields. You can specify any image field using the image field name in the advanced template setting for page label. To output an thumbnail (from the Thumbnail module) just use the dot notation. fieldname.thumbnailname (as specified in the thumbnail field settings) There's some option on this module for controlling the size of image and the container size, padding, colors. https://github.com/s...eListImageLabel Edit: Added support for multiple image fields. It will always take the first image.
  20. Shouldn't a module add a .css or .js named same as the module automaticly? It strikes me again, that I added a ModuleName.css to the module folder assuming it get's added automaticly, but it does not. Not first time I struggle with something that should be simple. Edit: The module is autoload and is extends WireData implements Module. (of course in the admin, not frontend. In case anyone wondering)
  21. Oh, I remember another case where there was a similar behavior. It was when our designer created images saved as png but named as .jpg ... or vice versa. If it's always the same images that fail, make sure the images are really correct.
  22. Well I remember when testing locally and once on a developement server, that uploaded image doesn't resize, but will show up in fullsize after uploading. I couldn't figure out, as it only happened 1-2 times and with only 1-2 images. It might be something else, but it could be that it is the image itself, (CMYK, header bug, compression bug, etc...) fail to resize on the server. If I remember correctly even the image generated had like 0.0.jpg but showed in fullsize in the admin even though thumbnails are checked.
  23. If having this large images, you need lots of php memory to resize them. I experienced similar issue once.
  24. Now I could reproduce it, thanks to Ryan. The trick was to add a file field to the template too. Display thumbnails option doesn't change anything.
  25. I tried on different computers and different browsers and installs. I'm still not able to reproduce this.
×
×
  • Create New...