Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/09/2015 in all areas

  1. On GitHub: https://github.com/plauclair/AutodetectLanguage PW's Modules repo: http://modules.processwire.com/modules/autodetect-language/ This ProcessWire 2.x module tries finds a best match between HTTP_ACCEPT_LANGUAGE and currently installed languages. If a match is found, the user will be redirected from the requested page to the same page in his preferred language. This match occurs only on the first page load, and will work with default caching on. If no match is found, the website will revert back to the "default" language. Installation info and more details on GitHub. Please submit any bug on the bug tracker, as it is easier to track different issues.
    6 points
  2. I've just done an ->addClass(), which seems better to me, and it does work...
    3 points
  3. I just built a server for a customer using a combination of a low-end intel nuc (a DCCP847DYE) with 4GB of ram and a 30GB eSATA micro SSD. This is for running a sports-club's admin system that I built with PW on top of a Ubuntu server LTS LAMP stack. I am very impressed with the whole set-up so far - from size of the package (smaller than the club's ADSL modem), the speed of the celeron + SSD (boots & serves PW pages quickly) through to the low power usage (6W idle to ~14W under load.)
    3 points
  4. A possible solution could be to use an other page to select but you show the current Page title. Here's how to do: In the Page field settings use Custom PHP code to find selectable pages type: $p = $page->parent; $p->title = $page->title; $PageArray = $pages->find("template=type-template, id!=$page->id"); $PageArray->add($p); $PageArray->sort('title'); return $PageArray; Then when the field contains the $page->parent, you know that they wanted to select the current page.
    3 points
  5. It is built in. Martijn was close right. You can do this: $button = $this->modules->get('InputfieldButton'); $button->attr('id', 'button_create'); $button->attr('value', $this->_('Create New')); $button->attr('href', './edit/'); $button->class .= ' my-float-right-class';//note: concatenation + space PW will add the other inbuilt button classes. //See a cleaner alternative below...
    2 points
  6. Linux version antiX-13.2 (fast) with Lamp and Zimbra No special hardware like a rack server or nas, just and old box where I have put my own motherboard ASRock Z87 with intel i5 and 8G ram. Instead of UPS I use a 12V car battery with a converter to 220 V ac. It's all placed in a basement so there are no cooling problems. I don't have to pay for electricity or something. The only thing I pay is that I share with them their monthly internet bill. I certainly am curious what will be the downtime during a year. I want to see if the whole thing will be useful to script automate making backups, pings, check webshop email workings, etc. Will free up time to do other things.
    2 points
  7. Can't you just set the class ? $button = wire('modules')->get('InputfieldButton'); $button->attr('class', 'ui-button ui-widget ui-state-default ui-corner-all align-me-right'); Didn't test it but looks like: $button->addClass('align-right'); should do the trick.
    2 points
  8. On a bit of a hurry right now, so just hopping in to mention keyword "circular reference". This has been discussed every now and then, and current situation (unless I've missed something) is that it's (intentionally) prevented for Page fields. There have apparently been some changes regarding circular reference checks recently, so it might've been possible at some point, though it was never really intended Anyway, I'm not saying that this shouldn't possible, just trying to provide hopefully some insight about why this might happen. If you need a quick way to get past this, one option would be removing current page from selectable options and including a single checkbox, something along the lines of "this page itself". Or something like that
    2 points
  9. FieldtypeMatrix and InputfieldMatrix Modules Directory: http://modules.processwire.com/modules/fieldtype-matrix/ GitHub: https://github.com/kongondo/FieldtypeMatrix The module Matrix enables you to save data from a 2D-Matrix table. The rows and columns of the matrix table are made up of pages retrieved via a ProcessWire selector or via a page field selection of parent pages. The matrix values are made up of the data input in the matrix cells, i.e. the 'intersection of rows and columns'. Example Usage You have Products whose prices vary depending on colour, size, material, etc. Using the Fieldtype, you can create a table with rows made up of colours and columns made up of sizes the combination of each making up their respective values (in this case price). So rather than creating multiple text fields to do the following: Colour Size Price Red Small £10 Red Medium £20 Red Large £30 Red X-large £35 Green Small £9 Green Medium £15 Etc... You can instead have the following in one field: Small Medium Large X-Large Red £10 £20 £30 £35 Green £9 £15 Blue Etc... Yellow Purple If you set a selector in the Field's settings, to retrieve pages to build your matrix's rows and columns, it follows that all pages using the template the Fieldtype is attached to will have identical rows and columns. In some cases, this could be the intention. For instance, you might have 'Car' pages, e.g. Audi, Volvo, Ford, Citroen, Mazda, BWM, etc., each of which uses a 'Cars' template that has a single FiedltypeMatrix called 'car_attributes'. If you set a selector to build the Fieldtype's rows and columns, your users can easily compare the cars based on a combination of different values. The following matrix table best illustrates this: Type Engine Size Fuel Efficiency Carbon Emissions Warranty Road Tax Price 1994 Audi brand 1 values, etc. 2000 Audi brand 2 2006 Audi brand 3 2012 Audi brand 4 Each of your car pages would have similar matrices. This allows you to make easy but powerful queries. Such a setup allows you to compare within and across car brands. Say you wanted to find out which car(s) offered the best value for money given certain parameters such as warranty, emissions etc. You can easily make such comparisons (see code below). You can also compare within one car type, e.g. which brand of BMWs does best in what area...The possibilities are endless. In the database, Rows and column pages data are stored as their respective page->id. Matrix-values store any data (varchar(255)). If instead you wanted a template's pages to each have a matrix built of different rows and columns, you would have to name a Multiple Page Field (attached to the same template as the as your matrix field) in the matrix field's settings. When editing those pages, your matrix table's rows and columns will be built using the published children pages of the 2 pages you select in the Multiple page field.. The module allows the creation of matrix tables of any sizes (rows x columns). The rows and columns dynamically grow/shrink depending on the addition of row/column pages that match what you set in the matrix field's settings (see its 'Details Tab'). Please note that, if such pages are deleted/trashed/hidden/unpublished, their data (and presence) in the matrix are also deleted. Entering values in the matrix You have three choices: Manually entry Uploading a comma delimited (CSV) file. This can be delimited by other characters (tab, pipe, etc); not just commas Copy-pasting CSV values. (Tip: you can copy paste directly from an Excel spreadsheet. Such values will be 'tab-delimited'). In addition, if your server supports it, in the field's settings, you can enable the use of MySQL's fast LOAD DATA INFILE to read and save your submitted CSV values. Note that for large tables, you may have to increase your PHP's max_input_vars from the default 1000 otherwise PHP will timeout/return an error and your values will not be saved. I have successfully tested the module with up to ~3000+ values (10x350 table), the Fieldtype is not really optimised (nor was it intended) to handle mega large matrix tables. For such, you might want to consider other strategies. Install Install as any other module. API + Output A typical output case for this module would work like this: The matrix's rows, columns and values are subfields of your matrix's field. So, if you created a field called 'products' of the type FieldtypeMatrix, you can access as: product.row, product.column and product.value respectively foreach($page->matrix as $m) { echo " <p> Colour: $m->row<br /> Size: $m->column<br /> Price: $m->value </p> "; } Of if you want to output a matrix table in the frontend: //create array to build matrix $products = array(); foreach($page->matrix as $m) $products[$m->row][$m->column] = $m->value; $tbody ='';//matrix rows $thcols = '';//matrix table column headers $i = 0;//set counter not to output extraneous column label headers $c = true;//set odd/even rows class foreach ($products as $row => $cols) { //matrix table row headers (first column) $rowHeader = $pages->get($row)->title; $tbody .= "<tr" . (($c = !$c) ? " class='even' " : '') . "><td class='MatrixRowHeader'>" . $rowHeader . "</td>"; $count = count($cols);//help to stop output of extra/duplicate column headers foreach ($cols as $col => $value) { //matrix table column headers $columnHeader = $pages->get($col)->title; //avoid outputting extra duplicate columns if ($i < $count) $thcols .= "<th class='MatrixColumnHeader'>" . $columnHeader . "</th>"; //output matrix values $currency = $value > 0 ? '£' : ''; $tbody .= "<td>" . $currency . $value . "</td>"; $i++; } $tbody .= "</tr>"; } //final matrix table for output $tableOut = "<table class='Matrix'> <thead> <tr class=''> <th></th> $thcols </tr> </thead> <tbody> $tbody </tbody> </table>"; echo $tableOut; The module provides a default rendering capability as well, so that you can also do this (below) and get a similar result as the first example above (without the captions). echo $page->matrix; Or this foreach($page->matrix as $m) { echo $m; } Finding matrix items The fieldtype includes indexed row, column and value fields. This enables you to find matrix items by either row types (e.g. colours) or columns (e.g. sizes) or their values (e.g. price) or a combination of some/all of these. For instance: //find all pages that have a matrix value of less than 1000 $results = $pages->find("products.value<1000"); //find some results in the matrix (called products) of this page $results = $page->products->find("column=$country, value=Singapore");//or $page->products->find("column=$age, value>=25"); //$country and $age would be IDs of two of your column pages Other more complex queries are possible, e.g. find all products that are either red or purple in colour, come in x-large size and are priced less than $50. Credits @Ryan on whose Fieldtype/InptufieldEvents this is largely based @charger and @sakkoulas for their matrix ideas Screens Field Details Tab Inputfield Larger matrix table Example output
    1 point
  10. I'm on a DS412+ with 3x 4TB WD RED drives in it. A little annoyed that WD RED are now 6TB and I could have more space if I buy some of those, but whilst I've still got one bay spare and a lot of space left in this RAID configuration I have no need to upgrade - I just like the idea of having even more space I've not really tried to run it as a server but I'm sure it could, albeit a bit underpowered. What I'd really like to see is one of their smaller units with a punchier CPU and more RAM. That said, it's good enough to stream movies to a smart TV using PLEX (worth a look for those with media collections) without transcoding or buffering - even with large blu-ray files, though it will depend on your TV's ability to read MKV files or other similar uncompressed formats (I know that's not their technical term, but a good way to describe them). I use TeamViewer quite a bit which is similar. Helpful for diagnosing issues customers run into like email config issues or those times when a customercan see an issue but you can't replicate it. TeamViewer also lets you keep contact lists so you don't have to remember the login details every time - just prompt the customer to let you on to their machine and you're away. (I said "customer" instead of "client" there to avoid confusion with software clients ). I have also, on occasion, used it on a laptop when I needed to check something on my PC at home, though that only works if my wife turns the PC on since I always shut it down. You can set that up for unattended access via a password so on the off-chance you did leave the PC on it's just a few clicks away from wherever you are. But yes, with cloud storage there isn't usually much need. With web access to your Synology also a possibility it's like having your very own Google drive but without Google
    1 point
  11. I am sure this thread should actually be called "I've got a brand new pair of roller skates." (Apart from a nice fit, deal old Melanie really does have the most incredible brown eyes. My bother took me to see her play at the Glastonbury Fair when I was young and I was totally besotted!)
    1 point
  12. Ah, right (was definitely not looking in the right places)... Would be nice if it was built in: $button->addClass('ui-button-float-right').
    1 point
  13. VPN for me for some years now with a Web host. Have got a 4 bay Synology that I've burned all my DVDs to (finally legal to make backups in the UK) but also it is configured to download backups from the VPS overnight. It can also be run as a Web server but I've always just used WAMP (found it better than XAMPP) on my local machine for development.
    1 point
  14. Oh, okay! Yes, I did similar several years ago, but we were having too many problems with power outages at the time - I gave up. Now I just have a little dev server by my desk running ubuntu and webmin/virtualmin.
    1 point
  15. @Joss, I took the advice of Diogo and not put client websites on it. I put owncloud on it and a few sites of my own, the whole thing is actually for me to learn new things.
    1 point
  16. Found the issue, posted a possible solution on GitHub.
    1 point
  17. I'll try that. Thanks Mr. Geerts. I also found it's already possible from 2.3. Post here from Mr. Cramer. I'll add it to the list of "things I really want PW to do which are in fact already possible"
    1 point
  18. Ok, v3 takes care of populating the description fields for the new image pages. The one thing I don't like about all this is the duplication of the image files themselves. Maybe the module should delete the original images after the child pages have been created?
    1 point
  19. I see many comments about SSDs and WINDOWS ... anyone running Linux 24/7 on a SSD? This coming 2015 income tax refund will be enough for me to totally replace my custom build PC, which I have used for the past 6-7 years. Am seriously looking at replacing EVERY single component and converting the existing system into a media server for family use.
    1 point
  20. Why not using a template for this?
    1 point
  21. Sure, though the approach depends a lot on your needs. Are your top menu items always placeholders for grouping pages or can some of then be actual pages, how deep or complicated will your site hierarchy be and does the top menu have to reflect that somehow, etc. Assuming that this is a very simple setup (no real pages in top menu at all), one approach would be creating top menu structure somewhere else (as pages), and adding a "top menu parent" Page field to pages. If a page has this field filled, it'll be displayed under said top menu item: - Home - Who we are - About us - History - Values - Meet the Cashmaster Team - ... - Topmenu - About Us - About You - ... You'll need to write your own code to create markup for the top menu, and probably side menu (if you use one), but that's just about it. Something like this should work: echo "<ul>"; foreach ($pages->find('template=top-menu-parent, sort=sort') as $parent) { if (!$parent->numChildren(true)) continue; echo "<li>{$parent->title}<ul>"; foreach ($parent->children as $child) { echo "<li><a href='{$child->url}'>{$child->title}</a></li>"; } echo "</ul></li>"; } echo "</ul>"; Anyway, this is just a very crude and basic example, so if your needs are more complicated than that, there are other approaches that may make more sense. Path/URL rewriting might be one option, etc. In any case most likely you'll never need to change any core code
    1 point
  22. Hi everyone! I'd like to introduce PassiveCron - a module, which allows developers to schedule cronjobs - to you. This will be Conclurer's second Pro Module, following ProcessImageMinimize / minimize.pw. PassiveCron is available now as a beta version. What is it going to do? Have you ever been in a situation, in which ProcessWire ran out of PHP's max_execution_time, because you're doing cool tasks like resizing dozens of images using PIM? Or have you noticed site load performance issues when doing a lot of tasks simultaneously? PassiveCron will fix this by giving developers the ability to schedule tasks to future and / or repeating points in time run tasks asynchronously Isn't this exactly the same as LazyCron? No. LazyCron runs your tasks synchronously as your page loads. So running larger tasks will decrease your page's load performance. Instead of this, PassiveCron is able to run those tasks separately from your site loads, thanks to our new web service cron.pw, which will be released together with PassiveCron. How can I use this in my site / module? We will bundle PassiveCron with an easy-to-use API. Let's say you want to call a specific module action tomorrow at 8:00 am: $cron->tomorrow->at('8:00 am')->run('Class', 'Method'); Or do this specific cleanup task, every night at 3:00 am: $cron->every("day")->at("3:00 am")->run("Class", "Method"); Or just run this one large task asynchronously: $cron->run("Class", "Method"); How much will it cost? We are planning to give every ProcessWire site 200 task executions / day for free. For unlimited task executions per site, it'll be around 5€ (pay once, use forever). During the beta period, no payments will be available. Features overview Easy-to-use API for asynchronous task execution Integrable into existing modules for load time improvements No registration at cron.pw needed Pro Cache will be bypassed En- or disable PassiveCron per module Free minimize.pw background tasks Dashboard with reports per task So, what do you think? Is such a module what you need? Can you imagine additional features or do you have wishes for PassiveCron? Please tell us in the comments. Thank you very much!
    1 point
  23. Repeater pages have a method getForPage() to get the page the repeater is living on.
    1 point
  24. [quotamos]This is really interesting stuff and I'm learning so much from it. I've already tested Soma's code and it works very well. Is there a way of configuring $form->render() so that it outputs different html (divs for ul/li etc.)? [/quotamos] you.can usage. $form->setMarkup(); und $form->setClasses(); two.set markups und html caresses. see.eliamos /wire/core/InputfieldWrapper.php
    1 point
  25. For any PageArray, count($pageArray) returns the number if items present now, but $pageArray->getTotal() returns the number of items total without pagination. So if you specified a "limit=n" in your selector when loading the pages, you can always call upon that $pages->getTotal() to tell you how many matched in total. There is also a $pageArray->getStart() method, which tells you the index of the first item. So if you had specified "limit=10" and you were on page2 in the pagination, then getStart() would return 10. I use these two functions to output a summary of results that tells you were you are. So if you wanted a headline that said this: You'd do something like this: $firms = $pages->find('parent=/firms/, num_staff>100, limit=10'); $start = $firms->getStart() + 1; $end = $firms->getStart() + count($firms); $total = $firms->getTotal(); echo "<h1>Firms with more than 100 staff</h1>"; echo "<h2>Showing firms $start - $end of $total</h2>"; foreach($firms as $firm) { echo "<p>{$firm->title} has {$firm->num_staff} staff</p>"; } // output the pagination links echo $firms->renderPager();
    1 point
×
×
  • Create New...