Jump to content

kongondo

PW-Moderators
  • Posts

    7,479
  • Joined

  • Last visited

  • Days Won

    146

Everything posted by kongondo

  1. I am not sure this is how I would consider it. Btw, a lot of fields is relative. There's a site here in the forums that had 800+ fields! Whilst I thought (then) that that was a lot of fields, some people looked at me like duh! Since then my perception has changed and is guided differently. So, rather than asking these from a cosmetic point of view (visual bloat?), I think we should be asking the following questions? What are the forums data needs? How best can we store that data to facilitate efficiency? (i.e. easy, fast and optimized queries) What format should we best store a data format in? Varchar, int, etc? If storing strings, are we better of storing some stuff as JSON? Should we store some stuff in one page or as different pages? Should we store some data in its own table or store it as part of a column (sub-field) in a row? How will the forum scale vis-a-vis our data model? EDIT: See next post - Are all/some of our data needs best served by developing custom Fieldtypes and Inputfields? We then base our data model around such questions. If that results in 20, 50 tables, so be it. Give me a scalable data model any time than a short list of fields in the backend, something that I won't be spending my time interacting with often Just my 2p
  2. @adrian: I think I misunderstood what you meant by append. I assumed you meant tucking new values at the end of the matrix starting from the last empty row. What I think you actually meant was for each value, 'if new value is empty, keep old value. If new value is not empty, overwrite old value'. Is that correct?
  3. Andrey, With adapted code stolen from Soma here: https://processwire.com/talk/topic/4476-validating-field-before-page-save/ (post #2), you can do something like below in an autoload module. Be sure to read Soma's explanations as well in that post/thread. <?php class ValidateEmail extends WireData implements Module { /** * Return information about this module (required). * * @access public * @return array module info * */ public static function getModuleInfo() { return array( 'title' => 'Validate Unique Email', 'summary' => 'Ensure Uniqueness of Emails across site', 'author' => 'Kongondo, Soma', 'version' => 001, 'singular' => true, 'autoload' => true, ); } public function init(){ $this->addHookAfter("InputfieldEmail::processInput", $this, "validEmail"); } public function validEmail($event){ $field = $event->object; if($field->name == 'mail'){ $page = $this->modules->ProcessPageEdit->getPage(); $oldEmail = $page->get($field->name); $newEmail = $field->value; #$this->message("old value: $oldEmail"); #$this->message("new value: $newEmail"); $existEmail = $this->wire('pages')->get("id!=$page->id, template=basic-page, mail=$newEmail, mail!=''"); if($existEmail && $existEmail->id > 0) { $field->value = $oldEmail; $field->error($this->_("That email $newEmail is already taken mate; go fishing! :-)")); } } } } This will save if unique, keep old value if not unique and show error. I am not sure what you mean by admin gets error notification; you mean send them an email or log the error? I'll let you Google that
  4. Very nice site Tom. Glad ProcessWire ticks all your boxes! Just a minor niggle: I am not too keen on the scrolling/typing text thing...It hurts the eyes after a while and it also seems to be in several places so becomes a bit too much.
  5. Update version 1.0.3 (Dev only for now) Note: Haven't had time to update README Changes Export to CSV feature: Can export whole matrix (default) or limit to specified row range (e.g. start at row#2 and end at row#10 ). These are set in the collapsed fieldset 'Import/Export CSV Data' below the matrix. Exported CSV files include timestamp in the file name. Some CSS styling for buttons. Option: Set alert message to show after clicking 'clear data' button. If message set, show alert if no message specified, do not show any alert. Note: now using a custom popup rather than the ugly + annoying browser popup . Option: Save empty values. Default is no; do not save empty values. Current status shown at the top and bottom of the matrix table. Option: Show row numbers. Default is no, do not show row numbers. Fixed a bug where older saved values would still appear after one switched to using custom PHP code to return rows and columns. Added checkboxes for row selections (see #8). Clear Data: Rather than wholesale clearance, button will only clear values of selected rows (see #7). Will show a popup if you try to clear without first selecting at least one row. Fixed some minor bugs in situations where there would be more than one matrix table on a page. Some stylistic changes to rendered fields in line with above changes. Code re-factoring.
  6. Hi Robguy, Welcome to PW and the forums... Although you could make it work in the frontend, a core module like that is really meant for the backend, where all their dependencies are present. I would suggest you use your own HTML form for uploads but make use of ProcessWire API to validate and sanitize uploads + use CSRF. Here's an excellent thread to show you how: https://processwire.com/talk/topic/3105-create-pages-with-file-upload-field-via-api/ Adapt the code to suit your needs. What you are after is really the bit about wireUpload class...
  7. Hooks... http://processwire.com/api/hooks/
  8. Going by the setting in the 'Detail's tab in a comments field, under 'Number of days after which to delete spam' (default = 3), I am guessing the spam will be deleted after those number of days. If you want to delete them yourself that's also OK. In the Blog itself, spam comments on the frontend will only be visible to superusers or logged in users who can edit that page. Try it out and see what happens -) Just to clarify: The comments module is actually not part of the Blog module, but a core ProcessWire module, hence my 'guessing'.
  9. Fieldtypes are not for the faint-hearted ; but don't let that discourage you! They will seem difficult in the first instance, but once you get to know what does what (some of the generic methods), you will absolutely love Fieldtypes and appreciate the thoughtfulness that Ryan put into designing PW. I used to be a sucker for Process Modules but now am totally hooked on Fieldtypes. I dare say they are the heart of ProcessWire. Here's some important homework from the forums that will help you with the generic methods I mentioned above. The most important thing to remember is that with Fieldtypes, you are just a heartbeat away from the database so sanitizing data and retrieving data in some expected format is crucial. Enjoy! https://processwire.com/talk/topic/671-relationship-between-sleepvalue-wakeupvalue-and-sanitizevalue-methods/ https://processwire.com/talk/topic/4105-module-create-a-pages-findquery-as-a-field/?p=40411 https://processwire.com/talk/topic/1936-remove-entry-from-pagesfield-via-api/ And don't forget this classic: http://www.flamingruby.com/blog/anatomy-of-fields-in-processwire/ Edit: One more tip. Working with Fieldtypes, you will want to have a tab open showing the table (database) of the field you are working on so that you can observe how things get saved (or don't get saved!). The FieldtypeEvents that @adrian pointed too uses some advanced techniques (e.g. moving some methods to their own PHP classes); you don't always have to do that. It really depends on your coding style. I'd also suggest you have a look at RuntimeMarkup or Concat Fieldtypes and check out the comments. These Fieldtypes don't save anything to the db but have some useful comments. Edit 2: A diagram RE Fieldtypes database schema https://processwire.com/talk/topic/5040-events-fieldtype-inputfield-how-to-make-a-table-fieldtypeinputfield/?p=85759
  10. You are not saving the status you have just set. Assign your page 1265 to a variable, set a status to it and save. Hidden and similar flags are saved to the db (see the column status in the table pages in your PW db) so you need to save.
  11. https://github.com/ryancramerdesign/ProcessWire/releases
  12. @quickjeff, nope. That should do it. If the version is not showing as 2.3.5 in the modules page on your site, just hit the module's refresh button. Would love to hear about how the site performs if possible, ta.
  13. @Metadope, In my testing, I never managed to replicate the issue you reported here. I know it's been a while but wondering if you managed to resolve your issue?
  14. Update: Blog Version 2.3.5 (dev branch only for now) Changes Fixed issue of slow loading dashboards on sites with lots of posts. Added some missing translation strings, thanks @mr-fan. Decluttered modal window, thanks @mr-fan. Some code optimisations. I don't think there are any other pending issues. Apologies it took so long to get to this update; we got there in the end
  15. @Alxndre' That sounds inordinately long. Are you importing on a local or remote server? On a local server, I imported 10K rows with 3 fields in two equal batches and it took no more than 10 minutes in total (IIRC). If you can, direct SQL import will be faster than PHP. If you are working on a remote server, maybe try to import to a local server first, then get a DB dump of the import and on the remoter server import the db dump instead. Of course, page IDs will need to match what you expect on the remote server. Just a thought...
  16. It was on local host. See posts from here onwards.
  17. @quickjeff...his Blog install got messed up by an x-debug limitation so he needed to reinstall. He was caught between a rock and a hard place and couldn't use the 'cleanup feature' since Blog didn't finish installing due to the x-debug thing.
  18. Update version 1.0.2 (Dev only for now) Note: Haven't had time to update README Change Added method getValue() to get the value at the given coordinates(row, column). This is an extended syntactic alias for $page->matrix->get('row=1045, column=1098'). It is more versatile, taking two parameters (row, column), allowing you to get a value by specifying its row and column ID (integer), path, title or Page object. Examples: getValue() (matrix field called 'results' with student names for rows and subjects for columns) //get by path #$result = $page->results->getValue('/students/ishak/', '/subjects/physics/'); //get by title #$result = $page->results->getValue('Ishak', 'Physics');//note title is case sensitive //get by ID #$result = $page->results->getValue(1062, 1082); //### get by Page #$r = $pages->get(1064);//results row #$c = $pages->get(1083);//results column //pass Page object #$result = $page->results->getValue($r, $c); //pass Page title #$result = $page->results->getValue($r->title, $c->title); //pass Page ID #$result = $page->results->getValue($r->id, $c->id); //pass Page path #$result = $page->results->getValue($r->path, $c->path); ############### //get by mixed parameters #$result = $page->results->getValue('Ishak', '/subjects/history/'); #$result = $page->results->getValue('/students/sarah/', 'French');//note title is case sensitive #$result = $page->results->getValue($r, 'Music'); #$result = $page->results->getValue('Amani', $c->path); $result = $page->results->getValue('James', $c->id); if($result) echo '<strong>' . $result->rowLabel . ' </strong>scored ' . $result->value . ' in ' . $result->columnLabel; else echo 'No result found'; Please test and let me know how it goes, thanks.
  19. Thanks for sharing Pete . Also speaks volumes about the beauty of OOP. Don't know how/if you could have achieved that using procedural code.
  20. Most of its magic happens in JS. See how I do it Menu Builder if at all helpful. I hooked into its render method and injected my custom JS file (jquery.asmselect-mb.js) which overrides its native jquery.asmselect.js. See this thread for the results (toward the end)
  21. @Roxanne, Welcome to ProcessWire and the forums. The source code is here in GitHub And this is the module's page
  22. Update version 1.0.1 (Dev only for now) Note: Haven't had time to update README Changes As requested, added ability to find column/row pages using custom PHP code. Thanks @adrian. This is a really powerful feature. Note that the order of precedence for the 3 methods to return row/column pages is: 1. Selector 2. Custom PHP code 3. Page field (3 is greatest). Browser warning alert for reset button + rename the button (@adrian). Done + enhancement by @mackski, the button styling now matches other PW buttons Added two properties: rowLabel and columnLabel (in memory only; not saved to DB) to return user-friendly row/column header info. E.g. echo matrix->rowLabel could render 'Red' or 'Large' instead of echo matrix->row that would instead render the page's ID. These are searchable in-memory ONLY, e.g. $results = $page->results->find("columnLabel=Maths"). Added two methods getRow() and getColumn() for mainly syntactic convenience. These do in-memory searches. Can search by path, title, ID, page object (see examples below). Examples columnLabel //find all results for one column - using 'user friendly selector'; $results = $page->results->find("columnLabel=Maths");//@note: in-memory selector echo '<h3>The are the results of: ' . $results->first()->columnLabel . '</h3>';//maths results foreach ($results as $r) echo $r->rowLabel . ': ' . $r->value . '<br>';//student name: score rowLabel $results = $page->results->find("rowLabel=Maurice|Joel|Mi Mong");//@note: in-memory selector #$results = $page->results->find("");//will show all echo '<h3>The are the MULTIPLE results for several students</h3>'; $row = array(); foreach ($results as $r) { if(!in_array($r->row, $row)) { echo '<h4>' . $r->rowLabel . '</h4>';//echo'es student name (e.g. Joel) $row[] = $r->row; } echo $r->columnLabel . ': ' . $r->value . '<br>';//echo'es each subject's results, e.g. Maths: 70 } getRow()//accepts 3 arguments selector value, limit, sort #$p = $pages->get(1088); #$results2 = $page->results->getRow($p->id);//get by ID #$results2 = $page->results->getRow($p->title);//get by Title #$results2 = $page->results->getRow('Joel');//get by Title (case sensitive) #$results2 = $page->results->getRow($p);//get by Page #$results2 = $page->results->getRow($p->path);//get by Path $results2 = $page->results->getRow(1087);//get by ID//get by ID #$results2 = $page->results->getRow('/students/richard/');//get by Path #$results2 = $page->results->getRow($p, 4, 'random');//get by Page, limit to 4 random values #$results2 = $page->results->getRow($p, 4, 'asc');//get by Page, limit to 4 values, sort ascending #$results2 = $page->results->getRow($p, 3, 'desc');//get by Page, limit to 3 values, sort descending #$results2 = $page->results->getRow($p->title, 4);//get by Page title, limit to 4 #$results2 = $page->results->getRow($p, '', 'asc');//get by Page, no limit, sort ascending #$results2 = $page->results->getRow($p->path, '', 'desc');//get by Path, no limit, sort descending echo '<h3>The are the results for: ' . $results2->first()->rowLabel . '</h3>';//student name foreach ($results2 as $r) echo $r->columnLabel . ': ' . $r->value . '<br>';//subject: score getColumn()//accepts 3 arguments selector value, limit, sort Similar to getRow() except for columns $results3 = $page->results->getColumn('/subjects/physics/'); echo '<h3>The are the results for: ' . $results3->first()->columnLabel . '</h3>';//Subject foreach ($results3 as $r) echo $r->rowLabel . ': ' . $r->value . '<br>';//student:score Some feature requests still pending + thinking whether to implement findRows() and findColumns(). Please test and let me know (if you can, both fresh install and upgrades [test on non-critical data please])
  23. Media Manager Released 31 March 2016 https://processwireshop.pw/plugins/media-manager/ Documentation http://mediamanager.kongondo.com/ As of 10 May 2019 ProcessWire versions earlier than 3.x are not supported ******************************************************* ORIGINAL POST ******************************************************* API Example (frontend; will be added to documentation site) Accessing and outputting the contents of the MediaManager field(s) in your template is quite simple. The fields are accessed like many other ProcessWire fields. The fields return an array of type MediaManagerArray that need to be looped to output each media within. Assuming you created a field of type MediaManager named 'media', you can loop through it for a given page as shown below. @note: Each MediaManager object has the following 5 basic properties: DATABASE (saved properties) 1. id => pageID of the page where the media lives (hidden in admin and not important to know about) 2. type => integer denoting media type (1=audio; 2=document; 3=image [for variations this will be 3x, where x is the number of the variation of an original image]; 4=video) RUNTIME 3. typeLabel => user friendly string denoting media type (audio, document, image, video) 4. media => a ProcessWire Image/File Object including all their properties (ext, filesizeStr, height, width, description, tags, filename, basename, etc.) 5. title => title of media (@note: this is the title of the page where the media lives; may or may not be the same as the name of the media file itself). This can be used as a user-friendly name for your media $media = $page->media;// returns a MediaManagerArray. Needs to be looped through foreach ($media as $m) { echo $m->id;// e.g. 1234 (hidden page in /admin/media-manager/media-parent/) echo $m->type;// e.g. 3 (a media of type image) OR 1 (a media of type audio) echo $m->typeLabel;// e.g. 'document' (i.e. type would be 2) echo $m->title;// e.g. 'My Nice Trip' (whose media file could be my-nice-trip.mp4) /* @note: - $m->media returns an object; either a ProcessWire Image (for image media) or File object (for audio, document and video media) - This means you have access to all the properties of that object, e.g. ext, tags, description, url, filename, basename, width, height, modified, created, filesize, filesizeStr, etc as well as associated methods, e.g. size() */ echo $m->media->tags; } // only output images foreach ($media as $m) { if($m->typeLabel =='image') { echo "<img src='" . $m->media->size(100,75)->url . "'><br>"; } } // There's also a toString() method so you can do: echo $page->media; /* All your media will be output wrapped in appropriate HTML tags, i.e.: audio: <audio></audio>; document: <a></a>; image: <img>; video: <video></video>; */ ******************************************************* ORIGINAL POST ******************************************************* The topic of a central media manager feature for ProcessWire has come up several times: https://processwire.com/talk/topic/4330-get-image-from-other-pages-via-images-field/ https://processwire.com/talk/topic/4330-get-image-from-other-pages-via-images-field/?p=42578 https://processwire.com/talk/topic/4330-get-image-from-other-pages-via-images-field/?p=42582 https://processwire.com/talk/topic/425-file-manager/ https://processwire.com/talk/topic/425-file-manager/?p=13802 https://processwire.com/talk/topic/425-file-manager/?p=13861 https://processwire.com/talk/topic/10763-asset-manager-asset-selector/ More recently, regarding my Visual Page Selector module, I have been asked several times why the module does not have an in-built feature to upload images. There's two camps on the topic of a central media manager: those who like them (especially those coming in to PW from other CMSes) and those who don't like them (primarily because of the chaotic way some CMSes (dis)organise their media management) . I think that we can have our cake and eat it too! If done the right way, closely following the principles of and harnessing the power of ProcessWire, we can have a well-implemented, organised, feature-rich, site-wide media manager. Introducing Media Manager: (a commercial module) Alongside a number of modules I am currently working on (both free and commercial), I have been developing a centralised Media Manager for ProcessWire. Before you cast the first stone, no, this is not going to be a one-large-media-bucket as in other CMS where it gets very messy very quickly . In the backend things are neatly stored away, yes, in pages. However, those are pages you will not see (just like repeater pages). Before anyone has a go at pages, remember a page is not that thing you see on the ProcessWire Tree (that's just its visual representation); A page is a record/row in the database . For the end-user of Media Manager, all they will see is the 'familiar media bucket' to select their media from. As long as it works efficiently, I don't think they care about the wizardry behind the scenes . The module allows for the comprehensive management of several media types: Audio Video Images Documents Each media type will be handled by its own sub-module so the user can pick and install/choose the type of media management they want. Features include: Access controls Centralized uploads of media Bulk management of media: tag, delete, describe, replace, etc. Bulk upload: zip; scan, single Quick upload in page edit mode Usage stats across pages (maybe?) Etc.. Would love to hear your thoughts and any feature suggestions. I think there's enough demand for such a module. If not, please let me know so that I can instead focus on other things , thanks. How other CMS do it The more efficient (PW) way of doing it
  24. It's not meant to show any other fields. For that, you need to edit your post as page as usual.
  25. Yes. Doing things the ProcessWire way....we make no assumptions (aka total freedom for end-user to implement as they wish). Some stuff, e.g. the role and demo files, Blog offers as a courtesy to get you started
×
×
  • Create New...