Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/07/2013 in all areas

  1. Hi, I wish to have a core ImageManipulationClass like the ImageSizer but not only for resizing and cropping images. It should provide these easy to use functionality like with the ImageSizer and additionally a step to step image manipulation whereas the user / module author is not restricted anyhow. The basic image manipulation methods should be included, like: im_flip im_rotate im_crop im_crop_auto im_resize im_sharpen im_stepResize If someone want to do something more fancy or magic, he/she should not to have to reenvent the basics again. He/She just should start with the class by opening the imagefile and create a GD-object, use some basic methods, and at any point get the GD-IM-Reference out, do his fancy magic with it and put it back to the class to use its basics to finalise the file: im_get_im() im_set_im( &$im ) I have started to write something for this. I tried to be as close to the ImageSizer as possible, but some differences will be there. Before I've started with it I have done some tests with sharpening, rotating and others. First I've tried to create a module that hooks into ImageSizer, but have figured out that this wouldn't solve most things what I imagine one want to do with images. I have read the code of ImageSizer very carefully and there are allready very good inprovements in it from the community here. Ok, Ryan has written it and done the most work of all, so tribute to him , - adamkiss, interrobang, mrx, teppo, u-nikos have contributed the improvements to it: . I have looked into apeisas Thumbnail-Module and tried adding functionality for sharpening to it. It think he would have liked if there was a CoreImageManipulation class once when he has written the module. Also Soma actually work on a very cool Module where I really would like to see a link/button or some links/buttons for every image that just let you do some manipulations/corrections to them. <hint, hint ;-)> Any thoughts or Meinungen are welcome. --- EDIT: there is actually a modified ImageSizer class with autoRotation & sharpening available for testing: http://processwire.com/talk/topic/3278-core-imagemanipulation/#entry32284 --- Here are an overview of what allready is in, (I post only properties and method names, not the method bodies): class ImageManipulation extends Wire { // information of source imagefile /** * Filename ImageSourcefile */ protected $filename; /** * Extension ImageSourcefile */ protected $extension; /** * Type of image ( 1 = gif | 2 = jpg | 3 = png ) */ protected $imagetype; /** * Information about the image (width/height) and more */ protected $image = array(); /** * Was the given image modified? */ protected $modified = false; // default options for manipulations /** * Image quality setting, 1..100 */ protected $quality = 90; /** * Allow images to be upscaled / enlarged? */ protected $upscaling = true; /** * Allow images to be cropped to achieve necessary dimension? If so, what direction? * * Possible values: northwest, north, northeast, west, center, east, southwest, south, southeast * or TRUE to crop to center, or FALSE to disable cropping. * Default is: TRUE */ protected $cropping = true; /** * Should a optional Auto-Rotation be performed if EXIF-Orientation-Flag is available? */ protected $auto_orientation = true; /** * the default sharpening mode * * @var array with custom pattern or a string: 'soft' | 'medium' | 'strong' | 'multistep' */ protected $sharpening = 'medium'; /** * if extended imageinfo should be retrieved: number of Channels, Bits/per Channel, Colorspace */ protected $extended_imageinfo = false; /** * Extension / Format for resulting Imagefile (default is same as ImageSourcefile-Extension) */ protected $outputformat; /** * Filename ImageTargetfile if $outputformat is different than InputImage (default is same as ImageSourcefile) */ protected $targetfilename; // other properties /** * Directions that cropping may gravitate towards * * Beyond those included below, TRUE represents center and FALSE represents no cropping. */ static protected $croppingValues = array(); /** * Supported image types (@teppo) */ protected $supportedImageTypes = array(); protected $option_names = array(); private $property_names; // Methods to set and get Properties /** * Here you can specify multiple options as Array, whereas with the * single set* functions you can specify single options * * @param array $options May contain key-value pairs for any valid Options-Propertyname * @return this */ public function setOptions(array $options) public function setQuality($value) public function setUpscaling($value) public function setCropping($value) public function setAuto_orientation($value) public function setSharpening($value) public function setTargetFilename($value) public function setOutputformat($value) /** * Return an array of the current options */ public function getOptions() /** * makes protected and private class-properties accessible in ReadOnly mode * * example: $x = $class->propertyname; */ public function __get( $property_name ) // Construct & Destruct the ImageManipulator for a single image public function __construct( $filename, $options=array() ) public function __destruct() public function im_release() // read image informations, basic and extended protected function loadImageInfo() private function extendedInfo_gif(&$a) private function extendedInfo_jpg(&$a) private function extendedInfo_png(&$a) // helper functions /** * check file exists and read / write access * * @param string $filename * @param boolean $readonly * @return boolean */ private function check_diskfile( $filename, $readonly=false ) /** * helper, reads a 4-byte integer from file */ private function freadint(&$f) // the IM's (ImageManipulation Methods) private $im_dib_dst = null; // is the output for every intermediate im-method and optional a check-out for the im! private $im_dib_tmp = array(); // holds all intermediate im references private function get_next_im( $w=true, $h=null ) public static function is_resource_gd( &$var ) public function im_get_im() public function im_set_im( &$im ) public function im_flip( $vertical=false ) public function im_rotate( $degree, $background_color=0 ) public function im_crop( $pos_x, $pos_y, $width, $height ) public function im_crop_auto( $direction, $width, $height ) public function im_resize( $dst_width=0, $dst_height=0, $auto_sharpen=true, $sharpen_mode='medium' ) public function im_sharpen( $mode='medium' ) public function im_stepResize( $dst_width=0, $dst_height=0 ) // static oneLiner Methods that can be called only with a filename passed to them public static function file_get_exif_orientation( $filename, $return_correctionArray=false ) public static function file_jpeg_auto_rotation( $filename, $quality=95 ) }
    6 points
  2. I just added this to module directory, pushed documentation to github and consider this pretty much released.
    3 points
  3. I was delighted to see ProcessWire listed as one of the CMS platforms in this job posting: http://seattle.craigslist.org/see/web/3716084835.html It sounds like a lovely position, for those of us in the Seattle area. J
    3 points
  4. A guy at Kodingen is working on this. It's not music, but it's sound and good for programming http://rainycafe.com/ love it!
    2 points
  5. Hi geniestreiche, Thanks for these modules. I was wondering if it would be better to toggle the pageListActionLabel labels depending on the status of that page. So, show label "hide" if page is not hidden and show "unhide" if page is hidden. Same for the published status, i.e. show "publish" if page is not published and "unpublish" if page is published. Visually, this makes more sense to me. I am no coder but I've made quick dirty hacks in local copies of the module to do just this. See attachment. I'm sure your code will be cleaner than mine . Many thanks. Cheers /k
    2 points
  6. Hi mister antii This is a killer-feature-module, thanks very much! Frontend-Editing the Pw way: I can define which fields from which page I want to edit and output the edit-link where I want. Now that's freedom!
    2 points
  7. Ok so I gave it a shot with creating a module by altering Ryan's code you linked to and this seems to be working so far (I think). Here's the module using that code teppo linked to, slightly modified to match my requirements: <?php /** * Edit Yours Only * */ class EditYoursOnly extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Edit Yours Only', 'version' => 1, 'summary' => 'Custom module to allow users only to edit pages they created. Applies to role \'standard\'', 'author' => 'Christina Holly, TinaciousDesign.com', 'singular' => true, 'autoload' => true, ); } public function init() { if($this->user->hasRole("standard")) $this->addHookAfter("Page::editable", $this, 'editable'); } public function editable(HookEvent $event) { // abort if no access if(!$event->return) return; $page = $event->object; // criteria required in order to edit if($this->user->name !== $page->createdUser->name) $event->return = false; } } If anyone sees any problems that this could cause, please let me know. So far it appears to be working as I want it but I haven't tested it thoroughly. Thanks!
    2 points
  8. Hi everyone! With Batcher you can batch-edit and create Pages in the Pw Admin. If you install this module, you get a new Page "Batcher" under Setup. Modules page: http://modules.processwire.com/modules/process-batcher/ Github: https://github.com/wanze/ProcessBatcher Editing How does it work? Search your pages with a selector. You can check if you want to include also hidden/unpublished pages with the filters. Select the pages you want to execute an action (the action only gets executed on "checked" pages). Select the action and if necessary, additional data like the new parent or the new template. Execute. Supported actions: Publish/Unpublish Pages Hide/Unhide Pages Lock/Unlock Pages Trash Pages Delete Pages Change Parent Change Template Batcher does the following permission checkings for the current user: Don't display pages that are not editable Remove Actions if the user doesn't have the permissions (page-delete, page-move, page-template, page-lock) Important notes: When changing a template, data in fields of the old template which are not assigned to the new template gets deleted. When changing the parent, the template of the new parent must accept the pages template as children. This is a setting in the template under "family". Creating How does it work? Select a parent where your new pages will be added as children Add as many pages as you want by clicking "add Page" Click "Create Pages" You must enter a title and choose a template. The name is optional: If left empty, Pw will generate this for you. Includes permission checking and Family template restrictions. This means in detail: The selected parent must accept children and their template The pages template must accept the parents template User needs the permission to add children to the selected parents template User needs the permission to create Pages for the chosen Template Batch-creating tips The chosen template and the statuses are always cloned from the last row. So if you need to add 30 pages with the same template, define it first and the click "add Page" - it'll make your life easier ;-) You can drag & drop the table rows should you want to change the order. The dragging looks ugly but it works. For the lazy dogs and keybord hackers among us, you can add a new row by pressing "ctrl+n". This works (at least in firefox) only if no input has focus. After adding a new row, the title input gets the focus. By pressing 3 times tab you arrive at the published-checkbox, here the short-cut works. Restrict Batcher for a user to only allow editing or creating Create permissions "batcher-edit" and/or "batcher-add". As soon those exists, the module checks if the current user has the permissions. If you only need batch creating, check out the following module by Soma: http://processwire.com/talk/topic/2138-process-tools-create-pages-wip/ Cheers
    1 point
  9. Fredi is friendly frontend editor for ProcessWire. Code and documentation: https://github.com/apeisa/Fredi Module page: http://modules.processwire.com/modules/fredi/
    1 point
  10. A few days ago some of us discussed the philosophy behind the action links in the contao/pw-tree (http://processwire.c...-love-pws-tree/). Sometimes i found it useful in contao to have a shortlink to publish/unpublish a page. So i came up with the idea to make a module for this task. I wouldn't call me a programmer so i take the code from ryan's pageprocessclone (http://modules.proce...ess-page-clone/) an nico's pageprocessdelete (http://modules.proce...ss-page-delete/) as a starting point. thank you for your great work. Both modules adding a link to the page list. ProcessPageHidden adding a "hidden" link to the list and changes the status of a page to hidden/unhidden. https://github.com/g...ocessPageHidden ProcessPagePublish adding a "publish" link to the list and changes the status of a page to publish/unpublish. https://github.com/g...cessPagePublish Maybe someone would find it useful too and there are not so much bugs in the code.
    1 point
  11. We've just launched a new company, early days and we needed to get a site out quickly. http://www.milktop.co.uk Still plenty of fiddling to be done and we're pretty busy on other work, just didn't want to be one of those web companies without their own site
    1 point
  12. Looks like FieldtypeDatetime currently ignores timezone issues? Seems like this needs to be addressed somehow, at some point - it's fine if your applications are used in one timezone exclusively, or if users are aware that all timestamps are in ET say, but it seems this is going to be inadequate for applications used even across multiple timezones in the US, which most US applications probably are. This problem is particularly serious if you're storing dates only - since, without timezone information, a single date actually spans a 48-hour period worldwide. You can't really convert dates if you don't have a time. I would strongly prefer to have all timestamps stored in UTC in the database - with the ability to auto-detect a default timezone for anonymous users, and selecting a timezone for registered users. Anything like that already in the pipeline?
    1 point
  13. I have played with selectors a little. My task is solved by $options = array('selector' => 'id|parent=1006|1003'); 1006 and 1003 - ids of "Want in menu 1|2" in my structure. So we can use multiple "parents" =)
    1 point
  14. No doubt. But pretty hilarious that they would use the same language that would be used to describe a web request, at least from a systems standpoint.
    1 point
  15. On a file system, you can't have two of the same filename in the same directory. Filenames as keys ensure that same remains true in memory.
    1 point
  16. Never underestimate the importance of word separation. It's the difference in readability between "pen-is-broken" and "penisbroken". Beyond the potential misunderstandings is raw readability both to users and search engines. While I have a readability preference for underscores, my understanding is that hyphens are the best balance when all factors are taken into consideration. Lastly, this may be obvious, but what gets populated in that name box is only an auto-generated suggestion. After populating the title, one can go modify the name as they see fit (which I often do), before saving the page.
    1 point
  17. Tina your example also has an extra '$' before the session variable: $this->$session->redirect($pages->get(1)->url); that should be: $this->session->redirect($this->pages->get(1)->url); Make sure that you've got $config->debug=true; in your /site/config.php during development so that you get more verbose error messages, which should highlight these things rather than giving you a 500 error. I also recommend replacing your "init()" method with "ready()". Technically either should work here, but since $page isn't yet available at init() time, anything that inquires $page would be non-functional. There doesn't appear to be anything here that needs $page, but since you are making a $pages call, I think it's just a little safer to use ready() rather than init(). Note however that you'll want to keep the init() method around, since it is required. But just leave the implementation for it blank, while moving your code to a ready() method. Lastly, since this has to do with front-end, you might just want to make your own login form for the front-end. PW's login form is for login to the admin, but it wasn't intended to be used as a front-end login form (even if you can technically do it). You may find it a lot simpler and more flexible just to have a separate form for your front-end login: Here's a couple examples: http://processwire.com/talk/topic/2937-creating-a-front-end-admin/?p=28954 http://processwire.com/talk/topic/1716-integrating-a-member-visitor-login-form/?p=15919
    1 point
  18. That is true. I think it should be on advanced tab - it is something that can be very valuable on site building, not just for core/module development (which is where advanced mode is used).
    1 point
  19. I just pushed an update to 0.0.2 to github. Some refactoring and some changes - changed image tag syntax to use selector string syntax. This is easier to handle and I can use the PW selector class to read key=value easily. Now supports: {image=/path/, width=200, height=200, class=someclass, id=myimage, rel=album} - improved image upload to use the image field settings for max size settings, also improved error handling there- added some translations string - changed data table some and added a input for the tag where when you click it will select the tag text automatic for easy copying. - added modified date (sortable), also fixed some stuff with sortable of other cols - added size col - improved data table live search to search for also image description or image description field and title Planned - improve upload even more if/where possible - add easy image delete function - (Done) add textarea fields setting, to only insert "ImageManager" button to those specified Any testing or help appreciated. Thanks
    1 point
  20. Okay, I added this: <?php public function ___install() { if(ProcessWire::versionMajor == 2 && ProcessWire::versionMinor < 2) { throw new WireException("This module requires ProcessWire 2.2 or newer."); } if(version_compare(PHP_VERSION, '5.3.0', '<')) { throw new WireException("This module requires PHP 5.3 or newer."); } } ?> Should work I guess.
    1 point
  21. @Peter: you might want to check discussion about this in another thread (linked by Pete earlier), starting from here: http://processwire.com/talk/topic/992-problem-with-assetsfiles-folder/?p=14452. A bit further down that thread there's a post from Ryan where he explains why file directories behave like they do.
    1 point
  22. In the search file you have a foreach loop so you could just generate these fake urls on the fly. Like: <?php foreach($results as $result) { $url = $config->urls->root.$result->category.'/'.$result->name.'/'; echo '<a href="'.$url.'">'.$result->title.'</a>'; } ?> (doesn't tried it)
    1 point
  23. Wow, this is actually really nice!
    1 point
  24. I'm not an expert for google maps but build this with mapmarker fieldtype and google maps api: http://interrail.nico.is/orte/ If you want I can send you the source code
    1 point
  25. Hi Antti, This does indeed work with Thumbnails. I can see all sorts of applications for this. Terrific work! Cheers Marty
    1 point
  26. Thanks guys. Wanze: when I got the idea of how this should work I had kind of light bulb moment. I have been thinking about front end editing in PW about two years and I think now I have nailed the right ingredients AdminBar feels like a hack now. Although I am planning simplified AdminBar which would integrate with this. It doesn't need to do anything else than provide fredi switch and full edit link.
    1 point
  27. Hi Ryan, I'm making progress on my first PW site. I'm very pleased, so far! I'm replicating a structure I had done in MODX, and it's an interesting process. On this issue of "Pages with file/image fields require a directory" -- what about the scenario of a site with many thousands of articles, where the article pages have the image field, but perhaps only 50% of the articles have actual images? I would think that it would be much, much better to only create a directory when an image is attached to the page, and when it's deleted, then remove the image and the directory. It seems inefficient to have thousands of empty directories. Also, wouldn't that add to the max number of inodes, perhaps causing an issue? Thanks! Peter
    1 point
  28. Hi Ryan, I am not sure whether this is easily possible within PW or not - perhaps someone else will chime in on that front. However, and maybe I am telling you something you already know, and maybe you have a specific scenario and a good reason for wanting this, but dashes in SEO friendly URLs are important as they are treated as a word separator. The other alternative that is usually used is an underscore, but it seems the general consensus is that dashes/hyphens are better. http://themetaq.com/articles/seo-under-scrutiny-are-hyphens-or-underscores-better-word-separators Sorry if this is all terribly obvious to you already
    1 point
  29. this is possible using URL segments; I think this really depends on what your specific need is; if you use URL segments, then you'll have duplicate URLs (so use canonical meta tag pointing to the actual page location).. to make it work, you would enable URL segments on the template being used on the skycrapers page; then you run a check to see what is in the url, and then return the data for the page that matches; you can find a lot of examples in the forum.
    1 point
  30. Apeisa, Thanks for this. Simply awesome! /k
    1 point
  31. just to clarify: the number of sections is variable each of those sections can choose from 1 of 3 'layouts'; and each of those sections+layouts can accept 4+ types of content. in addition there is a possibility on a page, to include a 'reusable' block, in any of the said positions. thinking about the structure of PW, it would seem that the best way to think of your sections is in fact with pages; because then your users can select a different template according to the type of content; then when they are inputting/editing that content, you could provide a select for them to choose between the three layouts. When rendering each section, you could then easily include the necessary template for that item into the main page, and the from that include file, include the specified layout, or use classes to control the layout, use an if to check which layout they selected. if it is not too complicated with the different content types, you could setup functions to render each content type, like with an include file containing all of the markup for each section.. (i'm not a super php guru, so this code may not be the most efficient...) function renderSectionArticle($item) { $out = " <div{$item->class}> {$item->some_field} </div> // etc "; return $out; } in the template $items = $page->children; foreach($items as $item) { if($item->template == 'article') echo renderSectionArticle($item); elseif($item->template == 'something') echo renderSectionSomething($item); // etc... } this would seem to solve 1, 2, and 3. As far as how intuitive this is, i think that's really just a matter of users getting used to the system, and I wouldn't bother hacking the admin; the only disadvantage might be in not seeing the page as a whole when editing each of the separate pages. I use this method a lot, meaning i have a page which is composed of various elements, each stored in a child page. As far as including that reusable block, that is something that might be best to be selected in the parent item; you could provide a page list select to choose the reusable item, and then have some way of specifying the order. You could use the import array to get that reusable section into your child pages array; then you could sort that array on a custom field, such as 'section_order' where you specify in that field the hierarchy; you could sort the pages in the admin based on that field; they wouldn't see the reusable section though in the admin, but it would appear in the right place on frontend..
    1 point
  32. You're welcome Ryan! Glad i could help. Very nice site as always!
    1 point
  33. I happened to run across this today and thought I would share. I don't know your level of understanding for basic programming, but I sometimes like to revisit the basics. Although php is not used here, its the same concept. The instructor here makes it very interesting with her enthusiasm, that is actually entertaining. I hope someone just starting out may find it useful. Here is the link
    1 point
  34. I confess I don't understand exactly what will be the benefits of changing the way the admin works, but I may not be visualizing it correctly. As I told you , I would try to achieve the best without changing the admin. If you can get everything to work without "hacking" it will be easier later to think of a good admin solution if needed. But again, maybe I just didn't understand exactly what you want to do. It's good to keep the real page structure of course, but if you think the pages will be too deep in the tree you can organize them in any way you want by using the page field for relating the sections to pages. You can have, for instance, a "reusable sections" page where you organize all reusable sections as children. But if you have a clear idea of what you want to do I may be just confusing things for you. Maybe you can explain in more detail what you want, like elaborating more on the image of the first post, and we can help you with the thinking
    1 point
  35. Amsterdam was a blur for me - I was there on my stag do...
    1 point
  36. That is pretty impressive stuff Ryan! Looks and works great here!
    1 point
  37. Big thanks to Mats for the alltpaoland.com example and his clustering updates to my RCDMap class. With these available, I was able to learn enough (and admittedly copy enough!) to make the map project come together: http://www.synbioproject.org/library/inventories/map/ ... my code is a little messy, but it all works for the deadline, and I can go clean it up later. Beyond Google Maps, tools used here are jQuery Mobile, ProcessWire 2.3, ImportPagesCSV module, and ProcessWire Form Builder (for the add/edit map submissions). Thanks again Mats! I don't think I could have made much progress without your alltpaoland site as an example/guide.
    1 point
  38. You can go even shorter if you want to <title><?=$page->{'alt_title|title'}?></title>
    1 point
  39. I knew it but just wanted to leave some room for improvement so you guys also have something to write.
    1 point
  40. uses: $results=$pages->getById($ides) ; muches faster!! then get() ones.by one and in.right orders they will.be
    1 point
  41. 100 sounds like a limit to me... edit: another option would be to have a hidden page called "navigation" with a pageFieldType multiple in it where you could list the pages. 97 to go
    1 point
  42. Hi KentBrockman, welcome to ProcessWire. There are two reasons why it doen't work: 1) $pages->get will return only one page. If you want multiple pages, you have to use $pages->find which returns a PageArray. 2) You need the OR selector: id=1|1001|1003 So you could try this: $myPages = $pages->find("id=1|1001|1003"); foreach ($myPages as $p) { echo $p->title; } To make this more dynamic, you could add a checkbox field to the templates of pages you want to list, let's call the field "show_nav". Then check the checkbox on the pages you want to appear and update the code: $myPages = $pages->find("show_nav=1"); Of course this is only one possible solution out of 100 (infinity), with ProcessWire you have no limits
    1 point
  43. Here is a screencast to show this functionality for those who arre curious but can't or don't want to test: This is my first screencast ever
    1 point
  44. Where has my brain gone?
    1 point
  45. Mats, that works nicely on my android chrome!
    1 point
  46. I haven't done much front-end user stuff but the API and flexible role/permission/user system makes this pretty easy. Of course, depending on the exact needs it could get more complex. So for example you could create a new permission called frontend-edit. Create a role called frontend-editor and give it page-view and frontend-edit permissions. This will keep a user with (only) the role frontend-editor out of the back-end but allows you to log him and check for permissions in templates, allowing stuff you want. if ($user->hasPermission("frontend-edit")) { echo "<a href='{$page->url}edit'>EDIT</a>"; } else { echo "you are not logged in or you do not have permission to edit this page"; } if ($user->isLoggedin()) { echo "here you go, view this awesome page"; } else { echo "plz login if you wish to view this awesome page"; A front-end login could be as simple as creating a page, why not name it login, and putting this into the template file: <?php /** * Login template * Based on a forum contribution by Ryan, can't locate it, but the are many examples of login forms. * */ if($user->isLoggedin()) { // user is already logged in, so they don't need to be here $session->redirect($config->urls->root); } // check for login before outputting markup if($input->post->user && $input->post->pass) { $user = $sanitizer->username($input->post->user); $pass = $input->post->pass; if($session->login($user, $pass)) { // login successful $session->redirect($config->urls->root); } } include("./inc/head.inc"); ?> <?php if($input->post->user) echo "<div class='alert alert-error'>Vekeerde combinatie van gebruikersnaam en wachtwoord</div>"; ?> <form class="" action='./' method='post'> <label for="user">Gebruikersnaam</label> <input type="text" name="user" id="user" placeholder="Gebruikersnaam..."> <label for="pass">Wachtwoord</label> <input type="password" name="pass" id="pass" placeholder="Wachtwoord..."> <label></label> <button type="submit" name="submit" class="btn btn-primary">Login</button> </form> <?php include("./inc/foot.inc"); ?> These are just some examples but most if not all what you need is already available. It's up to you to code it the way you want. The API cheatsheet gives a nice overview of available building blocks. For the Create, Update and Delete stuff i think you would need to roll your own forms, populate them via the API and do with it what you want. Of course making sure you properly sanitize the inputs, maybe do some of your own validation etc.
    1 point
  47. Then you would maybe create another role for them with only delete permission and remove the delete permission from the other role. Then assign the "delete role" to the template you want them to delete.
    1 point
  48. Michael, are you talking about minifying or compressing? I can confirm that the HTML output (along with my js, css, and svg files) from PW is correctly compressed with the following line in my .htaccess, which is basically a shorter version of the code from HTML5 boilerplate quoted above: <FilesMatch "\.(js|css|html|htm|php|svg)$"> SetOutputFilter DEFLATE </FilesMatch> The issue might be with your server then. You can double-check what's gzipped here: http://gzipwtf.com/
    1 point
  49. After Ryan's latest incarnation of Blog Profile I wanted to see if I could learn something from there to my own workflow. It turned out very nicely and this seems like a perfect template approach for me. Wanted to share it with you guys. Folder structure under templates folder: templates/markup/ templates/markup/helpers/ templates/markup/layouts/ templates/scripts/ templates/styles/ And it all begins from here: templates/markup/index.php -this is the "complete" html file, it has doctype, head and starting and ending body. There is very little "logic" here, it's more like a container. There is one very important code snippet there though: <?php if ($page->layout) { include("./markup/layouts/{$page->layout}.php"); } else { include("./markup/layouts/default.php"); } ?> Code above goes between header and footer of your site, that will be the main content. I call it layout, but the better name would be "content layout" or "inner layout" or something like that. Then the templates/markup/layouts/ folder will keep at least default.php file, but probably few others, like "threeColumns.php", "frontpage.php", "gallery.php" etc.. you got the idea. Each of the actual pw template files are then purely "controllers" - no actual markup generated there. All markup are done in files inside templates/markup/ folder and it's subfolders. This is how template file templates/home.php on one site I am building right now looks like: <?php // Carousel items $t = new TemplateFile(wire('config')->paths->templates . 'markup/helpers/carousel.php'); $t->set('carouselPages', $page->carousel); $page->masthead = $t->render(); // Tour themes $t = new TemplateFile(wire('config')->paths->templates . 'markup/helpers/items.php'); $t->set('title', "Get inspired from our <strong>tour themes</strong>"); $t->set('items', $page->featured_themes); $t->set('description', $page->themes_description); $t->set('url', $config->urls->root . "themes/"); $t->set('linkTitle', "All themes"); $page->main .= $t->render(); // National parks $t = new TemplateFile(wire('config')->paths->templates . 'markup/helpers/items.php'); $t->set('title', "Seven beautiful <strong>national parks</strong>"); $t->set('items', $page->featured_parks); $t->set('description', $page->parks_description); $t->set('url', $config->urls->root . "national-parks/"); $t->set('linkTitle', "All national parks"); $page->main .= $t->render(); $page->layout = "frontpage"; include("./markup/index.php"); This uses few "helper" markup files from templates/markup/helpers/ folder (namely carousel.php and items.php). Here is the carousel.php for your reference: <?php /* Generates the markup for the frontpage carousel */ if (count($carouselPages) < 1) return; $styles = ''; echo "<div id='carousel'><ul class='rslides'>"; foreach($carouselPages as $key => $p) { echo "<li class='c-item c-item-$key'>"; echo "<img src='".$p->image->getThumb('carousel') ."' alt='' />"; echo "<p>$p->summary</p>"; echo "<a class='button' href='{$p->link->url}'>$p->headline</a>"; echo "</li>"; } echo "</ul></div>"; Then populates the $page->masthead and $page->main properties and then set's the inner layout to "frontpage". That templates/markup/layouts/frontpage.php file is very simple on this site, but could be much more complicated if needed: <div id="masthead"> <?= $page->masthead; ?> </div> <div id="main" class="wrap"> <?= $page->main; ?> </div> Frontpage is rather unique and I could have done all the markup on the frontpage.php file also. But I do want to re-use those "carousel" and "items" components on other places as well. But if I do have totally unique stuff, where I do want to get "quick and dirty" this approach allows it. Then my template file would be something like this: $page->layout = "campaign2012"; include("./markup/index.php"); And then all the markup would be in that templates/markup/layouts/campaign2012.php Blog profile really gave me a good ideas (cleaner folder structure etc) and using TemplateFile class adds nice possibilities. This is of course just a one way to manage your templates, but hopefully someone of you finds this helpful when thinking about how you like to structure this stuff. PS: If you are just getting started with PW, then I recommend using the head and foot includes method from demo install. There is nothing wrong with that method and only more complicated sites starts to benefit from these methods introduces in this topic.
    1 point
  50. While developing my dashboard module I came across a lot of difficulties when building a configurable filter for selecting pages for the last pages widget. Some things I discovered: "or" filter in native page fields didn't work. Fixed by Ryan in the last commit (Big thanks!): https://github.com/ryancramerdesign/ProcessWire/commit/70093241b2cbfe7cae79f28531c1a5df1a572169 It is was somehow difficult/impossible to use get('/')->find(...). This resulted in weird results where direct children were not in the results array. Should also be fixed (not tested). There is an undocumented selector "has_parent" which looks for a parent up to the root. Quite handy! So "has_parent!=2" removes all admin pages (except admin itself, add id!=2 for that) from a select (thanks @Soma!). The "user" which created the standard pages is not the superuser. This was the reason I doubted my results because I thought the superuser would have created everything. Me stupid. The inputFieldSubmitButton module generates a button which gets doubled in the admin head section. Couldn't find the place where this happens until I found out that this is generated with Javascript. Me stupid again. Important rule for selectors: First "has_parent" (if needed), second "include=all" (if needed), then the other filters. And in the end "sort" and then "limit". Not sure about this, but this works for me, so I have only one selector which seems to be correct. For example the latest pages for a specific user which are not admin pages (and no trash): has_parent!=2,id!=2|7,include=all,created_users_id|modified_users_id=41,sort=-modified,limit=10 Looks easy, but wasn't (at least for me)
    1 point
×
×
  • Create New...