Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/09/2014 in all areas

  1. We've recently rebrushed/relaunched our agencys website and took the opportunity to build it using processwire (as we're currently using it for almost all of our projects). http://www.neuwaerts.de Modules used: Modules Manager Page Link Abstractor Database Backups Redirects Revision History For Text Fields Template Data Providers Template Decorator Template Twig Replace There currently are 6(!) more websites using processwire in the making (more or less parallel) so stay tuned for some more showcase entrys in the next weeks
    7 points
  2. Hi everybody, I'd like to share with you another new module. It helps you to manage user ratings for pages in a very simple way. You can add a user rating to a certain page with a line of code: $page->ratings->add(4) If the user is logged in, the module remembers which page the user has rated for. For non-logged-in visitors, the module stores the pages, the user has rated, in the session. You can get a page's rating and its total amount of votes in a similar way: $page->ratings->average; // => 3.2 $page->ratings->count; // => 5 For more information about this module, please check out its GitHub repository. You can check out a working version of the module here: http://curium-cte.lightningpw.com Edit: The module is now available in the ProcessWire modules directory. Update: Ratings has been updated to version 1.1, including a new, simpler API accessor. As always - please comment for bugs or feature wishes. Thanks in advance, Marvin
    6 points
  3. Wow ok, thanks for the encouraging comments guys I've worked with PW for quite a while, surfing the core silently in the background (I'm a little shy like that). But one day apeisa gave me a proper kick in the knee and told me to grow a pair - I did, ergo, here I am. I must say you have a really good thing going on here and I'm very happy to be part of it!
    4 points
  4. @sforsman: Thanks for your great answers in the forum recently! Looks like you have a lot of knowledge about PW even with only 50 posts in the forum Keep on doing the good stuff
    4 points
  5. Thank you for your feedback and your commitment. I already guessed that it won't work with every AD. So far, the few ADs I have for testing seem to work. Written before, I try to enhance the module over time and add more features and compatibilities to it. Therefore, I'd be pleased if you can share the code with me, so I can enhance this module and make it better. Of course, you will be given credits in the source code for this. What connects us is that we all love ProcessWire and want to see it grow in every environment. So if we pull together, we can achieve this.
    4 points
  6. Read this quickly. Just guessing here; are you by any chance dealing with a multi-dimensional array? If yes, then $input will not help. It is only set to deal with simple arrays. An option would be to use PHP's $_POST instead or there was some other nice code in the forums yesterday but I can't find it now here you go if it is relevant. Anyway, just guessing for now but you will get better answers am sure
    3 points
  7. Hey guys, just wanted to let you know, that I finally had the time to make the fieldname configurable. I just updated the module on GitHub and the PW module page. Thanks again for your input
    3 points
  8. And, as I was saying, you go along wondering what a certain ProcessWire option would be useful for, and then one day... boom... it makes sense. Today... As much as possible I'm trying to do things without installing modules. It's just the way I like to try and set things up initally. So, I was sitting here trying to work out how best to do tagging. I think doing it by a multiple page select field would be best. But I think to myself... hmm, it would be good if you could actually add a tag from the page edit, rather than on the page tree. And then I recall the option to "Allow new pages to be created from field?". Colour me amazed. Is there nothing Ryan hasn't thought of already!?
    3 points
  9. @everfreecreative The thing is if you have like a lot of templates you'll have to do this for every template, once you want to change something on that part you'll have to edit all templates, so it doesn't scale well and isn't as flexible. If you wanted to conditionally not include header and footer, you'll have to edit all templates again. Once you want to be able to be more flexible with different layout types you're left with editing all templates to implement some logic. Once you decide you need to have different main container template for certain templates ... it doesn't scale as well. Of course to some extend you can incorporate things before the header include, but what if you have some after you wanted to add a css or js or something else? Maybe you want to be able to render a widget (page) inside content generation, that has a module or partial, that then wants to load conditional things like assets, you can't with your approach as the header is already "rendered".
    3 points
  10. Or just use $log ? $timer = Debug::timer(); ... $log->save("mylog", "phase 1: " . Debug::timer($timer)); $timer = Debug::timer(); ... $log->save("mylog", "phase 2: " . Debug::timer($timer)); Will create a log in site/assets/logs/ as mylog.txt
    3 points
  11. I've updated the module to version 0.5.1 including some minor fixes. New features are the ability to use SSL (LDAPS), turn on Debug Mode and the validation of the configuration file on save. @horst: the typo is also fixed @sforsman: when can I expect your repository? I'd really like to see it.
    2 points
  12. I have to say that working within the templates directory, however you decide to do it, is hardly building a template engine. What really worries me about a lot of this is that there seems to be a fear of writing ordinary html with some css bunged in. However you decide to organise your structure, however you decide to piece the bits together, in the end, that is all you are doing.
    2 points
  13. Take a look at $config->pagefileExtendedPaths, if you want to enable this, put that one to your /site/config.php and set it to true.
    2 points
  14. ProcessWire handles checkboxes internaly with 0 and 1 integers. So you need to do this, to enable the checkbox field and save it. $page->of(false); // disable output formatting $page->checkbox = 1; $page->save();
    2 points
  15. yule can.alsos do this new.stuffs pwire2.5 renders /site/templates/willyc.php echo wireRenderFile( 'willyc', array('headline' => $page->title) ); or.this wireIncludeFile( 'willyc', array('headline' => $page->title) );
    2 points
  16. article tutorial on some of the logic / js used on the site http://benbyford.com/articles/making-horton-stephens.com/
    2 points
  17. Found a workaround: I had the "Ready-To-Edit New Repeater Items" setting under "Details" set to "0". I set it to "1", now any new repeater is already published when created.
    2 points
  18. After a nights sleep I've figured it out. It was indeed the rendering of the options in the underlying select that was the issue. Commenting out lines 57-64 of InputfieldAsmSelect ___render() fixes it for me. I'll now hook that method to provide my own implementation that doesn't put all the selected options at the end. Hope that helps and thanks for looking
    2 points
  19. Hi Marvin, perfect. With you, the project is certainly in good hands. Send me please your contact information, then we can talk about AIOM. Thanks and best regards from Cologne. Dave
    2 points
  20. The funny thing is, ProcessWire works like this for the exact same reason: to reduce loading of not needed modules If you really, really want to do this yourself, then you would have to create a container inside the main module (or create a new module), that holds the relationships (this can even be a module configuration field). Then each "sub" module registers themselves as a conditionally loadable module with the main module. This would be done inside their ___install() -method. Then in your main module's init(), you fetch all the registered "sub" modules and load them. This would work - I can even write you an example. But to be honest, I'd just autoload the damn the module Though just let me know if you still want an example of what I described.
    2 points
  21. Great, then I can try to help you. I'm certainly interested in the steps 4-7, that you described in your OP. It would help even more if you could add the timers around the different phases of your process, like this: $timer = "newsletter_debug"; Debug::timer($timer."1"); // Phase 1 code Debug::saveTimer($timer."1", "Phase 1"); Debug::timer($timer."2"); // Phase 2 code Debug::saveTimer($timer."2", "Phase 2"); Debug::timer($timer."3"); // Phase 3 code Debug::saveTimer($timer."3", "Phase 3"); Debug::timer($timer."4"); // Phase 4 code Debug::saveTimer($timer."4", "Phase 4"); If you can enable debug-mode, then you could copy the timers directly from your admin site. If not, then you could just save them to disk. You can do this with file_put_contents(wire('config')->paths->logs."/timers.txt", var_export(Debug::getSavedTimers(),true), FILE_APPEND); Then just surf to your logs -folder (site/assets/logs) and post us the contents of the timers.txt -file.
    2 points
  22. Hello! There is a very simple answer for this: https://github.com/ryancramerdesign/ProcessWire/blob/dev/wire/core/WireInput.php#L60 This is ProcessWire's doing and it is meant to work like that. For now, I'd just suggest that you fetch them directly from the $_POST-variable ($_POST['players']). Obviously you need to validate/sanitize it yourself, but that's the way to go if you don't want to change your form. If you want to play by ProcessWire's "rules", then you will modify your checkboxes so that their name is "player_{{player.id}}[]" and parse them into a multi-dimensional array yourself. This could be done with a simple function like this: /** * Parses a multi-dimensional array * * This function will use $prefix to match the keys in the source $values. * For matching keys the suffix is then extracted and used as a key for the resulting array. * * @param array|Traversable $values The source values * @param string $prefix The prefix used for extraction * @return array The parsed multi-dimensional array */ function getMultiDimensional($values, $prefix) { // Validate the arguments if(!is_array($values) and !($values instanceof Traversable)) throw new Exception("Invalid values"); $len = strlen($prefix); if(!$len) throw new Exception("Invalid prefix"); $output = Array(); foreach($values as $key=>$value) { // The key needs to match our prefix if(strcmp(substr($key,0,$len), $prefix) != 0) continue; // We expect the other part of the key to hold numeric IDs $id = intval(substr($key,$len)); if(!$id) continue; $output[$id] = $value; } return $output; } // Demonstration $players = getMultiDimensional(wire('input')->post, "player_"); // print_r($players); // // [5157] => Array // ( // [0] => 1580 // [1] => 1578 // ) // ...and so on Edit: Added an example and some comments Needless to say, I suggest the latter solution
    2 points
  23. We have created an LDAP module for PW that supports mapping groups, setting the base dn and storing the e-mail address of the user (for an example). It also has an "Active Directory" -mode. I don't think Marvin's current code works with every AD-instance since it's missing a couple of ldap_set_option() calls that are needed for some. The only reason we haven't released it earlier is that we wouldn't have the time to maintain it. @Marvin: If you want to take a look at the code I can post it on Github and throw you a link. You could always implement all the stuff by yourself as well, I would understand
    2 points
  24. Hey guys, first, ProcessWire is a great piece of software. Thanks for that and the great community behind that. So, i'm realy new to ProcessWire, but i will present you my first module for SEO- and performance optimizing: AIOM+ (All In One Minify). AIOM+ (All In One Minify) for CSS, LESS, JS and HTML AIOM+ (All In One Minify) is a module to easily improve the performance of your website. By a simple function call Stylesheets, LESS and Javascript files can be parsed, minimized and combined into one single file. This reduces the server requests, loading time and minimizes the traffic. In addition, the generated HTML source code can be minimized and all generated files can be loaded over a cookieless domain (domain sharding). Install AIOM+ Download current release (link below) Extract and copy the files for this module to /site/modules/AllInOneMinify/ Login to PW backend and go to Modules > Check for new modules Install Module > AIOM+ (All In One Minify) for CSS, LESS, JS and HTML Alternative in ProcessWire 2.4 Login to PW backend and go to Modules Click tab "new" and enter Module Class Name: "AllInOneMinify" Click "Download and Install" Features Combining stylesheets / LESS files or JavaScripts Minimize the combined files No change to the .htaccess necessary (except for the domain sharding) Server-side LESS parsing without plugins HTML source code minimization Cookieless domain / domain sharding Automatic cache management (With changes to the source file, the cache is rebuilt) Configurable via the backend Automatic rewriting the paths in the stylesheet and LESS files. No changes are needed Optional developer mode (combining, but no minimize and browser cache prevention) Clear the cache on the backend Conditional loading for CSS, LESS and JS (since Version 3.1.1) How to use Minimize multiple stylesheet or LESS files into one file. You can even mix stylesheet and LESS files in parsing and combining process! <link rel="stylesheet" href="<?php echo AIOM::CSS(array('css/file-1.css', 'css/file-2.less', 'css/file-3.css', 'css/file-4.less')); ?>"> Minimize multiple javascript files into one file. <script src="<?php echo AIOM::JS(array('js/file-1.js', 'js/file-2.js', 'js/file-3.js', 'js/file-4.js')); ?>"></script> Conditional loading (same with Javascripts) <?php $stylesheets = array('css/reset.css', 'css/main.less', array('loadOn' => 'id|template=1002|1004|sitemap', // PW API selector 'files' => array('css/special.css', 'css/special-theme.less'))); ?> <link rel="stylesheet" type="text/css" href="<?php echo AIOM::CSS($stylesheets); ?>" /> More Information, Documentation and Download AIOM+ in ProcessWire repository AIOM+ on GitHub So, I hope you can do something with this module. Dave
    1 point
  25. A very simple tip, but that might be useful for someone that didn't think of it... This is what I usually do if I want to change something on a live site. if($user->name!='diogo'){ // live code }else{ // my new code } Like this I'm the only one that sees the changes. More examples: // test new javascript. do the same for styles <?php if ($user->name!='diogo'){?> <script src="<?php echo $config->urls->templates?>scripts/main.js"></script> <?php }else{?> <script src="<?php echo $config->urls->templates?>scripts/main-dev.js"></script> <?php }?> // test new head file if($user->name!='diogo'){ include(head.inc); }else{ include(head-dev.inc): } and so on... edit: corrected the first block by Nik's suggestion
    1 point
  26. Description This module adds icons based on the file type uploaded. It also lets you change the columns, etc. You can watch the video for more details or download and install. To make it work (do not know why) you have to change any configuration setting and save. Version Alpha version (0.0.1). Updated: 0.0.2 - Added Json name shorter, icons and columns. Updated 0.0.3 - Config in columns Updated 0.0.4 - Video and Audio extensions added. Updated 0.0.5 - Fixed select files and drag to upload div position. Updated 0.0.6 - Execution of the module only in the administration. What a fail! Github
    1 point
  27. There are days where I get a huge great, miserable reminder than I am a composer/writer/advertising bloke, and not a sysadmin, coder or expert anything. Warning: if some bright spark has a solution for this, don't tell me - its too late. Having had a couple of odd problems I decided that I really ought to update php on my little Ubuntu dev box. It is 12.04 with Webmin installed. Turns out that this is not very easy to do - generally, the Ubuntu repositories only let you install the php that comes with your distribution - 12.04 only comes with 5.3. However, I found a neat little tutorial that added a repository so that you can upgrade - it is maintained by some of the debian folk. So, I went and did that. Trouble is, it also went and updated Apache to 2.4 (much to my surprise) and everything went wrong. First of all, Apache wouldn't start. It was complaining about everything. I spent 2 hours reading posts from everywhere and nothing worked. So, I uninstalled it, purged it and reinstalled it. Yep, it started! Except now, it would not recognise ANY of the virtual hosts. I started reading again. I tried creating new hosts in Virtualmin, but Apache did not want to know. I tried manually - still not interested. I read every post out there and tried every trick - but the things they said would be definitely wrong were fine, except the working thing. I tried a couple of other things which included restarting apache. Guess what? It wouldn't start again - gave off the same errors. I had backed up all my sites with Virtualmin, so I tried restoring them to see if I could force it to work. Nothing. So, I have found myself staring at a development server that isn't - serving that is. And, what is more, my meagre knowledge has simply run out, as has my patience. So, I have just double backed up everything - files, MySQL and the rest and I have just downloaded a new ISO of Ubuntu. And with that, I am going to reinstall the entire thing, format all the crap away into PBS Telethon, sort out some partitioning woes I had in the process (my old boot partition was too small, really) and start from scratch. It is not clever, it is not educational and it is a sledgehammer solution - but when you are not the Demon Sysadmin of Fleet Street, sledgehammers might be all you have left.
    1 point
  28. Sorry to hear that. Here's a post that might help: https://processwire.com/talk/topic/6736-pharma-hack/ I am also moving this topic to the 'off-topic - dev talk' forum....since it is not directly related to PW...
    1 point
  29. Good point. I changed the thread title...
    1 point
  30. Can I suggest you please change the title to "MODx Sites Hacked" or something similar? I hope you get your issues worked out.
    1 point
  31. @sunlix: you might want to take a look at how I've handled this issue in the Changelog module. The approach I took there was adding new configuration option ($this->schema_version, which refers to the schema version currently used) and a constant (SCHEMA_VERSION, which refers to latest available schema version) and until those match it'll run updateDatabaseSchema() method, which takes care of schema updates. In that case the install routine actually uses an "outdated" schema version, so that module update (on existing installation) and fresh module installation behave exactly the same. That's definitely a question of preference. This is actually a simplified version of ProcessWire's own SystemUpdater.. and pretty much what @netcarver mentioned above too
    1 point
  32. @Toothpaste Please read the documentation here Posts are always returned sorted by date, latest first if you pass first parameter of renderPosts($posts) as a string I am not getting you clearly. Are you saying you want posts from ALL categories or from only THREE (1042, 1043 and 1044). If from only three, you can do the following: $categories = $pages->find('id=1042|1043|1044'); $blog = $modules->get("MarkupBlog"); $posts = $pages->find("template=blog-post, blog_categories={$categories}, limit=10"); if ($posts) { echo $blog->renderPosts($posts, true);//the 'true' truncates posts' length } Read here about ProcessWire OR selectors. Yes. This is all documented in the Blog tutorials. The default truncate length is 450 characters. You can set a custom length in your Blog settings page.
    1 point
  33. Hi Sven, An idea off the top of my head (and totally untested): could you make your module a configurable module with a hidden field set to the current module's version. During your init routine you'll get given that value so you just compare it with your module's current version and if your current version is greater then call your update routine to alter the table as needed. Knowing Ryan, there's probably a way to do this built-in but I'm currently unaware of it.
    1 point
  34. @everfreecreative You may want to check out my module: http://modules.processwire.com/modules/template-engine-factory/ It basically is a wrapper around the "internal ProcessWire template engine" with the option to add Smarty or Twig as external engines. The basic idea is that your regular template files are controllers which delegate the output to a corresponding template file. If you need MVC in ProcessWire, this module can help you. *Advertisment mode off* Cheers
    1 point
  35. I think you do maybe not really understand and my fault to mention "template engine". There's not template engine other than what PW has. I don't have a "template engine" on top of already existing template engine. I'm just using <div><?php echo $variable ?></div> and some simple logic if and foreach's, no template engine at all. Anyway It's all there and you don't have to built something, just structure differently.
    1 point
  36. Hey gyo! I'm a bit busy at the moment so I'll just quickly comment on this part only. You have absolutely nothing to worry about on the size of the $event-object - it is a tiny little object that will basically just hold references to other objects (that already exist in the memory anyway). This does not increase the size of the overall memory usage (in a way that really matters, at least). It sure is true that every single function call is theoretically "overhead", but we are talking about a very, very small overhead (in the context of hooks). The only thing you need to make sure of (to reduce the overhead), is that if you hook into something that's used a lot and your hook isn't always applicable, you need to return from the hook asap (i.e. check the conditions for execution in the first possible moment). If it makes you feel better, there's about a hundred hooks added by the PW "core" modules themselves On a side note, I think it's very cool that ProcessWire uses it's own core architecture to provide many of the "core" services we are used to (e.g. the admin-site). PS. I have put the word "core" inside quotes because the actual PW core is pretty lightweight. Much of the "core" that ships with the installation is actually just normal modules that hook in to the system.
    1 point
  37. Thanks for that link kongondo. It really helped. When I do print_r($GLOBALS), I get: [_POST] => Array ( [name] => Test [uname] => test1 [regemail] => my@email.net [pass] => [_pass] => [sort_repeater1708] => 0 [publish_repeater1708] => 0 [_disable_repeater1708] => 1708 [servername_repeater1708] => [sort_repeater1709] => 1 [publish_repeater1709] => 0 [_disable_repeater1709] => 1709 [servername_repeater1709] => [sort_repeater1710] => 2 [publish_repeater1710] => 0 [_disable_repeater1710] => 1710 [servername_repeater1710] => [sort_repeater1711] => 3 [publish_repeater1711] => 0 [_disable_repeater1711] => 1711 [servername_repeater1711] => [sort_repeater1712] => 4 [publish_repeater1712] => 0 [_disable_repeater1712] => 1712 [servername_repeater1712] => [_reg_servers_add_items] => 0 [timezone] => Europe/Berlin [submitregistration] => Register Account [TOKEN609710988X1412858909] => VehDxck9zIEvN191SQ5G.1HKmG0EeQG41 ) Now I process $_POST with the function from the linked post. $servers = getMultiDimensional($_POST, "servername_repeater"); And get back my array Array ( [1798] => A Server [1799] => Another Server [1800] => And one more Server [1801] => [1802] => ) Now I can go on from there and process my values.
    1 point
  38. Hi Everyone, I'm looking for a good designer. Some initial work is to create nice email templates (I can code the HTML if you/the designer cannot) and then the work will include design work on the main website (which is ProcessWire). If this isn't the right place to find a good designer, can anyone recommend where I should look/inquire? Any help is appreciated. Thanks
    1 point
  39. Otherwise you can use my module: http://modules.processwire.com/modules/textbox-list/
    1 point
  40. Hi Nico, nice question. I was unclear about this. Basically, the ratings are saved to the database, but the information about which pages the user has rated is stored in the session for guests. This is just how the module handles preventing guests rating the same page again after a short period of time.
    1 point
  41. What Nico said! My thoughts exactly! .
    1 point
  42. Those you can't see from the debug-mode admin site's timers, which I was primarily aiming at
    1 point
  43. Hi David, I'd be glad to take care of AIOM. I'm coming from the South of Germany. I work together with @phil at Conclurer, a web development company. If you want to, I can send you my personal mail address so that we can talk about AIOM. Thanks in advance, Marvin
    1 point
  44. Check out the image version, also from blad: https://processwire.com/talk/topic/7379-module-alternativegridimages/
    1 point
  45. I have reopened the issue on Github for Ryan to take another look.
    1 point
  46. As in most cases with PW, there are multiple ways to accomplish this. That can be scary if you're coming from a module-based system and/or are not a coder, but once you “get” how much freedom it can give you to not have to rely on modules, it's a thing of beauty. Yes, it means you're going to have to write PHP code, but you have the trusty PW API to help you with it. It's really not that big of a deal, trust me. (I'm an idiot in PHP myself.) Let's assess what you need here and strip it down to very basic concepts. Basic concepts are great, because they are usually generic and thus reusable. As you probably know by now, the most basic concept in PW is a page. So what you need is a page type to list all the items, a page type for the actual items and a page type for categories. You'll probably want a superordinate page type for categories as well, but since those don't necessarily have to emit frontend markup, they're pretty easy to define. Your page tree for this might look like this: OverviewItem A Item B Item C CategoriesCategory A Category B Category C Categories as well as its child pages most likely only need a placeholder template since they don't necessarily emit frontend markup. You could have a category.php in your templates folder that looks like this: <?php // Placeholder template for categories Now, in your template for items (let's call it item.php), you would need a field to associate the items with a category, meaning: with a page that is a child page of „Categories“ and/or has the categories template. So you would create a field of the Page fieldtype, call it e.g. “itemcategory” and in its settings limit it to one page (meaning one category), which has to be a child of the page “Categories” and have the categories template. All that is pretty self-explanatory once you see the Page fieldtype in the PW backend. If you add this “Item Category” field to your item template and create a new page with that template in your backend, you can now choose a page representing a category for that item. (Let's skip the actual content of item.php, that's not really relevant for the list here.) Now, how do we list those items in your format? We need a template for the overview page, let's call it item-list.php. In that template, we can do this: <?php // Get all child pages, i.e. items $items = $page->children; echo "<ul>"; // For each item in our list foreach ($items as $item) { // Create a list item including a link to the page, the page // title and the category title echo "<li><a href='{$item->url}'>{$item->title} ({item->itemcategory->title})</a></li>"; } echo "</ul>"; The filter is a bit more complicated, but mostly because it depends on how you want to implement that. One option would be to just go with a JS-based solution, at least that's what I would do. (I'm a bit more comfortable with JS/jQuery than with PHP, so …) You would change your item-list.php maybe like this: <?php // Get all children of the categories page $categories = $pages->get('/categories/')->children; // Create buttons for all categories <div class="filter"> Filter: foreach ($categories as $cat) { echo "<button class='show-cat' data-show='" . strtolower($cat->title) . "' type='button'>{$cat->title}</button>"; } echo "</div>"; // Get all child pages, i.e. items $items = $page->children; // List all items echo "<ul class='items'>"; foreach ($items as $item) { echo "<li class='" . strtolower(item->itemcategory->title) . "'><a href='{$item->url}'>{$item->title} ({item->itemcategory->title})</a></li>"; } echo "</ul>"; So now you have a button for each category which stores the lower-case name of said category in the data-show attribute list items which have class names which also have the lower-case name of their associated category which means you can write a little piece of jQuery $('.show-cat').click(function() { var showme = $(this).data('show'); $('.items > li').hide(); $('.items > li').hasClass(showme).show(); } which gets the associated category class of the button and then first hides all the list items and then shows only the ones which have the class associated with the button (i.e. the class matching the selected category). Please note that this JS code a) requires the jQuery library and b) is not perfect for performance, but the easiest way to quickly show you how to do it. It would be better to instead add and remove classes, but for that we would need another code example for the CSS you'd need for those, and I'm already posting a really long example here. Also please note that all this is untested and written from scratch off the top of my head on a lazy Sunday evening, so there might be typos. There might even be logical errors in the code. (There probably are. As I said, I'm an idiot in PHP. ) Sorry about that if that's the case, but I hope this example gives you an idea of how simple it can be to write the code for this yourself instead of relying on a module. Yes, other systems might give you a module ready to plug in which gives you about that functionality without having to write a single line of code (well, probably not), but this way you control exactly what code is used. You don't have to have some part of it in one specific way because the module's author decided to do it that way. You can have it your way.
    1 point
  47. Just use the wonderful CropImage module. Say, you have a 300x300 image in your template. Define one 300x300 called "thumb" and one 600x600 crop called "thumb2x". Now you can use the picture polyfill like this: <picture> <img srcset="<?= $page->myimage->eq(0)->getThumb('thumb') ?>, <?= $page->eq(0)->myimage->getThumb('thumb2x') ?>, 2x" alt="<?= $page->myimage->eq(0)->description ?>"> </picture> Adding additional breakpoints with <source> is also possible (from the picturefill docs): <picture> <!--[if IE 9]><video style="display: none;"><![endif]--> <source srcset="examples/images/large.jpg, examples/images/extralarge.jpg 2x" media="(min-width: 800px)"> <source srcset="examples/images/small.jpg, examples/images/medium.jpg 2x"> <!--[if IE 9]></video><![endif]--> <img srcset="examples/images/small.jpg, examples/images/medium.jpg 2x" alt="A giant stone face at The Bayon temple in Angkor Thom, Cambodia"> </picture> So you can also do some art direction where you output not only different sizes but also different formats (for example 2:1 on mobile, 1:1 on desktop etc)
    1 point
  48. This is how html5boilerplate does it. the nice thing is it works without specifying your domainname and could easily included in your own default htaccess: # Rewrite "www.example.com -> example.com" <IfModule mod_rewrite.c> RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L] </IfModule> https://github.com/h5bp/html5-boilerplate/blob/master/.htaccess#L344
    1 point
  49. We force a non-www on processwire.com, but it seems that not many sites do that for whatever reason. If you want to do that, here's the code you can use in your htaccess (replacing processwire.com with your domain): RewriteCond %{HTTP_HOST} ^www\. RewriteRule ^(.*)$ http://processwire.com/$1 [R=301,L] This isn't technically part of ProcessWire's runtime configuration because the rules in the htaccess file are what ultimately gives control to ProcessWire (they are executed before ProcessWire is).
    1 point
  50. I just pushed an update to the source that should prevent it from creating directories for pages that don't need them. Next up: going to make a module that removes empty directories, for those that want it.
    1 point
×
×
  • Create New...