Jump to content

kongondo

PW-Moderators
  • Posts

    7,479
  • Joined

  • Last visited

  • Days Won

    146

Everything posted by kongondo

  1. Good idea, ta. I'll have to link to the image from somewhere (maybe Github or my site) since we can't add images to modules directory
  2. What 100k limit? Somebody here had 500k pages . The page_id field is int(10) - the 10 just means how many digits can be displayed in the db column It is an unsigned integer field so...from the MySQL docs... http://dev.mysql.com/doc/refman/5.1/en/numeric-type-attributes.html http://stackoverflow.com/questions/8892341/what-does-int5-in-mysql-mean http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html You will be fine
  3. Good detective work...Just to reiterate: 1. This is about Blog AND Demo content 2. If one wishes, they can use the _main.php with Blog Demo files but they would have to set that up themselves... (I should do a tutorial about this)
  4. After (but only if necessary - see below). As outlined in the must README + You have to manually copy over the files CSS + JS files. If you don't copy them to /site/templates/css/ and /site/templates/js/ then, you have to amend the links in blog-main.inc (e.g. you could have copied them to /site/templates/styles/ and /site/templates/scripts/ respectively. Have you confirmed that the files are being loaded in the browser. If your answer is yes, then the problem I suspect is that the default PW install _init.php and/or _main.php files are interfering with the rendering. It has happened to me before . I always use the PW blank install so I don't tend to notice this much. If blog-main.inc wasn't copied to over to /site/templates/ it means you did not install Blog with demo content . Maybe send some screenshots of your settings when you initially set up blog (step 1 in the module config) + what your frontend looks like.
  5. 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.
  6. The simple and recommended way is to use a page field ..(with radio as select) Please see these: https://processwire.com/talk/topic/4852-radio-buttons-fieldtype/ https://processwire.com/talk/topic/588-how-can-i-use-radio-buttons/ https://processwire.com/talk/topic/201-fieldtype-select-aka-drop-down/?p=8971
  7. Hi @loopyloo. Welcome to the forums and thanks for trying out Blog. If you want to install Blog with the demo content, you have to manually copy over those two CSS files and the blog.js file to some folder in your /site/templates/. If your paths are different, you would have to change them in 'blog-main.inc'. Check in Firebug/Chrome Developer that the files are actually being loaded. In case you missed it, let me also reiterate that the demo Blog is just that - a demo; you will probably want to change it here and there to suit your needs .
  8. I have been running Windows 7 on an i7 processor, booting from a 120gb SSD for the past 2 years...Amazingly fast! Quiet PC and no overheating. Remember no to defrag an SSD! . I am now thinking of going even smaller - build a NUC (or similar) rig...using them microSSDs..
  9. Blink and you miss it! Thx Adrian! I'm such a rookie! .
  10. The Matrix is for the backend. There are multiple approaches to display its stored values in the frontend - in a grid/matrix table, repeater like list, etc...
  11. You are right. The more I think about this, the more I see it as a separate/bespoke module...
  12. @everfreecreative, you mean besides having a cooler name? . As LostKobrakai pointed out, it's all in the first post. You can't really create a 2D/Matrix table using repeaters, since, er, the rows just keep repeating with the same thing. And if you could create one, I think you would have more overhead using a repeater to create, say a 10x100 table than this Fieldtype. To understand what the Fieldtype does, think an Excel spreadsheet with column headers and row labels whose intersections contain unique cell values (by unique I mean each table cell can only ever represent a unique combination of two factors different from any other cell). The main purpose of the Fieldtype is for storing and retrieving such values. As for Table, that's a whole different beast whose scope is far greater than what this Fieldtype does...
  13. Thanks for the writeup....Here's another way of doing it (no need to use instance of Page ). Also, only output stuff you have confirmed exist.. //prepare a variable to use later on. Setting one like this ensures we don't get 'unknown $sidebar' errors in case things go wrong $sidebar = ''; //if we found a course selected in the page field if($page->course_name_from_list) { $course = $page->course_name_from_list; $sidebar = "<h4>Course: " . $course->course_number . "<br>" . $course->title . "</h4>"; } else { //Oops, course not selected! Quick, hide everything! $sidebar = '<h4>Sorry, we do not have yet have the details for this course. Please check back soon, thanks. Alternatively, if your case is urgent, you can contact us on 12345-4567-0000.</h4>'; } echo $sidebar; Btw, If I understood you correctly, the page selected in the Page field 'course_name_from_list' has a field called 'course_number' and of course a title. In that case, you don't need to first save those fields in an array as you implied above: The fields will be available to you automatically in the 'page/object' 'course' . You will be able to reference them as $course->name_of_field. If any of the fields is an array, you would have to loop through it, of course..
  14. I think the feature Nico is talking about was added in the dev branch a while back? IIRC...can't find a link atm... . To be clear parent::init() has been there for a while...what I am referring to is the 'uninstall' feature Nico is talking about...if memory serves me right!
  15. Glad you sorted it out... The error with first() is because, in a Single page field, there is no 'first' per se; there is only one value there. first() will only work with a Multiple page field (or similar fields that return multiple items). To be a bit verbose, it is like telling a student 'go get me the first Head Teacher' - it doesn't make sense since there is only one Head Teacher (only one possible - Single page field). But you could tell the student, 'go get me the first teacher you find in the staff room, or the next five teachers you meet in the corridors ' (multiple possible) OK, you get the point
  16. @kathep. Welcome to the forums. As Nico pointed out in his post, he didn't know whether you are using a Single page field or a Multiple pages field, hence the use of 'instanceof Page/PageArray. That is not code you would normally use in a template file. Nico also pointed out how you would handle either page field type which I want to further clarify by asking, is your 'course_name_from_list' a Multiple or a Single page field? The fact that: does not answer my question either . This is because, your 'course_name_from_list' could be a Multiple page field but you are using it to select only one course. In that case, because it would be a Multiple page field, whether you select one or 10 courses from it, it would return an array that you would have to loop through. On the other hand, if it is a Single page field, you would only ever be able to select one page in the field; PW will not let you choose more. You would not have to loop through it if it was a Single page field. Which of this is your case? If not the latter, I would suggest you change it to be the latter since you will only ever want to force the selection of a maximum of 1 page. Then you would be able to do as Nico suggested in his second example...(and it would work if your 'course_name_from_list' was a Single page field type), e.g. if($page->course_name_from_list) echo $page->course_name_from_list->title; Sorry for long-windedness! Btw: If on development/local server, you want to turn debug on....
  17. 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!)
  18. Not directly, its not. But with a custom script it is possible; something to tell Blog about the IDs of your comment related pages and that comments feature is enabled. Alternatively, if you know what you are doing and TESTING on a development server first, you can directly edit the necessary values in your database using a programme like phpMyAdmin. The code below is from a fully installed blog, in the PW db table 'modules' and the row 'ProcessBlog'. It tells you what is going on. {"blogFullyInstalled":1,"blogStyle":1,"schedulePages":0,"commentsUse":1,"templateFilesInstall":2,"tagTemplatesFields":"blog","blog":2480,"blog-posts":2481,"blog-categories":2482,"blog-tags":2483,"blog-comments":2484,"blog-widgets":2485,"blog-authors":2486,"blog-archives":2487,"blog-settings":5190,"blog-asc":4017,"blog-dnc":4018,"blog-dc":4019,"blog-rposts":2491,"blog-rcomments":2492,"blog-broll":2493,"blog-tweets":2495,"blog-pauthor":4015} In your case, you would first need to create the four comments pages and note down their IDs. blog-comments":2484" - comments (parent of below three) blog-asc":4017, - always show comments "blog-dnc":4018, - disable new comments "blog-dc":4019 - disable comments There is also the recent comments page to install under widgets. blog-rcomments":2492 You would also have to create the necessary fields that go with those pages as in a full blog install. Then it would be a matter of simply adding the above key/value pairs that have the IDs of your newly created comment page. This would be faster than writing a custom PHP script You would also need to change this: "commentsUse":1, in your case the value is '0' - it would need to be changed to '1' It is not as complicated as it sounds but like I said, you would need to try and thoroughly test on a development install first! If you want to go this route (rather than install afresh), I suggest you fully install blog on a test server and compare the above db values to your current install that's missing the comments feature as well as compare their respective Blog Pages tree....I think that's it really...
  19. I have done a couple of tests in respect of memory (memory_get_usage) and timings (Debug::timer()) when processing 1000 copy-pasted CSV values in a 100X10 matrix table: For a fictitious investment company, I generated (using a local install of datagenerator) CSV data consisting of 100 rows (account manager) x 10 columns of customer details containing their: Full Names, Age, Country, Bank Account Number, Phone Number, Credit Card CVC, Email, Income, Address, Post Code Btw, this showcases another use for this Fieldtype. It is not only about colours vs sizes . If you have data such as above that is most likely already available in CSV or similar format and that would not readily lend itself to being converted to pages (even for use in Page Fields), then you probably want to use FieldtypeMatrix... OK, back to our measurements...I imported my 1000 CSV values into my matrix and got the following results. Note that I am on an i7 windows machine. lightning.pw has been down for me the last couple of days so wasn't able to test there. I am not good at such testing so if anybody else wants to help out I'd appreciate it. I also had to increase my max_input_vars from the default 1000. Saving 1000 pipe (|) delimited CSV values //Note: SEQUENTIAL PROCESSING (I skipped timing methods like get() and set() //not sure why ___sleepValue() was not showing here! See next test where we exit at ___sleepValue() 11187192: Memory Usage Start: get()Inputfield() 0.0360: Debug Timer End: get()Inputfield() 11270704: Memory Usage End: get()Inputfield() 11772248: Memory Usage Start: ___wakeupValue() 11772456: Memory Usage Start: get()blankValue() 0.0000: Debug Timer End: get()blankValue() 11773896: Memory Usage End: get()blankValue() 0.0700: Debug Timer End: ___wakeupValue() 13372176: Memory Usage End: ___wakeupValue() 12871408: Memory Usage Start: sanitizeValue() 0.0000: Debug Timer End: sanitizeValue() 12871408: Memory Usage End: sanitizeValue() 14262896: Memory Usage Start: ___render()//render calls mergeMatrix() 14263624: Memory Usage Start: mergeMatrix() 0.2190: Debug Timer End: mergeMatrix() 15165696: Memory Usage End: mergeMatrix() 0.2800: Debug Timer End: ___render() 15231376: Memory Usage End: ___render() Same as above (+sequential) but exiting at ___sleepValue() //exit before ___sleepValue() returns $values 11707344: Memory Usage Start: get()Inputfield() 0.0020: Debug Timer End: get()Inputfield() 11790872: Memory Usage End: get()Inputfield() 11791416: Memory Usage Start: get()blankValue() 0.0000: Debug Timer End: get()blankValue() 11792856: Memory Usage End: get()blankValue() 11793040: Memory Usage Start: sanitizeValue() 0.0000: Debug Timer End: sanitizeValue() 11793040: Memory Usage End: sanitizeValue() 12762576: Memory Usage Start: ___processInput() 12763296: Memory Usage Start: mergeMatrix() 0.0540: Debug Timer End: mergeMatrix() 13372952: Memory Usage End: mergeMatrix() 13361256: Memory Usage Start: ___processInput() - csv only 13361848: Memory Usage Start: processCSV 13362040: Memory Usage Start: mergeMatrix() 0.0080: Debug Timer End: mergeMatrix() 13486200: Memory Usage End: mergeMatrix() 13613512: Memory Usage Start: get()blankValue() 0.0000: Debug Timer End: get()blankValue() 13614504: Memory Usage End: get()blankValue() 0.0830: Debug Timer End: processCSV() 15346208: Memory Usage End: processCSV() 0.0830: Debug Timer End: ___processInput() 15098552: Memory Usage End: ___processInput() 14992888: Memory Usage Start: sanitizeValue() 0.0000: Debug Timer End: sanitizeValue() 14992888: Memory Usage End: sanitizeValue() 15128552: Memory Usage Start: ___sleepValue() 0.0160: Debug Timer End: ___sleepValue() 15511096: Memory Usage End: ___sleepValue() Loading the matrix table with the saved 1000 values //SEQUENTIAL 11763208: Memory Usage Start: ___wakeupValue() 0.0890: Debug Timer End: ___wakeupValue() 13363016: Memory Usage End: ___wakeupValue() 14253776: Memory Usage Start: ___render() 14254504: Memory Usage Start: mergeMatrix() 0.2250: Debug Timer End: mergeMatrix() 15156544: Memory Usage End: mergeMatrix() 0.2680: Debug Timer End: ___render() 15222208: Memory Usage End: ___render() Don't know what to derive from these results or if I did them correctly . From a timing point of view, the results don't look too bad, or? Saved data screenshot
  20. @Peter, I am afraid I don't follow ...Isn't that what you already have? What do you mean mirroring pages? And where?...I'm just slow that way
  21. 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
  22. @netcarver, Thanks. Had stumbled upon it when you initially raised your question. Hoping to do some tests soon...
  23. Btw, in addition to my previous response, for the curious, at the input level, each individual intersection is HTML named as follows: <input type="text" name="matrix_products[R5284_C5271]" value="100"> Where R1234 = row page->id and C1234 is column page->id. So, the two dimensional array shown in the post above is for grabbing data from the db, manipulating it as R1234_C1234 intersections and displaying (Inputfield) it to the user in the matrix table cells. On save, we are dealing with a one level associative array as shown in the HTML code above.
  24. @sakkoulas, Does this mean that all the rows and columns that make up your matrix table will have have their corresponding pages displayed in your page fields? It's an interesting idea but would probably not work well (visually) if you have a large table? The list of pages in your page fields could get very long
×
×
  • Create New...