Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/06/2017 in all areas

  1. On twitter @pwtuts I made this site to: a) help get beginners up and running with PW. b) give something back to a community that has been very helpful (and patient) to me. c) improve my own knowledge because writing about it really drills it home. Modules: AOS - lots of useful admin tools Connect page fields - made tagging and related posts very easy indeed Custom inputfield dependencies - used to hide fields (on child pages) in a multipage post because all blog posts use the same template ProFields: repeater matrix - used for all body content (image, RTE and code fields) Markup Sitemap XML - for submission to google search console ProFields: Auto links - I have a bunch of pre-determined strings in here (that I need to print out and stick on the wall...) Tracy Debugger - still can't use properly IMagick image sizer - very fast compared to GD, especially when some posts have 5+ images and the originals are 2500px wide Tools: NodeJS with the usual suspects: "devDependencies": { "autoprefixer": "^7.1.2", "cssnano": "^3.10.0", "gulp": "^3.9.1", "gulp-postcss": "^7.0.0", "gulp-rename": "^1.2.2", "gulp-sass": "^3.1.0", "gulp-sourcemaps": "^2.6.0", "gulp-uglify": "^3.0.0", "postcss-flexbugs-fixes": "^3.0.0" }, "dependencies": { "bootstrap": "^4.0.0-alpha.6" } Bootstrap 4 (npm) SCSS In short: had a bunch of fun making this, learned loads. and looking forward to updating with more tutorials.
    6 points
  2. Hello, Upon reading these articles https://dev.to/maxlaboisson/an-introduction-to-api-first-cms-with-directus-open-source-headless-cms-9f6 https://snipcart.com/blog/jamstack-clients-static-site-cms I was thinking that PW can be used for a Jamstack or Headless CMS with no changes at all. You can easily create REST Api with PW or use the GraphQL module https://github.com/dadish/ProcessGraphQL So ProcessWire is an Open Source Headless CMS since 2010
    4 points
  3. Untested, quickly thought through, blah blah.. From the docs you linked to: Under Manipulating options on a page from the API, see Getting all possible options // @note: forget this code! // get the Select Options Field $field = $fields->get('licences'); // get all the defined options $all_options = $field->type->getOptions($field); foreach($user->licences as $licence) { // check 'checked' status $checked = $all_options->get("id={$licence->id}") ? ' checked': '';// untested! $content .= "<label for='$licence->id'> <input name='licences[]' type='checkbox' id='$licence->id' value='$licence->id' $checked>$licence->title</label>"; } Edit: I am not sure my logic above is correct but I have to run. It might be you need to loop through the $all_options instead. I'll check back later..., sorry Try this one instead. @note: incomplete, but gives you an idea // get the IDs of selected options @note: untested! + pseudo-code $selectedOptions = getArray($user->licences);// untested! pseudo-code; Here, manipulate to get IDs! // @see: https://processwire.com/api/ref/wire-array/ foreach($all_options as $option) { // check 'checked' status $checked = in_array($option->id, $selectedOptions) ? ' checked': '';// untested! $content .= "<label for='$licence->id'> <input name='licences[]' type='checkbox' id='$licence->id' value='$licence->id' $checked>$licence->title</label>"; }
    3 points
  4. There's something called function scope in PHP. In a hurry, please Google forums for more info. For now, use: wire('page'); wire('pages'); wire('input'); // etc...
    3 points
  5. Here is an attempt to simplify things a bit: $wire->addHookAfter('ProcessPageAdd::buildForm', function(HookEvent $event) { $form = $event->return; $template_select = $form->getChildByName('template'); $options = $template_select->getOptions(); $options = array('' => '') + $options; $template_select->set('options', $options); // Set the value to something that will never match an option in the select (any string will do) $template_select->value = 'a'; $template_select->attr('required', 1); }); It's important to set the HTML required attribute (thanks to @abdus for the idea) and to make sure none of the options get the "selected" attribute (hence setting the inputfield value to something that will never match an option). Otherwise if the Add New form is submitted with no actual template selected a nasty error occurs - the core does not allow for the possibility that no valid template ID is included in POST.
    3 points
  6. If you want to add your own button value at the add button of a pagetable field, you only have to put this little piece of code inside your ready.php file. $wire->addHookBefore('InputfieldPageTable::render', function($event) { $table = $event->object; if(!in_array($table->name, array('datespagetable'))) return; $this->addHookBefore("InputfieldButton::render", null, function(HookEvent $event){ $button = $event->object; if($button->name == 'button'){ $button->attr('value', 'Test'); } }); }); In this case I limit it to a certain pagetable field called "datespagetable". You have to change it to the name of your desired pagetable field. If you want to change it for all pagetable fields (no restrictions) simply remove the following line from the code: if(!in_array($table->name, array('datespagetable'))) return; If you want to add it to more than 1 pagetable field, then write all the fieldnames into the array: if(!in_array($table->name, array('datespagetable','pagetable1','pagetable2'))) return; You can change the value of the button text to your needs in this line of code: $button->attr('value', 'Test'); I simply called it "Test" in this case to show how it is working. If you need it to be a translateable string simply use: $button->attr('value', __('Test')); And now this is the result: This let you customize your pagetable field a little bit. Fe you can use "Add News" or "Add new events" or something else. If you want to change another attribute than the value please take a look at the following page: https://github.com/processwire/processwire/blob/master/wire/modules/Inputfield/InputfieldButton.module Best regards
    2 points
  7. Like any other ProcessWire variable, the easiest way to access them inside a function is: wire('session')
    2 points
  8. Thanks a million, @kongondo ! You pointed me to the right direction. In the end I had to loop through the $all_options as you anticipated. The following works: // get the Select Options Field $field = $fields->get('licences'); // get all the defined options $all_options = $field->type->getOptions($field); foreach($all_options as $licence) { // check 'checked' status $checked = $user->licences->get("id={$licence->id}") ? ' checked': ''; $my_form .= "<label for='$licence->id'> <input name='carnet_de_conducir[]' type='checkbox' id='$licence->id' value='$licence->id' $checked>$licence->title</label>"; } After hours of wasted sleep and overengineered failed attempts, here you come to save the day with this classically elegant and readable PW snippet. I'm so grateful ! Gottta love this forum.
    2 points
  9. On the fields that you have set access restrictions for, on the "Access" tab try checking the checkbox shown below:
    2 points
  10. Welcome to the Forum! I think these discussions should give you some hints where to get started: https://processwire.com/talk/topic/15453-pw-based-form-centric-website-recommendations-please/?tab=comments#comment-138395 https://processwire.com/talk/topic/11499-admin-restrict-branch/ https://processwire.com/talk/topic/3543-register-users-and-add-page-same-as-username/ This is just a quick and short sample. You will definitely need more to achieve what you need. It is because your requirements are unique in a sense that there is no out-of-a-box solution. Hope this helps.
    2 points
  11. Restrict Repeater Matrix Allows restrictions and limits to be placed on Repeater Matrix fields. Requires ProcessWire >= v3.0.0 and FieldtypeRepeaterMatrix >= v0.0.5. For any matrix type in a Repeater Matrix field you have the option to: Disable settings for items (cannot change matrix type) Prevent drag-sorting of items Prevent cloning of items Prevent toggling of the published state of items Prevent trashing of items Limit the number of items that may be added to the inputfield. When the limit is reached the "Add new" button for the matrix type will be removed and the matrix type will not be available for selection in the "Type" dropdown of other matrix items. Hide the clone button when the limit for a matrix type has been reached. Note that in PW >= 3.0.187 this also means that the copy/paste feature will become unavailable for the matrix type. Please note that restrictions and limits are applied with CSS/JS so should not be considered tamper-proof. Usage Install the Restrict Repeater Matrix module. For each matrix type created in the Repeater Matrix field settings, a "Restrictions" fieldset is added at the bottom of the matrix type settings: For newly added matrix types, the settings must be saved first in order for the Restrictions fieldset to appear. Set restrictions for each matrix type as needed. A limit of zero means that no items of that matrix type may be added to the inputfield. Setting restrictions via a hook Besides setting restrictions in the field settings, you can also apply or modify restrictions by hooking RestrictRepeaterMatrix::checkRestrictions. This allows for more focused restrictions, for example, applying restrictions depending on the template of the page being edited or depending on the role of the user. The checkRestrictions() method receives the following arguments: $field This Repeater Matrix field $inputfield This Repeater Matrix inputfield $matrix_types An array of matrix types for this field. Each key is the matrix type name and the value is the matrix type integer. $page The page that is open in ProcessPageEdit The method returns a multi-dimensional array of matrix types and restrictions for each of those types. An example of a returned array: Example hooks Prevent the matrix type "images_block" from being added to "my_matrix_field" in a page with the "basic-page" template: $wire->addHookAfter('RestrictRepeaterMatrix::checkRestrictions', function(HookEvent $event) { $field = $event->arguments('field'); $page = $event->arguments('page'); $type_restrictions = $event->return; if($field->name === 'my_matrix_field' && $page->template->name === 'basic-page') { $type_restrictions['images_block']['limit'] = 0; } $event->return = $type_restrictions; }); Prevent non-superusers from trashing any Repeater Matrix items in "my_matrix_field": $wire->addHookAfter('RestrictRepeaterMatrix::checkRestrictions', function(HookEvent $event) { $field = $event->arguments('field'); $type_restrictions = $event->return; if($field->name === 'my_matrix_field' && !$this->user->isSuperuser()) { foreach($type_restrictions as $key => $value) { $type_restrictions[$key]['notrash'] = true; } } $event->return = $type_restrictions; }); http://modules.processwire.com/modules/restrict-repeater-matrix/ https://github.com/Toutouwai/RestrictRepeaterMatrix
    1 point
  12. https://www.baumrock.com/portfolio/individuelles-crm-und-controlling-tool/ I'm happy to share my biggest and most interesting ProcessWire project so far with you It's a 100% custom office-management solution that helps my client to keep track of all their contacts, projects and finance/controlling stuff. Conception was done back in 2016 and the software is productive since begin of this year. My client is very happy with the result and so am I. Some technical insights: Everything is done inside the PW Admin. I'm using the Reno Theme with some custom colors. In the beginning I was not sure if I should stay with the pw admin or build my own admin-framework but now I'm VERY happy that I went with PW Almost all of my custom Process Pages use my RockDatatables module - there are still some limitations but without it, this project would not have been possible For the charts I used Google Charts and chartjs - both play well together with the datatables and make it possible to display filtered data instantly: also my handsontable module was created for this project to have a nice and quick option for matrix data inputs: Lister and ListerPro were no options as i needed much more flexibility regarding data presentation (like colorization, filtering and building sums of selected rows): invoices are highly customisable as well and easy to create. PDFs are created by php and mPDF by the way: all data is dummy data populated via my Module RockDummyData have a nice weekend everybody
    1 point
  13. Hey! When I was building a little commercial Processwire website for a family member, I started looking into caching with WireCache and somehow had troubles to find a satisfying solution to organize the caches and their expirations. My site had a few parts that updated in a regular manner while other parts should be refreshed whenever the current page - or e.g. for the menu: any page - was saved. I wanted to create a cache of the whole page's html which should expire whenever any of its parts expired. This would be simple if you could set multiple expire values for one cache. Unfortunately, you can only set one. So I started to build a solution to my problem which uses the WireCache and creates a dependency tree for every cache. And since I haven't yet implemented a Processwire module and this little class might be useful for other websites, too, I thought I'd try to make a module out of it. This is it. Github: https://github.com/janKir/CacheNesting Please have a look, and feel free to leave a comment. This is my first module, so any suggestions are welcome. I am not even sure if my approach makes much sense for performance reasons. I'm happy to hear your opinions! Thanks a lot!
    1 point
  14. @adrian Ah, git tags at last. Nice.
    1 point
  15. Yep, that fixes it - thanks!
    1 point
  16. Thanks, I re-worded that sentence, hopefully that works too (cannot see here the issue).
    1 point
  17. In v165 sticky header is available for the Uikit admin theme too along with a compact (smaller, better name anyone?) masthead, plus Profile page links to configure themes (SuperUsers only):
    1 point
  18. Have a look at this post: @psy's code does almost exactly that what you need/want. At least you get the idea and can adjust it to your needs.
    1 point
  19. @helmut2509 - it's working fine here. Are you actually calling the function where the "number" session value is set before you try echoing it?
    1 point
  20. I was about to suggest fontello but ten icons weighted about 10 kbyte, so 1 per char which seems heavier than svgs. Of course more or other chars can be perhaps less heavy. Another option could be using unicode characters as icons but I'm not sure there are enough of them and browsers may display them differently. That would be super light though.
    1 point
  21. Thanks szabesz, for the code and the link. I've noticed the Gmails are coming in regularly again, so I guess that part is out of my hands. I've gotten the form working and sending emails, thanks to the help from you guys so I'm going to mark this as solved. I will probably be back asking more about wireMail at some point, but that would be for a different thread.
    1 point
  22. I know, this is the solution if you have only 1 template assigned.
    1 point
  23. All sounds great @szabesz The other possibility here is to use FontAwesome icons as much as possible. I recently added it for loading the icons for the new "Custom Links" section in the PW Info panel. Although it is only loaded if you have defined some custom links. Because you guys can add a link to any page (admin Process or frontend) on the site, this was the only way to show the appropriate icon automatically. Not sure if this is a better or worse approach in terms of resources. Obviously Fontawesome isn't super lightweight, but it's also not embedding the SVG directly into the panels, so maybe more efficient? Sounds like a good idea - I'll sort that out.
    1 point
  24. Can you elaborate more on how you achieved this? maybe some screenshots of the page editing?
    1 point
  25. Hi, A related good to read post: https://processwire.com/talk/topic/13977-custom-php-code-selector/?tab=comments#comment-125688
    1 point
  26. Line-only versions are harder to do right because of its nature and limitations but I was thinking about going crazy with optimization regarding how much is injected into the page. By removing the probably not needed <title>turn-off</title> from my version (it was just exported too, as the name of the file was "turn-off") we have only 300 characters. Probably this is not the one where we can gain a lot but more complex ones like logos and such. I would be happy to do it. It is probably not worth forcing us to use line-only svg when more complex icons are needed but some of then (like this turn on/off icon called EnableButton) looks doable. Others might just need SVGO treatment I focused on EnableButton because I would like to see less in the source code of a frontend page when Tracy is disabled. So something like this (removing some line breaks) would be nice too: <style>div#TracyEnableButton{bottom:10px!important;right:10px!important;z-index:99999!important;position:fixed!important;width:16px!important;height:16px!important;margin:0px!important;padding:0px!important;cursor:pointer!important;}div#TracyEnableButtonsvg{width:16px!important;height:16px!important;}</style> I often use the Chrome extension called Quick source viewer which displays the actual rendered output in a different way then the inspector. For the styles I get the line breaks but if you could remove them we would get a more compact version injected.
    1 point
  27. Thanks @adrian You made me realize I had code executing on ready.php which was embedding css in the admin page, hence the unexpected < Others postings led me to think it was a system problem, rather than my own code.
    1 point
  28. Also, for the field to work in lister/lister pro, some additional changes needed to be made to how the links to the download are formed; this is the complete hookRenderItem method; so basically instead of referencing the page being edited, it would need to reference the $pagefile->page; then since the editUrl already has the id, you don't need to have that in the $segments array.. this works now in listers if you show a secure files field, when it renders in the list you can click on the item to download/view the file... public function hookRenderItem(HookEvent $event) { /** @var PagefileSecure $pagefile */ $pagefile = $event->arguments('pagefile'); if (!$pagefile instanceof PagefileSecure) { return; } $markup = $event->return; $markup = preg_replace("/<a class='InputfieldFileName'[^>]*>(.*)<\/a>/", "$1", $markup); if ($pagefile->field->get('allowDownloadInAdmin') && $pagefile->isDownloadable()) { $segments = array( //'id' => $this->wire('input')->get('id'), self::GET_VAR_DOWNLOAD => urlencode($pagefile->basename), ); //$link = $this->wire('page')->url . '?' . http_build_query($segments); $link = $pagefile->page->editUrl . '&' . http_build_query($segments); $markup .= "<div class='FieldtypeSecureFileDownload InputfieldFileData'><a href='{$link}'><i class='fa fa-download'></i> " . $this->_('Download File') . "</a>"; $segments['view'] = 1; //$link = $this->wire('page')->url . '?' . http_build_query($segments); $link = $pagefile->page->editUrl . '&' . http_build_query($segments); $markup .= " | <a href='{$link}' target='_blank'><i class='fa fa-eye'></i> " . $this->_('View File') . "</a>"; $markup .= "</div>"; } $event->return = $markup; } after additional testing, i can consider forking and pull request, but wanted to run this by here on the forum first.. also haven't setup a module config to account for the showing pref (view and or download).. will possibly get to that soon..
    1 point
  29. Just for reference: https://processwire.com/talk/topic/10408-button-labels-for-pagetable/ I thought I remembered this being possible by default, but turns out it only works when you have more than one possible template.
    1 point
  30. I like where you are headed with this and I think the new version looks nice. The only thing I wonder is whether it is worth re-crafting all the icons vs just running them through SVGO (which I should really have already done). I just used the online GUI for this test. I just tried and it reduced it to 501 characters: <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 44.8 44.8"> <g fill="#CD1818"> <path d="M22.4 21.2c2 0 4-1.8 4-4V4c0-2-2-3.8-4-3.8s-4 1.7-4 3.8v13.5c0 2 2 4 4 4z"/> <path d="M30.7 3.3c-.5-.2-1 0-1.4.2-.5.3-.7.7-.7 1.3v5c0 .6.3 1.2.7 1.4 4.2 2.4 7 7 7 12 0 7.7-6.2 14-14 14-7.6 0-13.8-6.3-13.8-14 0-5 3-9.6 7-12 .4-.2.7-.8.7-1.3V4.4c0-.6-.2-1-.7-1.3C15 3 14.5 3 14 3 6.6 6.6 1 14 1 23c0 12.3 9.7 22 21.6 22 12 0 21.6-9.6 21.6-21.6 0-9-5.4-16.6-13.3-20z"/> </g> </svg> So there is definitely significant room for improvement with these icons. It's just a question of whether it's worth going the "line only" route, or just using SVGO to optimize the existing ones. Honestly I think most of the icons could do with some work - many of them are pretty ugly If you feel like taking this on, it would definitely be appreciated. Anyone else have any thoughts?
    1 point
  31. 1 point
  32. I think a partial export is still better then breaking an entire system So even if it does not do anything, it's still better to if-repeater-return than to do harm imho. You could still log a warning that there have been unsupported fields that need manual exporting so the user knows what fields need to be exported… Now, as for me, i just had to manually copy a field (not repeater) that I otherwise could have just exported - imported… (which I now did via the db directly)… Also, shouldn't it be possible to narrow down the problem even further now that we know what causes the problem? What happens if you use "getTableData()" directly?
    1 point
  33. @adrian This morning I quickly crafted my own version of the "TracyEnableButton" in order to see if a smaller version can be made. The idea is that – in such small sizes the icons are used – using only lines should be enough to get very similar results. Of course, when an icon like this is enlarged its line only characteristics become prominent but I do not think it is an issue in our case. So here it comes: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 54.48 57.24"><defs><style>.a{fill:none;stroke:#CD1818;stroke-miterlimit:10;stroke-width:8px;}</style></defs><title>turn-off</title><path class="a" d="M24,10.17a23.24,23.24,0,1,0,16,0" transform="translate(-4.76 -2)"/><line class="a" x1="27.24" x2="27.24" y2="21"/></svg> Only 323 characters versus 1101 (current icon). What do you think? Is it usable, and if so worth the effort? I could produce all the others if you think it is a good idea.
    1 point
  34. This can be done by installing the page-publish permission. Go to Access -> Permissions -> Add New in the backend and select the page-publish permission there. Afterwards, page-create and page-edit alone will only allow the creation and editing of unpublished pages.
    1 point
  35. Thanks guys for all the feedback. I looked into this a little, and I was able to reproduce an instance of the problem using VMO's description with two repeater fields 'rep1' and 'rep2' and two text fields 'text1' and 'text2'. The assignment of text fields to repeater fields got mixed up if and only if the AutoExportTemplatesAndFieldsModule was installed. I could narrow down the problem onto my use of ProcessWire's $field->getExportData() inside a hook 'after' ProcessPageView::finished. The problem is triggered when this function is called on the repeater fields in that hook, so the function seems to have side effects. I have added a minimal showcase for this called 'BreakRepeaterFields module' to the git repository, see module info summary for usage. To sum this up: I am pretty confident there is no bug in my code directly causing the faulty behaviour. On the other hand one could not say that there is a bug in ProcessWire either, as my module is using an internal method which is not part of the documented API. Best I can do for now is to declare this module incompatible with repeater fields and ProFields.
    1 point
  36. A quick update. Thanks to lots of help from @szabesz we have fixed the issue with the Config Data section in PW Info panel from being slow. The latest version also: 1) Fixes a ERR_BLOCKED_BY_XSS_AUDITOR browser error if there are <script> tags in your template file and you are using the Template Editor panel to test code changes. 2) Adds a new option for opening links from the PW Info panel in a new browser tab (off by default) - this was requested by @szabesz above. 3) Revamped the init() and ready() code so that much less code is processed when Tracy is completely or temporarily disabled. It also improves efficiency for various conditional checks. 4) Several other minor tweaks / fixes. Please let me know if you come across any problems with this new version.
    1 point
  37. As long as you do not have security concerns regarding those files there is nothing to worry about. As an added precaution you might want to use htmlspecialchars() or better yet $sanitizer->entities() like this: $comments = $sanitizer->entities($sanitizer->textarea($input->post->comments)); $message .= 'Comments: ' . $comments; This is because $sanitizer->textarea() is for input – BTW, in your code you use $sanitizer->text() which is for single line only, so you might want to change it – while $sanitizer->entities() is for output which in this case will be performed at the email client's end. See this discussion for example (last comment at the bottom): https://stackoverflow.com/questions/17115426/do-i-need-to-sanitize-user-inputted-data-before-sending-it-in-an-email Sometimes it happens but I have not yet figured out when. Other times I get emails in "almost no time".
    1 point
  38. Hi folks, I published "Simple file downloads with ProcessWire tutorial" today which explains how to make a simple download function with ProcessWire (tested with version 3.0+). Basically this is based on my post here in the forums
    1 point
  39. just add the "pw-panel" class to your link. if you want it to reload on every open add "pw-panel-reload". see here for details: https://github.com/processwire/processwire/blob/master/wire/modules/Jquery/JqueryUI/panel.js
    1 point
  40. This site was one of my first PW attempts a couple of years ago. I recently upgraded it to PW 3.0.60 and changed it to delayed output rather than header/body/footer format. URL: https://rockpoolpainting.com.au/ PW: v3.0.60 Modules: Admin Help Page Admin Help Setup Admin Help Tab Admin Save Actions Database Backups Email Obfuscator File (for FormBuilder) Form Builder Forms Jquery jQuery DataTables Plugin Json-LD Schema Markup Simple Navigation Markup Sitemap XML Mobile Detect Modules Manager Modules Manager Notification Page Delete ProCache ProFields: Table Template Editor Templates Reference (multiple) Features: To keep the home page content fresh, the list of services (repeater field) and 'Examples of our work' (Gallery page children, limit = 3) are randomly shuffled. Display changes subject to ProCache refresh. Testimonials are also randomly shuffled to keep content fresh Submission of the testimonial form adds the form data to an unpublished item in a pagetable on the testimonials admin page so the admin doesn't have to go to Setup->Forms->testimonial->Entries to view/edit/approve/delete the new submission (thanks netcarver ) Framework is Bootstrap although didn't use Bootstrap profile All pages validate on https://validator.w3.org/ Considering the number of images and the fact it's on a shared host, page speeds are acceptable on https://developers.google.com/speed/pagespeed/insights/ Photos of Tuggerah are my kitchen that Chris painted
    1 point
  41. I figured it out: While using Axios.post() one has to set the Header explicitly to: 'X-Requested-With': 'XMLHttpRequest' Just in case someone is facing the same Problem in the future: axios.post('/pathTo/script/', yourData, {headers: {'X-Requested-With': 'XMLHttpRequest'}}) Have a nice weekend.
    1 point
  42. it works! $lang = $user->language->name; if($lang == 'default') { setlocale(LC_TIME, "de_DE.UTF8"); } else { setlocale(LC_TIME, "en_EN.UTF8"); } and utf8_encode(strftime('%A <br>%d %B %Y', $page->getUnformatted('postDate'))) THANKS!
    1 point
  43. Haven't tested it (wrote it in the browser). But something alike should do the job. Maybe add some extra sanitizing on the old and new pass too. Inside a template: if (!$user->isLoggedin()) throw new Wire404Exception(); if (!$sanitizer->name($input->post->submit)) throw new Wire404Exception(); $username = $user->name; $old_pass = $input->post->old_pass; $new_pass = $input->post->new_pass; if ($username === 'guest') throw new Wire404Exception(); if (!empty($old_pass) && !empty($new_pass)) { $u = $users->get("name=$username"); if ($u->id) { try { $u = $session->login($username, $old_pass); if ($u->id) { $u->setOutputFormatting(false); $u->pass = $new_pass; $u->save(); $u->setOutputFormatting(true); $u = $session->login($username, $new_pass); } } catch (WireException $e) { // show some error messages: // $e->getMessage(); } } } Inside a method: if (!$this->user->isLoggedin()) return; if (!$this->sanitizer->name($this->input->post->submit)) return; $username = $this->user->name; $old_pass = $this->input->post->old_pass; $new_pass = $this->input->post->new_pass; if ($username === 'guest') return; if (!empty($old_pass) && !empty($new_pass)) { $u = $this->users->get("name=$username"); if ($u->id) { try { $u = $this->session->login($username, $old_pass); if ($u->id) { $u->setOutputFormatting(false); $u->pass = $new_pass; $u->save(); $u->setOutputFormatting(true); $u = $this->session->login($username, $new_pass); } } catch (WireException $e) { // show some error messages: // $e->getMessage(); } } }
    1 point
  44. Just wanted to throw in my two cents. If you come at it as a front-end developer that's a complete beginner to CMSs, then PW should be very easy to get going. It's built around working the same way that existing web technologies work… Pages map in the same way that URLs do… Template files are just plain HTML/PHP files… the API is largely the same as a front-end API (jQuery)… and so on. So if you know your basic web technologies outside of CMSs, then you won't find a simpler system than ProcessWire. The problem is most other CMSs don't work that way. So the line gets more blurry when you've become used to the terminology and approach of another CMS, because PW can be quite different. Sometimes you have to unlearn what you know from elsewhere in order to appreciate the simplicity of PW. People are always trying to find complexity that isn't there, especially those that grew up on other platforms. PW is a system that rewards you by being curious. We aim to show you how to fish so that you can catch the big fish. We're not here to catch the fish for you. You don't have to know anything about fishing, but you should know how to yell for help if you fall in the water. And you should be willing to learn by example. I learn best by example, so this is the way I tend to teach too (and I recognize not everyone learns the same way). PW is a CMS and CMF, not a website builder. If you are curious and willing to explore, you'll find it is very simple indeed. Certainly far simpler than even WordPress in creating a custom website. You do have to come from the point of view of "I want to create and have the system adapt to me" rather than "I will create something based on what the system provides." If you already know what you want to create and it's something unique, you won't find a simpler path to get there than PW. WordPress is a different beast, in that it's basically saying "YOU WILL CREATE A BLOG or modify this blog and call it something else." Some people like that underlying structure… "okay, we're starting with a blog, what can we do with it?" Others do not like that underlying structure. Our audience consists of those that want to have a system support their original creation rather than mash up an existing creation. There was a PDF posted earlier that I think hit upon some good points, and I appreciate the effort that went into putting it together. The fictional character being scripted in the dialog is not our target. I can go into specifics if anyone wants me to, but I was definitely left feeling at the end of it that we have to be careful about hand-feeding too much or else we'll start attracting people beyond our support resources. Folks that want the fish cooked and filleted rather than folks learning to fish. Perhaps in time we will want to attract more of the consumer-type audience, but currently I don't know how to support users looking to find all the answers in a sitemap file. Keep in mind that unbridled growth is not necessarily desirable. Most of us don't get paid for most of the work we do here and we do best if we grow in a more healthy manner, attracting more thoughtful designer/developers that are here to learn and also contribute. Obviously the author of the PDF is one of the thoughtful ones (and the PDF is a great contribution), even if his fictional character isn't necessarily, but we'll welcome him anyway. But we will definitely be going through the PDF in more detail to learn and improve from it where appropriate, while keeping our audience in mind. I think we're doing something right, because our audience is growing rapidly. I'm nearly full time on ProcessWire now, and it's still difficult to keep up with everyone. At present, I like that our audience is largely open-minded, curious and thoughtful designers and developers. Somehow we've attracted an incredible quality of people and that's what makes this place great. We could not ask for a better group of people here. I'm reluctant to lead PW towards a website builder direction because I think that's when the quality of the community could go down, as people come looking to eat fish rather than learn, catch some fish, and throw some back. The reality is that part of our long term goals include converting the rather large audience that has outgrown WordPress into ProcessWire users. I'm convinced that we do that by giving them more ProcessWire, and not more WordPress. But at the same time, we always have to keep an eye on WordPress and learn. They've been lucky no doubt, but they are also doing many things right. So we have been and always will be working to make the WP-side of users more comfortable in ProcessWire, while also trying to help them grow by distancing them from the limited WP mindset.
    1 point
×
×
  • Create New...