Jump to content

horst

PW-Moderators
  • Posts

    4,088
  • Joined

  • Last visited

  • Days Won

    88

Everything posted by horst

  1. if you not already know this, here is a grouped collection maintained by @pwired: https://processwire.com/talk/topic/4173-grouped-forum-posts-links-articles-tutorials-code-snippets/ @teppo has some things on his site: http://www.flamingruby.com/blog/php-for-template-designers/ (just ignore this twig stuff, focus on the php side), and there are more articles. The recipes are new but continousliy growing: https://processwire-recipes.com/ ...
  2. yeah, as they say, but concatenate the results, not overwrite them by each other: $read_test .= "<h4>" . $item->title . "</h4>";
  3. Yeah, but when reading the article that @jjozsi links to it seems that apple has done much more than only buying and using HiDPI displays. They have implemented a technique / layer that inspects browser content and displays images in normal dimensions on the screen but scale up texts to 200%. This way you are only able to see images that sharp and also can read the text without needing glasses. I'm not a apple fan, the only apple devices we have are iphones. All Tablets, PCs, Monitors, MP3-players, etc are not from apple.
  4. main.inc should keep the largest possible code for all your different layouts and include sub-xy.inc files. Lets say for example you have the default layout with $bodycopy and $sidebar and additionally a onecolumn layout without sidebar: You define a new variable e.g. $myLayout: // here is how it would look like in the /site/templates/init.inc <?php $headline = $page->get("headline|title"); $bodycopy = $page->body; $sidebar = $page->sidebar; $myLayout = "default"; // we only write the name without the fileextension, this way we also can set a CSS-class in the body tag! // or you put it into the head of every template file, here: /site/templates/basic-page.php <?php $headline = $page->get("headline|title"); $bodycopy = $page->body . $page->comments->render(); $sidebar = $page->sidebar; $subnav = $page->children; $myLayout = "default"; include("./main.inc"); Now move the smallest possible segment from your main.inc into default.inc and replace it in main.inc with an include("./$myLayout"): /site/templates/main.inc <html> <head> <title><?php echo $headline; ?></title> </head> <body class="<?php echo $myLayout;?>"> <?php include("./{$myLayout}.inc"); ?> </body> </html> /site/templates/default.inc <div id='bodycopy'> <h1><?php echo $headline; ?></h1> <?php echo $bodycopy; ?> </div> <div id='sidebar'> <?php echo $sidebar if(count($subnav)) { echo "<ul class='nav'>"; foreach($subnav as $child) { echo "<li><a href='$child->url'>$child->title</a></li>"; } echo "</ul>"; } ?> </div> Lets say you don't want the sidebar on your homepage, then you define / overwrite in your /site/templates/home.php the $myLayout var with $myLayout = "onecolumn"; // we only write the name without the fileextension, this way we also can set a CSS-class in the body tag! Create a file called "onecolumn.inc" and put in your desired markup, e.g.: /site/templates/onecolumn.inc <div id='bodycopy'> <h1><?php echo $headline; ?></h1> <?php echo $bodycopy; ?> </div> To stile your onecolumn layout with CSS you need to append to your css something like: body.onecolumn div#bodycopy { width: 100%; }
  5. @Martijn: ah, for me this makes sense: saving space with full images. And with a lot of images so boringly showing repetitive cropnames throws away the focus from the thumbnails. And that it is visually different from default images field is a plus. @Martijn: have you also read that if you have two or more croppable fields on one page, toggling the viewmode (list/grid) always affects all fields?
  6. Really? --- If you can find the time, you should drop in the code from my previous post and try it. - But also there is nothing to say against using array_unique. The only thing with your code is that you don't need to use this cool implode / explode trick because you initially have the array. So you first can run $outItems through array_unique() and then implode() it to get your outputstring. And when using array_unique() you don't need even to try to collect and compare category titles: // beginning of new design category code if($design_technique instanceof PageArray) { // create array for collecting output $outItems = array(); foreach($design_technique as $test_skill) { foreach($test_skill->design_skill_category as $example) { // collect for output $outItems[] = $example->title; } } // create the output $import_skill .= implode(" / ", array_unique($outItems)); // implode gets the result from array_unique here } //end of new design category code PS: But you should bookmark or somehow store this trick (explode / array_unique / implode) for later use if you once only have a string list with double items. I have bookmarked it (the link in the browser favourites and the code in my brain)
  7. Ah, I always use Thumbnails in Listview, have tried the fullsize images in Listview a while ago. Yes, the (unhovered) titlebar is transparent and overlaps the image. Maybe we simply should make it opaque? Or do you think this few lines can be important enough to not get covered? But anyways, I have to hand this over to @Martijn ! ------ In Listview with thumbnails I like it as it is now, but in Listview with centered fullsize images it may look a bit better if the buttons are appear directly under the image and centered too, followed by the text inputfields. But I have to give this to @Martijn too
  8. Hey @adrian, just to clarify: 1) in grid view (thumbnail view) you need to hover over the little headline (width x height), than this changes to "Edit" and you need to click this to get into a little modal window that holds all crop buttons and all the text inputfields, for e.g. description, tags, etc. Does this not work for you? If not, what browser version you are using? 2) what admin theme are you using? 3) Is this related to the list view or the grid view, or both?
  9. Hey @kathep, glad you have solved it. But I wonder if it couldn't be done shorter, and also if not one of my examples also should work. Do you also have tried my second example? I think this one should work, regardless if I have understand the hirarchycal order of your data or not. If you like, please try out and compare the following examples: if($design_technique instanceof PageArray) { # first run my example 1) but put the $alreadyFoundCategories = array one level up !!! // create array for collecting output $outItems = array(); // array collecting categories $alreadyFoundCategories = array(); // this is moved from **) to this line foreach($design_technique as $test_skill) { // **) here was the "$alreadyFoundCategories = array();" before foreach($test_skill->design_skill_category as $example) { // is already processed, so skip this one if(isset($alreadyFoundCategories["{$example->title}"])) continue; // add it to the list $alreadyFoundCategories[$example->title] = $example->title; // collect for output $outItems[] = $example->title; } } // collect for comparision $outItems1 = $outItems; # second run is my example 2) // create array for collecting output $outItems = array(); foreach($design_technique as $test_skill) { foreach($test_skill->design_skill_category as $example) { $outItems[$example->title] = $example->title; // $outItems will be created as associative array, $key => value // we use the value (your title) also for the key // therefore each following item with a identical value will overwrite the previous one // and each items stays unique, as this is the nature of arrays: they cannot have keys with the same name or index !!! // therefore there is no need for array_unique ! But let us see } } // save it and create unique arrays for comparision: $outItems2 = $outItems; // we pass $outItems1 and $outItems2 through array_unique(), what will remove any duplicate value if there is any ! $outItems1u = array_unique($outItems1); $outItems2u = array_unique($outItems2); // now we put some debug message out $outMsg = "<pre>\n"; $outMsg .= "Method 1 collected " . count($outItems1) . " items\n"; $outMsg .= "Method 2 collected " . count($outItems2) . " items\n\n"; $outMsg .= "UniqueArray1 has " . count($outItems1u) . " items\n"; $outMsg .= "UniqueArray2 has " . count($outItems2u) . " items\n\n"; $outMsg .= "Method 1 seems to work " . (count($outItems1) == count($outItems1u) ? 'correct!' : 'wrong! Sorry.') . "\n"; $outMsg .= "Method 2 seems to work " . (count($outItems2) == count($outItems2u) ? 'correct!' : 'wrong! Sorry.') . "\n"; echo $outMsg . "\n\n</pre>"; }
  10. here is one more solution, created / based on Somas module
  11. It would be god if you can provide some more details about the hooks you are using for those modules, (a few lines of code for each of both modules) And if you create pages via API you also have to save them, so what is the difference between saving them the fisrt time (via API after creation) and the second one? A few lines of code you use to create save them would be helpful too.
  12. New addition: retinafy! this was created on request from @jjozsi here in this post. . * retinafy // create a pageimage with any method you like $image = $page->images->first()->size(400, 300); // call retinafy on it echo $image->retinafy(); // it outputs a markup string like this, where width and height is populated with half the sizes of the pageimage <img src="/site/assets/files/1234/basename.400x300.jpg" width="200" height="150" alt="description" /> . . The default markup template has the default replacements URL, WIDTH, HEIGHT and DESCRIPTION. <img src="[URL]" width="[WIDTH]" height="[HEIGHT]" alt="[DESCRIPTION]" /> You can change that to any markup you like in the modules Configpage! . . If you have additional properties populated with pageimages in your system, you can provide an array with those property names: // if you need custom properties in your markup, define the template in the modules config page with those placeholders, // please only use UPPERCASE and wrapp these [ ] around them <img src="[URL]" width="[WIDTH]" height="[HEIGHT]" data-custom1="[CUSTOM1]" data-custom2="[CUSTOM2]" /> // call retinafy with custom property names $customPropertyNames = array("custom1", "custom2"); echo $image->retinafy($customPropertyNames); // it outputs a markup string like this, where width and height is populated with half the sizes of the pageimage <img src="/site/assets/files/1234/basename.400x300.jpg" width="200" height="150" data-custom1="custom-value-1" data-custom2="custom-value-2" /> . . Regarding to the technique described in the article @jjozsi linked to in his post it would make much sense to use a low quality setting sitewide by defining it in the ImageSizerOptions, also available on the Pia Configpage. Otherwise, if this is not possible, you need to call your images for that you want the retinafy markup with the quality option set: // create a pageimage with any method you like echo $page->images->first()->size(400, 300, array("quality"=>35))->retinafy();
  13. I have updated Pia with this retinafy: https://github.com/horst-n/PageimageAssistant/commit/d31d743533133b130131d8c5b042bd510bf68bb2
  14. @jjozs: If you think you can go with Pia, I can implement this feature, but I wanted to clarify how it should be best done. With my above suggestion Pia will not create any image, you create the images with what ever method you like before Pia comes into play. Normally with images there is not returned any HTML output from PW. Only the images get rendered and the returned pageimage object holds the necessary properties (url, width, height, etc). But with a module we can also achieve to create and return some html output. So Pia will only inspect and return what is given by the pageimage on wich you call ->retinafy. If it has the right dimensions in regards of upscaling or not isn't noticed by Pia. How I understand it, you want to create and serve one image for all devices including retinas. You create the images in doublesizes as normally but with less quality == high compression. To achieve this you can set the sitewide default options for the imagesizer right in Pias config page. And if you have concernes that the images do not match a minimum length, there is are settings in images fields for minWidth and minHeight. If you provide values there, no image that do not match these criterias can be uploaded!
  15. If no other users are allowed to the Admin, one could use Diogos module I think: http://modules.processwire.com/modules/process-admin-custom-pages/ Edit: that was the wrong module, here is the right one: https://github.com/ocorreiododiogo/ProcessHomeAdmin
  16. Have you the latest cropimage module? There were updates lately regarding repeater fields: https://github.com/apeisa/Thumbnails/commits/master
  17. @jjozsi welcome to the forums. @jjozsi & @all I think this is a perfect task for Pia. I would suggest to implement it this way: // create a pageimage with any known method or module (width, height, size, crop, contain, cover, ...) $image = $images->first()->size(400,400,$options); // return output for retina displays $image->retina(); Pia will inspect the given pageimage for width and height and outputs a html img tag according to your settings in ModuleConfig but fills in the half value for width and height. Available placeholders should be each available Pageimage property from your system as uppercase wrapped into [], so the default ones are: - - [WIDTH] - [HEIGHT] - [DESCRIPTION] So, if you have this configsetting: <img src="" width="[WIDTH]" height="[HEIGHT]" alt="[DESCRIPTION]" /> and your $image->width is 400 and your $image->height is 300, the output of $image->retina() will be something like: <img src="/site/assets/files/1234/basename.400x300.jpg" width="200" height="150" alt="the image description" /> What do you think? Or is it odd to calculate the double size for the initial images by yourself? The advantage of this implementation is that you can use it with any core- or module-method (even future ones) that return a pageimage!
  18. -------------------------------------------------------------------------------------------------------------------------------- for PW 3.0+ please follow this link! -------------------------------------------------------------------------------------------------------------------------------- Croppable Image Module for PW >= 2.5.11 and PW <= 2.7.3 Version 0.8.3 alpha Hey, today I can announce an early (alpha) release of CroppableImage, what was forked from Anttis Thumbnails module. Until now there was a lot of work done by owzim, Martijn Geerts and me. We have solved the issues regarding the list from here: The modules are bundled together so that you only can and have to use FieldtypeCroppableImage for install, uninstall & configure. It uses new naming scheme that was introduced with PW 2.5.0 that supports suffixes. The complete image rendering is delegated to the core ImageSizer, or to any optional hooked in rendering engine. Template-settings are now fully supported, including removing variations when settings have changed. It fully respects settings for upscaling. If upscaling is set to false, you cannot select rectangles smaller than the crop setting. We implemented these enhancements: The GridView now is very nice and compact, and also benefits from the lately introduced setting for $config->adminThumbOptions. Permanent storage of the crop coordinates, quality and sharpening settings are now implemented native. No need to use PiM for this anymore. The usage/display of the Quality and Sharpening DropDown-Selects can be globally disabled/allowed in the modules Configpage. (additionally to that a setting on a 'per field base' is planned.) And the most wanted feature by the community: It gives back a pageimage and not the URL-string. This way you can use it like this: // get the first image instance of crop setting 'portrait' $image = $page->images->first()->getCrop('portrait'); You can further use every pageimage property like 'url', 'description', 'width' & 'height' with it: // get the first image instance of crop setting 'portrait' $image = $page->images->first()->getCrop('portrait'); echo "<img src='{$image->url}' alt='{$image->description}' />"; And you can proceed further image rendering with it: // get the first image instance of crop setting 'portrait' and proceed a resize with imagesizer $image = $page->images->first()->getCrop('portrait'); $thumb = $image->width(200); // or like this: $thumb = $page->images->first()->getCrop('portrait')->width(200); // and if you have installed Pia, you can use it here too: $thumb = $page->images->first()->getCrop('portrait')->crop("square=120"); The only downside with this is that when you (as the site developer) have enabled the usage of DropDown-Selects in the images editor, you do not know the values the editors have chosen for the images. As a workaround for this you can use the getCrop() method with a second param. This is a PW selector string. It can contain as many of the known pageimage options like 'quality', 'sharpening', 'cropping', etc, as you need, but none of them is required. But required is at least one setting for 'width' or 'height': $image = $page->images->first()->getCrop('portrait', "width=200"); $image = $page->images->first()->getCrop('portrait', "width=200, height=200, quality=80"); $image = $page->images->first()->getCrop('portrait', "height=400, sharpening=medium, quality=75"); . . You can get the module from GitHub: https://github.com/horst-n/CroppableImage (Better Docs are coming soon) Screenshots Related Infos A good setting in site/config.php for the AdminThumbs are: (height=>200 and scale=>0.5 !) $config->adminThumbOptions = array( 'width' => 0, 'height' => 200, 'scale' => 0.5, 'imageSizer' => array( 'upscaling' => false, 'cropping' => true, 'autoRotation' => true, 'sharpening' => 'soft', 'quality' => 90, 'suffix' => array(), ) );
  19. Wow! You have brought it a step further! Very well done to use the same naming scheme and provide the same methods. Edit: At the GitRepo I have seen that the gregwar lib supports IMagick? I saw a GD.php and a Imagick.php. How can I force to use the Imagick.php?
  20. It could be something like that: if($design_technique instanceof PageArray) { // create array for collecting output $outItems = array(); foreach($design_technique as $test_skill) { // array collecting categories $alreadyFoundCategories = array(); foreach($test_skill->design_skill_category as $example) { // is already processed, so skip this one if(isset($alreadyFoundCategories["{$example->title}"])) continue; // add it to the list $alreadyFoundCategories["{$example->title}"] = $example->title; // collect for output $outItems[] = $example->title; } } // create the output $import_skill .= " > " . implode(" / ", $outItems); } You can shorten this by using an associative array for $outItems and drop collecting items in $alreadyFoundCategories. Also I'm not really sure on wich level the items reside you want avoid to be collected twice. So you have to experiment with this snippet. if($design_technique instanceof PageArray) { // create array for collecting output $outItems = array(); foreach($design_technique as $test_skill) { foreach($test_skill->design_skill_category as $example) { // collect for output $outItems["{$example->title}"] = $example->title; } } // create the output $import_skill .= " > " . implode(" / ", $outItems); }
  21. Hey Ivan, a happy new year 2015! Actually here in Aachen Germany it is looking gray without snow at around +4°C
  22. If you have only a few or one function in a template, you may wrap a if function_exists() around it. If you have custom functions in other template files too, best way is to use a separate functions file. Depending on your setup you can include_once() your functions file in the site/config.php or a _init.php. This way you don't need to include it repeatedly in every single template file.
  23. @kathep: I like working with a editor / IDE that supports remote file editing (it is done via FTP behind the scenes). For me this is the most comfortable way, I really like it. Maybe your editor of choice has this too? Or can be extended somehow? Or another way could be to use a system software / protocol that lets you "hang in" remote directories into your filesystem. This way you can open any remote file with any software, also if the software doesn't support opening remote files by it self.
  24. I find PW and PHP addictive. And here is what others say: google-4-addictive EDIT: corrected broken google link
×
×
  • Create New...