Jump to content

ryan

Administrators
  • Posts

    16,714
  • Joined

  • Last visited

  • Days Won

    1,515

Everything posted by ryan

  1. If anyone is interested in experimenting with this one, grab the latest dev branch. In your selector to $pages->find(), you can specify get_total=count to make it use the count method rather than the calc method. You can also specify get_total=0 to disable any kind of total counting. Though note that it's only counting totals if you have a "limit=n" (where n is any number), so don't bother trying to change the count method if you aren't using limit=n somewhere in your query. Example: // calculate total using count method $t = Debug::timer(); $items = $pages->find("template=basic-page, limit=1, get_total=count"); $total = $items->getTotal(); echo "<p>Found $total items in " . Debug::timer($t) . " seconds using count</p>"; // calculate total using calc method (default) $t = Debug::timer(); $items = $pages->find("template=basic-page, limit=1, get_total=calc"); $total = $items->getTotal(); echo "<p>Found $total items in " . Debug::timer($t) . " seconds using calc</p>"; // bypass any kind of counting $t = Debug::timer(); $items = $pages->find("template=basic-page, limit=1, get_total=0"); $total = $items->getTotal(); // will be 0 or 1 echo "<p>Found $total items in " . Debug::timer($t) . " seconds with total count disabled.</p>"; One thing is for certain: counting totals takes up significant overhead regardless of count method. For large scale usages, having the option to disable total counting with get_total=0 will be valuable for sure. For instance, if you wanted to retrieve the 3 newest news items, but didn't care how many there were total, get_total=0 would be worthwhile. Likewise, if you are using a "Next Page / Prev Page" type of pagination (rather than numbered pagination links) then you also wouldn't need the total count.
  2. Or you could use this undocumented feature: Edit your /site/config.php and set $config->advanced = true; In your admin, go to Setup > Templates > your-post-template Click to the "System" tab. See the last field: "Allow the created user to be changed on pages?" Check that box and Save. Restore your config.php back to normal: Edit your /site/config.php again and set $config->advanced = false. Now you should be able to change the "Created User" on the Settings tab of any pages using that template.
  3. I've updated PageFinder to support both the SQL_CALC_FOUND_ROWS and the COUNT(*) method so that I could compare them. I found some interesting results. My conclusion is that COUNT(*) is indeed faster in many instances, but SQL_CALC_FOUND_ROWS is faster in many other instances. Sometimes one is even twice as fast as the other, making me think we might need to build some logic into PageFinder to help it decide which method to use. Though I'm not yet certain why one is counting so much faster than the other at present. Here are the results. Numbers are in seconds. This was testing on a site with ~45k pages. 1. Selector: id>1 (matches 45786 pages) AVERAGE TOTAL (50 finds) ------------------------------------------- CALC: 0.030606 1.5386 COUNT: 0.026732 1.3451 WINNER 2. Selector: template=facility (matches 38008 pages) AVERAGE TOTAL (50 finds) ------------------------------------------- CALC: 0.197568 9.9118 COUNT: 0.183608 9.2142 WINNER 3. Selector: template=facility, title*=senior (matches 1207 pages) AVERAGE TOTAL (50 finds) ------------------------------------------- CALC: 0.053222 2.6943 WINNER COUNT: 0.08826 4.4469 4. Selector: template=facility, capacity>5 (matches 28616 pages) AVERAGE TOTAL (50 finds) ------------------------------------------- CALC: 0.347964 17.4320 COUNT: 0.208856 10.4764 WINNER 5. Selector: template=facility, capacity>5, zip!='' (matches 28145 pages) AVERAGE TOTAL (50 finds) ------------------------------------------- CALC: 0.61547 30.8082 COUNT: 0.407376 20.4028 WINNER 6. Selector: capacity>5, zip!='', limit=2 (matches 28145 pages) AVERAGE TOTAL (50 finds) ------------------------------------------- CALC: 0.435284 21.7988 WINNER COUNT: 0.903338 45.2016 7. Selector: capacity<5, zip!='', limit=2 (matches 4713 pages) AVERAGE TOTAL (50 finds) ------------------------------------------- CALC: 0.097256 4.8961 WINNER COUNT: 0.176476 8.8574 Here is the script I used to test: <pre><?php include("./index.php"); $timers = array(); $selector = "id>1, limit=2"; // change to desired selector $totalTimer = Debug::timer(); $totalRecords = 0; $max = 50; for($n = 1; $n <= $max; $n++) { $timer = Debug::timer(); $items = wire('pages')->find($selector); $totalRecords = $items->getTotal(); $elapsed = Debug::timer($timer); $timers[] = $elapsed; // clear the find() cache so it doesn't get reused on next find() wire('pages')->uncacheAll(); } $total = 0.0; foreach($timers as $elapsed) $total += (float) $elapsed; $average = $total / count($timers); echo "Selector:\t$selector\n"; echo "Average:\t" . $average . " seconds per find()\n"; echo "Total Time:\t" . Debug::timer($totalTimer) . " seconds for $max find()s\n"; echo "Total Pages:\t$totalRecords\n";
  4. Thanks Hari, excellent observation and I will take a closer look at this. While COUNT(*) is very fast in that context, ProcessWire never executes such a query with no where or join conditions. If I recall that speed difference doesn't hold true once you are counting the results of a rather complex query (as most PW page queries are). Though if we can tweak a little more speed out of using a count rather than a select found_rows() then I'd be all for it. I've been through this consideration before and had settled on sql_calc_found_rows being the better option at the time, but it's been awhile and I'd like to revisit it. I'm now working on a project with apeisa where we deal with hundreds of thousands of pages and we're always looking for ways to optimize performance, so it seems like a good opportunity to benchmark this again. One thing to mention also is that the PW dev branch is more optimized in this respect. It is quite a bit more selective as to when it uses SQL_CALC_FOUND_ROWS, which ensures it's not putting that overhead on top of situations where it doesn't absolutely need it. You can also disable the behavior in your $pages->find() call by specifying the 'getTotal' option as false, which tells PageFinder not to attempt to determine the total number of matches. But specifying it wouldn't be necessary unless your selector string included a limit=n in it, as PW dev doesn't attempt the count unless you are using a limit (presumably for pagination). $options = array('getTotal' => false); $items = $pages->find("selector", $options);
  5. VIM for most quick code editing. PhpStorm (in VIM mode) when I have time to sit and focus on coding. I enjoy using it quite a bit. But the overhead is definitely noticeable relative to using VIM on its own. TextWrangler for quick stuff. I especially like TextWrangler for search/replace with regular expressions, as it's more straightforward than doing it in VIM or PhpStorm.
  6. wireRelativeTimeStr() has been there since PW 2.3 if I recall correctly. All the words in it are translatable via the translation tool pointed at /wire/core/Functions.php.
  7. You are right the SR-80s really aren't comfortable for very long periods. Though they don't bother me too much. Mine are old enough that the foam surrounds have started to disintegrate (which is apparently normal) so I've got to order some new surrounds, or whatever they are called. The main reason I still use the Sr-80s is because they are open air and I can still hear when people need me (lots of interrupts when you've got little kids). Otherwise, I have a strong preference for the sound of the Vmoda headphones, but they really do isolate you from the rest of the world to the point where I'm no good to anyone else when I've got them on. I bought the Vmodas because Amazon had them on a $50 lightning deal last year (they are usually like $130), otherwise I wasn't in the market for them. I have tested out the Beats by Dre a couple of times just because they are always around in stores to try. Even on the $300 monsters, maybe they are comfortable, but the sound doesn't suit me (which is good, because I'd never spend that much). Maybe they've got bass, but it sounds and feels like plastic headphone bass rather than real bass, to my ears at least. These kinds of flavored cans (including Vmodas too) I suppose are more subjective to the individual than flat ones.
  8. My brother has some Audio Technica ones and I like them. I haven't used them next to others, so don't have a good comparison, but I did find them very comfortable and with very nice sound. I personally use Grado SR-80s and Vmoda Crossfade LP. I'm mixed on the Grado headphones... they sound great, supposedly excellent, but I think for someone else's preferences. I love the sound of the Vmoda headphones though. They are heavy on the bass and soundstage for sure, but in a way that's real / you can feel, like you are in a movie theater... makes me forget I'm wearing headphones. Honestly though the best value I've seen for headphones is with these Panasonic earbuds. Both my wife and I use them to replace our mobile phone earbuds, and the incredible sound that comes out of those $8 earbuds is hard to believe.
  9. File and image fields now support multiple languages for the description (in the current PW dev branch). The multi-language capability was built directly in the existing file/image fields, so nothing needs to be installed/modified–they simply become multi-language when you've got language support active. Thanks to stardesign for sponsoring this addition.
  10. AutoLinks has been updated with the following additions: Multi-language support: You can now specify different sets of terms per language. Max linked terms option: You can now specify the maximum terms that will be linked in a block of copy. Markup for links: It will now let you control the markup for auto-generated links and you can specify different markup for internal and external links. Allowed tags whitelist: You can now specify a whitelist of tags where auto-generated links are allowed. For example, if you didn't want it generating links in headlines, you might tell it to only generate links in paragraphs <p> and list items <li>.
  11. Probably not. The Table ProField is good for repeated tabular information. If your user profile needed to include a links, memberships, family members or something like that (each with multiple properties) then the Table field would be good. But the examples you listed all sound like they would still be best kept as separate fields to me. The only exception would be that I think you might potentially benefit from combining Hobbies, Dislikes, and About Me into a single Textareas field (similar to what @peterfoeng mentioned). This doesn't sound consistent with ProFields, or ProcessWire for that matter. If you are setting up a forum, your best bet us to use a forum software. We use IP.Board here and really like it, but there are plenty of other great forum packages that are smaller in scope too (I've heard good things about Vanilla). Also, I wouldn't worry about having too much power when it comes to forum software. Even if your needs are only basic, having a powerful forum software doesn't necessarily make it harder to implement. It just makes it more likely that it'll do what you need it to, when you need it to. The Page fieldtype won't be part of it, as Table isn't actually using Fieldtypes. But some kind of Page reference field will likely be added to Table.
  12. Table Use this for tabular data, like rate tables or other things that you might typically represent in a spreadsheet. Use it for situations where you don't need the full-blown flexibility of repeaters, as it's technically more efficient with far less overhead than repeaters. Something like the Events Fieldtype could be very easily re-created via a Table field, but the potential uses are far broader. But for the most part, think tabular data when it comes to the Table field. Multipliers This is good for when you need a range of values (whether text, textarea, numbers, dates, etc.). If you are using repeaters with just one field in them, you might be a lot better off with a Multiplier. Like the Table field, Multipliers are very efficient and low overhead relative to something like Repeaters. Use Multipliers when you need to repeat a single input multiple times, optionally with a min and max number of inputs. Lets say you are building an employee directory, and each employee has between 1 and 3 email addresses. Rather than using 3 separate email fields, you would use 1 multiplier field and specify min=1 and max=3. Repeaters These are infinitely flexible in terms of what they represent, but each row of values is technically a page in the system. As a result, with the flexibility comes significant overhead. This is really only an issue when the quantity of repeater items gets high, or when you have lots (thousands) of pages using repeaters. I recommend repeaters for setting up things like homepage carousels. For example, if you go to the Villas of Distinction homepage, there are 3 separate repeaters in use on that page, each holding a photo, title, description, link. The client can have as many items in each of those sections as they want. Currently it looks like the first repeater as 6 items, the 2nd has 2, and the 3rd has 6. The possibilities of what can be represented with repeaters is endless, but look for potential alternatives when dealing with large quantities (whether large quantities of repeater items, or large quantities of pages using repeaters). PageTable This is one of the ProFields that is available for free (thanks to Avoine sponsorship) on the ProcessWire dev branch. Meaning, it'll be available for everyone to use as part of the core in ProcessWire 2.5. And you can use it now if you don't mind running the dev branch. PageTable has all the flexibility of repeaters, but with lower overhead from the admin/input perspective. Rather than trying to bundle all the inputs on one screen, PageTable shows you a table of items and you click on the item to edit it in a modal window. This enables it to be a lot more efficient from the admin UI perspective. It's also more flexible than repeaters are in terms of where you store your items. PageTable lets you choose where they should live, whether as children of the page being edited, or as children of some other parent page you designate. They might be a little more work to setup than repeaters, but I think that most situations where you need the flexibility of repeaters may be better served by PageTable. PageTable still can't compete with the speed and efficiency of Table or Multiplier, but consider using PageTable anywhere that you might have used Repeaters before. Repeaters and PageTable are fundamentally different from the admin UI/input perspective, so you'd want to compare them yourself to see what suits your individual input needs better. PageTable involves more clicking to create and edit items, making Repeaters potentially faster for entering data rapidly. But PageTable will scale much further in the admin UI than Repeaters will, so I would personally favor PageTable in more situations than Repeaters.
  13. Definitely still use for repeaters, but fewer for sure. I think it's all a good thing to have more options, as I expect repeaters will end up being used more for more appropriate situations rather than for everything.
  14. We already have a dedicated Inputfield for this: InputfieldCheckboxes. Use that as your selection when creating a Page field, and you'll have exactly what you are talking about (I use it regularly for that purpose).
  15. Multiplier and Table can be used as more efficient (and perhaps preferable UI) repeater replacements in a lot of instances. If either Multiplier or Table will serve your needs as well as repeater, they will be able to scale a lot better than repeater. File fields aren't supported by Table at present. I agree with Antti that PageTable is your best bet to replace repeaters for your particular need. While PageTable won't be as fast/efficient as Table, it will still be a lot better than repeaters in that respect. PageTable is actually very simple and I think you'll find it easy to get going without needing to read anything about it. From the API side you are just dealing with a PageArray like any other.
  16. ProFields just comes in 1 edition, unlike FormBuilder and ProCache which come in either: Single, Professional, Developer or Agency editions. The ProFields edition is the equivalent of the Developer edition of FormBuilder and ProCache, in that you can use it in as many sites as you develop, for as long as you want to. I figured there wasn't much point to having individual site licenses with a multi-module package because chances are you won't use them all together on one site. It's more likely that folks will use one or some of the ProFields on some sites, and others on other sites. We want it to be a toolbox you've always got available to you when you need it.
  17. I updated the wording on the page to just this: "The license to install ProFields and receive support goes to the purchaser."
  18. Sorry, I will try to word that better. What it means is that that the license to create new installations goes to the purchaser. If it's purchased on a client's credit card, then they are the purchaser. If you pay for it, then you are the purchaser. The purchaser can put it on any sites that they design/develop (whether for themselves or their clients). If you want to mark it up and charge the client for it, that's fine. It's just that when you buy a product in the store, you are buying support of the product, so we have to know who is the person that gets support. That's all it is.
  19. This is not possible, as fields in the Table represent literal fields in a MySQL database table, not ProcessWire fieldtypes. For instance, when you define a radio buttons or select input in your table, you are literally defining a MySQL ENUM field. And when you define a checkboxes input, you are literally defining a MySQL SET field. In this sense, the Table field is incredibly efficient and fast, as there's really no middle layer between your content and the database table. However, if you need multi-language text fields, you'd want the flexibility of either Repeaters, or the new PageTable field (now available for free on the dev branch). All the ProFields are available as of this morning in the ProcessWire store. I agree regarding Joss's voiceover. He heard my other pirate voiceovers and basically said: "step aside son, let me show you how this is done." I wrote a rough script and sent it to him. 30 minutes later, he replied with a voiceover that had everything in the script but majorly improved and with SO much more good stuff. All the funny lines are all Joss. My favorite is the "chuck 'em overboard to let the porpoises nibble on 'em."
  20. Good question Alan. Here's a screenshot of the module config screen that I think answers your question. See the two settings at the bottom where you can define the max times to link and the distance required between links. AutoLinks is of course also smart enough not to attempt linking things that have already been linked.
  21. Introducing ProcessWire ProFields: Table – it lets you literally define your own Fieldtype! This is one of the most exciting ProFields and it's something very different than any other Fieldtypes. I think it is best described by this screencast (be sure your sound is on): Special thanks to Joss for his great voiceover on this screencast. Please view the video at 720p and full screen if possible. Read more about the Table Field Table is part of the ProcessWire ProFields package now available for purchase in the ProcessWire store.
  22. Introducing the AutoLinks Text Formatter, part of the ProcessWire ProFields package of modules. What it Does This Textformatter module automatically links your specified phrases/words to your specified URLs. This is an excellent SEO and accessibility tool for creating automatic contextual links with little effort. If there are pages that you commonly link to in your site from your textarea/rich text fields, then this Textformatter can save you a lot of effort, automatically linking to those URLs. Furthermore, contextual links of this sort are also considered especially valuable from an SEO context. Because this module is a Textformatter module, the work it does happens at runtime. That means that this module can easily be applied to existing sites, no matter how large. Usage Example We'll use processwire.com as an example. Throughout processwire.com, we routinely use the terms "API", "selector", "template", "template file", "$page", "$pages" and more. In the past, I've spent a lot of time in TinyMCE manually linking these terms to the appropriate pages, as it is a helpful cross-reference for users. For example, when the term "API" appears, I want to automatically link to the API Cheatsheet page at http://cheatsheet.processwire.com. With the AutoLinks Textformatter module, I can now automatically link to all my important terms from all existing and future body copy. If one of those links happens to change in the future, no problem, as I only have to update it in one place (if at all). The benefits here are a real win win for the users of processwire.com, myself (in time savings) and our performance with search engines that analyze these contextual links. We hope that you find AutoLinks to be a huge benefit to your site(s) and time saver for you and/or your site editors. AutoLinks is available for purchase as part of the ProFields package in the ProcessWire Store.
  23. You can multiply any type of field that holds a single value/property. This includes Text, Textarea, Integer, Float, Email, Datetime, Selector and URL. It can also multiply 3rd-party Fieldtypes as well (so long as they are single-property).
  24. Similar only in the multi-value aspect. Repeaters are creating a new page for each item, and that page can have any fields. That's incredibly powerful, but also consumes a lot of resources. That's why we don't recommend repeaters in large quantities or other large scale usages. Multipliers on the other hand multiply an existing Fieldtype like Text, Textarea, Integer, Email, etc. (including those that don't yet exist), without any overhead or additional resources. They are incredibly scalable. Like all the ProFields, Multipliers are a tool that enhances things you can already do [with repeaters] by doing them more efficiently and in a more focused way. They are especially desirable those using PW for large scale projects. They may also be preferable from the admin UI aspect in that they don't have to be as flexible as repeaters, so they can stay more focused on the UI side as well. Language text fields (FieldtypeTextLanguage and FieldtypeTextareaLanguage) are multi-property fields. Multiplier can only multiply single-property fields at present (though most Fieldtypes are single-property Fieldtypes). On the core side, Multiplier can multiply: Text, Textarea, Integer, Float, Email, Datetime, Selector and URL. It can also multiply 3rd-party Fieldtypes as well (so long as they are single-property). However, it is technically possible to multiply multi-property Fieldtypes as well, so I am planning to add support for multi-property Fieldtypes in one of the next versions of Multiplier. This would enable you to multiply Fieldtypes like TextLanguage, TextareaLanguage, and MapMarker (and other 3rd party multi-property Fieldtypes). Since there are a whole lot more single-property Fieldtypes, Multiplier is focused on those for this first version.
  25. Previously I posted about Textareas. The next field coming in ProFields is called Multiplier. This field lets you take almost any existing single-value Fieldtype, and use it as a multi-value Fieldtype. Single value Fieldtypes are those that store one piece of information at a time, for example: Text, Textarea, Integer, Float, Email, URL, etc. Any of these, and more can be multiplied with Multiplier. Here's a short video introduction to Multiplier. Like with the previous screencast, I recommend upping the quality to 720p and viewing full screen. This one also includes narration, though we're in allergy season here so my voice is a little rough. The next fields I have to tell you about in a few days are: Table, PageTable and AutoLinks.
×
×
  • Create New...