Jump to content

Leaderboard

Popular Content

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

  1. Inputfield Page Source Display a string with the rendered output of the Page (per it's Template) in an Inputfield. The markup could be copied with a button click (flash enabled browsers) and/or copied manually from the Inputfield. The rendered output is a runtime only value which is not stored in the database. Potential Use Provide an easy way for editors to copy the sourcecode of the page for the use in newsletter services and such. Note ! This Inputfield should not be used in the page template directly. (could give some “funky” results ) Download on GitHub
    8 points
  2. New addition: retinafy! this was created on request from @jjozsi here in this post. . * retinafy // create a pageimage with any method you like $image = $page->images->first()->size(400, 300); // call retinafy on it echo $image->retinafy(); // it outputs a markup string like this, where width and height is populated with half the sizes of the pageimage <img src="/site/assets/files/1234/basename.400x300.jpg" width="200" height="150" alt="description" /> . . The default markup template has the default replacements URL, WIDTH, HEIGHT and DESCRIPTION. <img src="[URL]" width="[WIDTH]" height="[HEIGHT]" alt="[DESCRIPTION]" /> You can change that to any markup you like in the modules Configpage! . . If you have additional properties populated with pageimages in your system, you can provide an array with those property names: // if you need custom properties in your markup, define the template in the modules config page with those placeholders, // please only use UPPERCASE and wrapp these [ ] around them <img src="[URL]" width="[WIDTH]" height="[HEIGHT]" data-custom1="[CUSTOM1]" data-custom2="[CUSTOM2]" /> // call retinafy with custom property names $customPropertyNames = array("custom1", "custom2"); echo $image->retinafy($customPropertyNames); // it outputs a markup string like this, where width and height is populated with half the sizes of the pageimage <img src="/site/assets/files/1234/basename.400x300.jpg" width="200" height="150" data-custom1="custom-value-1" data-custom2="custom-value-2" /> . . Regarding to the technique described in the article @jjozsi linked to in his post it would make much sense to use a low quality setting sitewide by defining it in the ImageSizerOptions, also available on the Pia Configpage. Otherwise, if this is not possible, you need to call your images for that you want the retinafy markup with the quality option set: // create a pageimage with any method you like echo $page->images->first()->size(400, 300, array("quality"=>35))->retinafy();
    4 points
  3. Found the issue, posted a possible solution on GitHub.
    3 points
  4. 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"
    3 points
  5. Here the same, but switching wire folders reveals the bug. (switch between, 2.5.7 and 2.5.14) // here $data is an empty array, but it shouldn't. Think Ryan has broke something. public static function getModuleConfigInputfields(array $data) { } I've posted an issue on github.
    3 points
  6. @mrkhan As you found out, that only removes part of the settings page. Sorry to say that there is no simple way to do this yet on a per-role basis. There is a way you can do it for a template regardless of role but it needs a little code. To Remove The Tab Regardless Of Role... To remove the whole tab you need to set the 'noSettings' property on the template used by those pages. If you already have a template file set up for that template then paste this in, edit as needed, and view any page that uses the template... $temp = $page->template; $temp->set('noSettings', 1); $temp->save(); When you next edit any pages using that template in the admin interface, you'll find that the settings tab has gone. To get it back change the 1 to a 0 and re-view the page in the front-end and the tab will be back in the admin interface. If you don't have a template file attached to the template just create one and add it to the template, view a page, and remove the template file afterwards. Edited to add: Actually, there might be a hook that can be used for this. I'll see what I can find later if no-one else gets to it first. Here's a working idea - totally untested and probably not working... <?php class AdminHelperHooks extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'My Admin Helper Hooks', 'version' => 1, 'singular' => true, 'autoload' => true ); } public function init() { $this->addHookBefore('ProcessPageEdit::buildForm', $this, "removeSettings"); } function removeSettings(HookEvent $event) { if(wire('user')->hasRole('webmaster')) { wire('page')->template->set('noSettings', 1); } } }
    3 points
  7. I have updated Pia with this retinafy: https://github.com/horst-n/PageimageAssistant/commit/d31d743533133b130131d8c5b042bd510bf68bb2
    2 points
  8. $item->price_currency returns page id like it should. $item->price_currency->title should give you what you are after. If these don't work, then make sure you have single page reference for the field price_currency. If this $item->price_currency->first()->title works, then your field returns multiple pages (PageArray).
    2 points
  9. It probably has something to do with the fact that admin themes were, once upon a time, not handled as modules. So, somewhere along the line, it loads up `templates-admin` instead of the module. Hope Ryan completely removes it when 2.6 comes out... /Nudge /Wink
    2 points
  10. 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
  11. This is a good case for being able to use a page table to not just create additional pages for a given page, but also to be able to select any existing page table created page. (A bit like a page field, but with the creation advantage of a page table) In the meantime, you can use a page field. So: You create a page called Colours. Below that you have children, each representing a colour. Those can have other fields associated, for instance a price field if colours cost differing amounts. Using your page field, you can select the colour parent and that gives you access to all its children. Using ASM select, you can now add lots of attribute parents and their children in the same way. They will need some common fields like a price field so that you can have just one method of adding up the numbers. But other than that you can rely on the individual templates for rendering out the info.
    1 point
  12. Hi Jay and thanks for the interest. What you are describing is not something I would recommend doing by using PadLoper product variations. In PadLoper each variation requires page id, so you can build variations using pages, repeaters or PageTable. That allows each product variation have their own unique price and stock. What you are after are more like perks or modifiers. Like additional services or modifications on product - which either increase or decrease the price and they don't have stock of their own. I have been thinking about that concept and will add those at some point, but you won't find them from first release. Although I am planning good hooks to make it possible to add things like that pretty easily with little custom coding per site.
    1 point
  13. here is one more solution, created / based on Somas module
    1 point
  14. i found a possibility.. which has nothing to do with my code.. in some way.. if i know more i will tell you in this post. tab has a lower id in the child generator then the konfiguration, so there is an possibility that the tabs are getting created before the configuration so obviously the tab cannot find the config.
    1 point
  15. Nice one Mike! You're a king. Nice and succinct answer!
    1 point
  16. Under your template's Advanced tab, you can add your field names under "List of fields to display in the admin Page List" Update: There also this (not sure on 2.5 compatibility, if that's what you're using)
    1 point
  17. For information why your code didn't work have a look here: https://processwire.com/talk/topic/4680-block-access-to-settings-delete-and-view-tabs-for-page/#entry83981
    1 point
  18. The automatic limit comes from the ProcessPageSearch module. wire ▸ modules ▸ Process ▸ ProcessPageSearch Line 55 protected $resultLimit = 25; ServicePages calls $process->executeFor(); and in that function the limit is set. $limit = $this->resultLimit; Setting the limit via URL (see code below [Line 200]) works fine for me but the input field has no effect at all. if($name == 'limit') { $limit = (int) $value; $this->input->whitelist('limit', $value); continue; } Btw: I get the limit parameter two times: {"selector":"template=cranach-house, limit=25","total":2,"limit":25,"start":0,"matches":[{" ... EDIT: ok, I guess there is a mixing up. In the module settings you enter the maxLimit value the url parameter is allowed to be. Example. Maximum pages to match per request is set to 20. http://.../service-pages/?...&limit=12 => WORKS http://.../service-pages/?...&limit=22 => DOES NOT WORK {"errors":["Out of bounds limit setting (max=20)"]} maxLimit != limit The limit parameter can only be overwritten by URL parameter.
    1 point
  19. For those interested in testing, please use the latest code from GitHub. (Still versioned 0.1.2, but with quite a few changes.) Please test in the latest PW dev, this is now intended for PW 2.6.
    1 point
  20. I have just completed a full translation (meaning every strings are translated). It is available here: https://github.com/plauclair/pw_french/tree/2.5.3 @ryan, it seems like the old maintainer hasn't been active in a very long time, is it possible to make my repo the default one? Thanks!
    1 point
  21. you should maybe reference the name which is already the 3 letter code; the title also can be the same uppercase code; where you are echoing you could use a function to convert to the right entity function get_cur_symbol($price,$cur) { $symbol = ''; switch($cur) { case 'USD': return '$'.$price; break; case 'AUD': return 'AU$'.$price; break; case 'CAD': return 'CA$'.$price; break; case 'GBP': return '£'.$price; break; case 'JPY': return '¥'.$price; break; case 'EUR': return '€'.$price; break; case 'CHF': return 'C'.$price; break; case 'CZK': return 'K'.$price; break; case 'DKK': return 'k'.$price; break; case 'HKD': return '圓'.$price; break; case 'HUF': return 'F'.$price; break; case 'SGD': return 'S$'.$price; break; case 'NOK': return 'k'.$price; break; case 'NZD': return '$'.$price; break; case 'PLN': return 'z'.$price; break; case 'SEK': return 'k'.$price; break; } }
    1 point
  22. This is why we have the API...it can do all the heavy lifting...cleanly
    1 point
  23. Had to tack ->save() on to the statement setting the field...
    1 point
  24. @renobird, awesome....I just used your hook directly in my module...so it's working fine. Thanks
    1 point
  25. If no other users are allowed to the Admin, one could use Diogos module I think: http://modules.processwire.com/modules/process-admin-custom-pages/ Edit: that was the wrong module, here is the right one: https://github.com/ocorreiododiogo/ProcessHomeAdmin
    1 point
  26. Link to the module in the modules directory: Modules Directory: http://mods.pw/8s
    1 point
  27. I think it is still the case that you have to explicitly activate all languages when working with the api. More info and code in this thread. https://processwire.com/talk/topic/4383-how-to-set-language-active-via-api/ Like apeisa's last question suggests, it might make more sense if all langs would be enabled by default. Dunno if anything has been done about it, via a Github request or the like.
    1 point
  28. Version 1.0.0. Changed status to stable Updated version (big jump!) to 1 Changed db querying syntax slightly, i.e. subfields are now, e.g., products.row, products.column and products.value respectively for the matrix's rows, columns and values. I have submitted this to the module's directory and also updated the first post in this thread.
    1 point
  29. <development post> New Alpha Release - 0.1.2 (Breaking Changes) This module introduces a new feature: Mapping Collections (this is the final name for it). The feature allows you to map key/value pairs to your redirects so that you need not repeat yourself. An example would be the following: Redirect /blog.php?id=2309 to /hello-world/, by using the following redirect: blog.php?id={id} => {id|pages} You're wondering, what's {id|blog}? Simply put, that's called a mapping reference, which refers to an entry in a Mapping Collection. A Mapping Collection, in this case, would look something like this: 1=a-post 2=another-post 3=third-post ... 2309=hello-world So, when it comes time to redirect, it will scan the provided id against the collection called blog and, if it finds a match, will redirect accordingly. If, however, there is no match, the segment that asked for the mapping will be left out, resulting in an invalid URL. I may get it to insert the original capture instead. Some Screenshots: -- -- -- Full Changelog for this release: [6 Jan] - Some refactoring; moving code blocks from main module to UtilityProcess - [New Feature] Mapping Collections - Changed module title to Advanced Redirects [ALPHA] Breaking Changes: The DB schemas have changed in this release. If you already have 0.1.0 or 0.1.1 installed, please uninstall it first.
    1 point
  30. Awesome! Nice one man! You are a bloody marvellous chap. Some might say a gentleman and a scholar... I most certainly would say so! I shall follow your process process down to the wire.
    1 point
  31. Thanks Alex for catching this. I can confirm this behaviour only happens in the dev branch since the addition of the updated FieldtypeComments. Ryan managed to break something . Hey, the new fieldtype is still under development. I will bring this to Ryan's attention. Meanwhile, a workaround that I have tested is to first install the stable branch PW, install Blog, upgrade PW to dev branch. Works fine. FYI the message logs for dev branch (unsuccessful upgrade of blog_comments) 2015-01-06 18:07:29 lightning_admin http://curium-kcu.lightningpw.com/processwire/blog/ Updating schema version of 'blog_comments' from to 4 2015-01-06 18:11:06 lightning_admin http://curium-kcu.lightningpw.com/processwire/blog/ Updating schema version of 'blog_comments' from to 4 2015-01-06 18:17:05 lightning_admin http://curium-kcu.lightningpw.com/processwire/blog/ Updating schema version of 'blog_comments' from to 4 Compare that to a successful one.. 2014-11-30 01:51:37 kongondo http://localhost/pb/pb/blog/ Updated schema version of 'blog_comments' to support website field. 2014-11-30 01:51:37 kongondo http://localhost/pb/pb/blog/ Updated schema version of 'blog_comments' to support website field. 2014-11-30 01:51:37 kongondo page? Updated schema version of 'blog_comments' to support website field. 2014-11-30 01:51:37 kongondo page? Updated schema version of 'blog_comments' to support website field. 2014-11-30 01:54:34 kongondo http://localhost/pb/pb/blog/ Updated schema version of 'blog_comments' to support website field. 2014-11-30 01:54:34 kongondo http://localhost/pb/pb/blog/ Updated schema version of 'blog_comments' to support website field. 2014-11-30 01:54:34 kongondo page? Updated schema version of 'blog_comments' to support website field. 2014-11-30 01:54:34 kongondo page? Updated schema version of 'blog_comments' to support website field. 2015-01-06 17:46:32 kongondo http://localhost/pb/pb/blog/ Updating schema version of 'blog_comments' from 1 to 5 (FieldtypeComments)
    1 point
  32. Hi all, I'll take a look at any issues that are still lingering (and any suggested features/updates) ASAP. I don't know Ryan's plan for pushing things into the current master branch. I suspect that any fixes will just be part of 2.6.
    1 point
  33. I just send first newsletter out with some badly cropped screens: http://eepurl.com/bagVe9
    1 point
  34. Revisiting this: Duh! I forgot that similar to 'matrix_row' that is being mapped to 'data' and vice versa, I could also map the db columns 'matrix_column' and 'matrix_value' to 'column' and 'value' respectively as well as let 'matrix_row' be 'row' mapping to 'data'. The names of the db columns don't change; it's just how I reference them in searches/selectors. #1. This means that instead of the current prefixed sub-fields: $pages->find("products.matrix_row=$foo, products.matrix_column=$bar, products.matrix_value=foo2"); #2. We'll rename the sub-fields as: $pages->find("products.row=$foo, products.column=$bar, products.value=foo2"); Just looks cleaner and of course means less typing. Any strong objections to renaming the sub-fields this way (switching to #2 syntax above)? Been staring at this for too long!
    1 point
  35. Changed this to Beta version. I'd appreciate testing (especially character encoding issues and using CSV/Text tab delimited files generated in other systems other than Windows - Linux, Mac, etc..), thanks! Changelog Version 0.0.7 Added optional feature enabling fast import of CSV data using MySQL's LOAD DATA INFILE (off by default, set in Details Tab of Fieldtype). Version 0.0.8 Option to populate matrix table via a .csv/.txt file upload. Top and Bottom Reset buttons to clear all matrix values before save (handy when you want to restart from a clean slate). Fixed issue where saved column header label was not being selected in the InputfieldSelect in the Fieldtype's 'Details' Tab - Thx @Adrian Changed status to Beta. Version 0.0.9 Fixed a character encoding issue regarding fopen (e.g. £ sign not being displayed) - note: if you really need to save such characters in the db, then you are better off copy-pasting your CSV values rather than uploading (i.e. avoid fopen). ============== I'll be writing more advanced find examples for this field using my customer data example. e.g. find records where a customer is <=45 and lives in Cameroon.
    1 point
  36. Teppo, most of the big players (others than Google and Apple) are not ready yet. Etsy, gumroad, you name it. This whole thing got everyone by surprise. I actually called to tax office here in Finland two months ago about PadLoper sales. The answer was, that as long as I sell under 8000€ a year, no need to pay taxes - it's enough to just tell about this income (and that way I pay huge side income tax). But my point is that even tax office didn't know about this 2 months ago. The thing I'm most interested is how on earth EU believes they can even in theory collect taxes from single person from India who sells pdf book online? For me it seems that micro businesses were just not considered while making these rules and there will be sooner or later new guidelines coming.
    1 point
  37. There are cases where required logging in is beneficial. But I think that most often the simplicity of "click a link and download" is what one expects. This also leaves all the stress of creating and managing user accounts etc. Orders are tied into user accounts, if buyer is logged in while creating the order. So one can create that kind of functionality if required. PadLoper won't offer it out of the box though.
    1 point
  38. It depends on what kind of payment gateway you use. If you don't have need for saving the credit card numbers in your service (for "one click checkout"), then there you don't have any need to collect credit card information in your service either. Both payment gateways that PadLoper will ship (Stripe and PayPal) asks for credit card information on their services, so using them makes your service PCI compliant (or to be exact - it removes the need from your service to be PCI compliant, since you are not handling credit card information at all). Yes - although not on the first release. I want to wait little and see how things are developing on that. I have a gut feeling that there are some more changes coming. The tax class system I have in place does already have possibility to define different taxes based on location (country & state supported). It seems that digital products was just beginning, EU will be rolling changes on all sales in upcoming years. Regardind order states: I am currently wondering this one: I found most of those statuses confusing and something where the shop owner needs to define meaning. I am looking for more specific toggles, like: - order successful / failed - order delivered / not delivered - order paid / not paid What causes me some problems are those custom situations like "returned", "cancelled" etc. I think those cases a little. Then there will be order notes also. Yes, there will be invoicing and invoice pdf (or printable html - I'll have to see if I am allowed to bundle pdf libraries in this module). Regarding bank transfers, not sure I understand? You can use invoice, where the payments go into your bank account - but PadLoper will not integrate with your bank. Downloadable products will have protected links: each link is unique per product & order, and there can be "download rules" defined - like how long it's available and how many downloads are allowed. Downloading a file doesn't require login though. PadLoper adds very little on top of the ProcessWire - so if PW runs ok on your server, then will PadLoper also.
    1 point
  39. Just for fun, I decided to try saving from copy-pasted CSV data using MySQL LOAD DATA INFILE. Now this MySQL feature is something you use for really serious transactions. Testing with 'only' 1000 values seems an overkill. Anyway, here's the results: Testing with same data as in my post above (10X100 table with 1000 values) Method 1: CSV + MySQL LOAD DATA INFILE 1. Copy-pasted CSV values in the format: Name|Age|Country|Bank Account|Phone|Credit Card|Email|Salary|Address|Post Code Quinlan T. Romero|36|Burkina Faso|RS31212461883550021066|(989) 462-3421|863|Integer.vulputate@Curabiturut.ca|£066.39|P.O. Box 161, 2347 Donec Street|6518 2. Flip the CSV values to match our db structure, i.e.: data(matrix_row) | matrix_column | matrix_value - explode csv line by line - str_getcsv csv line to create array of the csv line - push sanitised csv values into a new CSV array mirroring our 'db structure' (i.e. including row and column page->id) - we do this because our raw csv data is in matrix table format and LOAD DATA INFILE won't read it correctly array( [0] => ( [0] => row->id [1] => column->id [2] => value ) ) 3. Write CSV values to a data.csv file - fopen a data.csv in this page's /assets/files. Force create the file w+ if one doesn't exist - fputcsv the CSV array line by line 4. LOAD DATA INFILE - instantiate a new PW (PDO) $this->wire('database'); - Delete this page's existing values from db - Execute a LOAD DATA INFILE, reading through our data.csv and writing to db (at high speed ) - Delete data.csv Method 2: CSV + 'Saving Normally' 1. Similar to above but we don't write to a data.csv nor use LOAD DATA INFILE 2. Prepare csv array using str_getcsv similar to above...but 3. Our CSV array is slightly different (but timings don't matter because of the different structure) [row->id] => ( [column->id] => value ) Results: Memory usage and Timings Normal LOAD DATA INFILE processCSV() mem_end 15,105,984 13,767,352 mem_start 12,754,968 12,761,496 Diff 2,351,016 1,005,856 time 0.1240 0.0740 ___processInput() mem_end 14,974,128 13,328,584 mem_start 12,754,128 12,760,504 Diff 2,220,000 568,080 time 0.1240 0.0940 ___sleepValue() mem_end 15,504,760 Not Applicable mem_start 15,122,112 Diff 382,648 time 0.0160 Not Applicable As you can see LOAD DATA INFILE is the (clear?) winner. Not sure if LOAD DATA INFILE is enabled everywhere though? Anyway, for now, not sure if this is the route I should take. Besides, I got something else planned (in my head!) for handling really large grid tables.. Before you ask, no we are NOT using LOAD DATA INFILE with the LOCAL option (security concerns with that option!)
    1 point
  40. Update: versions 0.0.4 - 0.0.6 Versions 0.0.4 - 0.0.5: Code changes. Version 0.0.6: Added ability to copy-paste CSV values to save to current page Wasn't sure whether ability to import from CSV values in this manner really belonged in a Fieldtype and was wondering whether I should make the feature configurable optionally available? Then again, it makes sense in a fieldtype whose primary purpose is to store excel/grid-like data! Anyway, for now it stays...Will think about adding feature to import from csv/txt file... Copy paste CSV Data
    1 point
  41. That turned out (later) to be the easy bit . They are stored similar to Page Fields...(see second screenshot below) Matrix array (see post below - we use this only for grabbing db values to later manipulate to build matrix cells/intersections. We use a different array for saving) Matrix db table (see update below [version 0.0.3] about avoiding saving records with empty values)
    1 point
  42. Update: version 0.0.2 Added ability to reuse a single matrix field across pages/templates to build unique matrix tables on a page by page basis. This is achieved by specifying the name of a Multiplepages select field in the Fieldtype settings (Details Tab). It allows you to select row and column parent pages from within the page containing the matrix itself. The child pages of these parents are used to build the matrix. This setting overrides the Row and Column selector settings of the fieldtype. Example usage: Create a Multiplepages field and call it, for example, 'product_select'. Set it up as you wish (e.g. custom PHP, selectors, etc for selectable pages). You may wish to use ASM select to make things prettier/easier below. Add it to the same template(s) where you will be using a matrix field. In your matrix field's Details Tab, specify the name of the page field (i.e. 'product_select') under the 'Matrix Row and Column Parent Pages' setting. Edit the page where you will be building a matrix table. Select 2 pages in your 'product_select' whose child pages will be used to create your matrix rows and columns. The order is important! The first selected page will be assumed to be the row pages parent and the second one the column pages parent. Any additional pages here will be ignored. Save your page and your matrix table will be built using the children of the selected parent pages. Note: The usual error checking will be done and 'thrown' (e.g. if parent pages do not have children, if your specified page field is not a page field/does not return a PageArray, etc. Note 2: You can swap/change the row/column pages in your page field (product_select) HOWEVER, all previously saved values will be deleted(!) on save and your matrix table rebuilt to reflect the new specified row/column structure. Todo/think about Copy values from Excel and directly paste this in a similarly structured matrix table Export matrix table? 1-click clear all values entered in a matrix table Etc? Download: https://github.com/kongondo/FieldtypeMatrix Screens Named Page Field to select rows and columns parent pages Row and Column parent pages selection in a specified Page Field Reusing a single matrix field on a different page(s)
    1 point
  43. Just wanted to let you guys know that I have submitted a PR to Ryan to fix this issue: https://github.com/ryancramerdesign/ProcessWire/pull/823 Along with this, I wanted to note somewhere (for now here, although I will probably write a PW SVG tutorial sometime soon) that if you want to embed SVGs into CkEditor RTE fields and be able to drag to resize them, you need to add the following to the "Extra Allowed Content" section on the Input tab of the field: img[alt,!src,width,height] This allows the img tags to have width and height attributes, which allows you to resize the image to a fixed number of pixels.
    1 point
  44. What adam said. public function wordLimiter($str = '', $limit = 120, $endstr = '...'){ if($str == '') return ''; if(strlen($str) <= $limit) return $str; $out = substr($str, 0, $limit); $pos = strrpos($out, " "); if ($pos>0) { $out = substr($out, 0, $pos); } $out .= $endstr; return $out; } Cut's between words.
    1 point
×
×
  • Create New...