Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/22/2016 in all areas

  1. Just found http://intercoolerjs.org/ It does declarative ajax. Frontend wizardry without writing javascript. I'm impressed.
    5 points
  2. "equipment" is a page array. You can use the removeAll method to clear it of all items: $player->of(false); $player->equipment->removeAll(); $player->save(); $player->of(true);
    4 points
  3. Hi Tom, I think this was corrected in 2.7.3 or so (somewhere on the dev branch). To fix it in 2.7.2, unhide Admin > Pages.
    4 points
  4. $player->of(false); foreach($player->equipment as $equipment){ $u->equipment->remove($equipment); } $u->save("equipment"); EDIT: Ignore this and go with BitPoet's solution. I was just confirming that removeAll() worked, but he beat me to it
    3 points
  5. The newest Zurb Foundation seems to have learned quite a bit from other, more customizable, systems like Susy or Singularity and let you use their inner workings/mixins for your own css selectors, so no more row, col, hide, show classes littered through your markup.But I haven't looked much into that, since I use Susy2 for most stuff. It took a little while to get the concept of context (say you have an eight col grid, and inside an 4 of 8 spanning element you nest another element with span(2 of 8) - what width would you expect?) but once it clicks, working with Susy is really fun. but like processwire it leaves a lot of decisions to you as the developer, not offering pre-setup solutions, so compared with bootstrap or foundation it seems less comfortable at first glance. but if you really need to, you can easily integrate parts like the forms- or navigation patterns of foundation into Susy, and what I really like about Susy is, that I can keep my markup clean and can go from early prototypes to full production code with the same code basis, adding fidelity and complexity as the project progresses.
    3 points
  6. Tracy Debugger for ProcessWire The ultimate “swiss army knife” debugging and development tool for the ProcessWire CMF/CMS Integrates and extends Nette's Tracy debugging tool and adds 35+ custom tools designed for effective ProcessWire debugging and lightning fast development The most comprehensive set of instructions and examples is available at: https://adrianbj.github.io/TracyDebugger Modules Directory: http://modules.processwire.com/modules/tracy-debugger/ Github: https://github.com/adrianbj/TracyDebugger A big thanks to @tpr for introducing me to Tracy and for the idea for this module and for significant feedback, testing, and feature suggestions.
    2 points
  7. The textformatter multivalue is not really suitable for clients, but useful for quickly adding data structure by devs. Therefore a module with UI would be handy.
    2 points
  8. OMG, someone asked "How would this compare with Joomla?" Where do I even start?
    2 points
  9. Another vote for Susy here. It took me a little while before it clicked, but once you understand it, you'll never want to get back. Good intro tutorial: https://www.smashingmagazine.com/2015/07/smarter-grids-with-sass-and-susy/ One thing I like about it: The markup is kept lean. You define the grid behavior on the element without giving the element 3-4 classes (for each breakpoint). article { @include span(8); } aside { @include span(4 last); } i.e. you don't need any grid classes on the HTML elements anymore, like Bootstraps: .col-xs-12 .col-sm-6 .col-md-8 etc. You can define your entire grid-system with something like this: $susy: ( columns: 12, container: 1200px, gutters: 1/4, global-box-sizing: border-box, debug: (image: show) );
    2 points
  10. noodles and I got this running! Our scenario was a ProcessWire 2.7.x version we upgraded to ProcessWire 3.0.7. Uploads would stop at 100% and not finish. The JavaScript console showed the message jacmaes mentioned above. What did we do? We changed all fields of type "CroppableImage" back to "Image" and deleted the module, including the files in /site/assets/cache/FileCompiler/site/modules/CroppableImage. When we reinstalled the module, we were able to upload files successfully and the previously set thumbnails were created by the module! Everything seemed to work to this point, but cropping didn't work, due to missing processes and routes. The page created within the ___install routine of the module wasn't created!(https://github.com/horst-n/CroppableImage/blob/master/ProcessCroppableImage/ProcessCroppableImage.module#L306) We created it ourself within the admin.php file (dirty, we know - see code below), as a child of /admin/pages, edited and assigned the Process (ProcessCroppableImage) in the given select box within ProcessWire. Et voilà, it works! Dirty workaround we used within the admin.php file as a superuser: $p = new Page(); $p->template = $this->templates->get("admin"); $p->parent = $this->pages->get(3); $p->title = 'Croppable Images - PW3'; $p->name = 'croppable-image'; $p->addStatus(Page::statusHidden); $p->save(); This for sure is dirty, but it will give us all a little more time. We will try to provide a good fix/workaround to make upgrades possible without following the steps above by hand.
    2 points
  11. Revising the problematic part of the code I posted in the OP, here's the new and improved part: if ($field->type == "FieldtypePage") { $table = wire('fields')->get($field->id)->getTable(); $query = wire('database')->query("SELECT tbl.pages_id, tbl.data, COUNT(*) FROM $table AS tbl INNER JOIN pages AS p ON tbl.pages_id = p.id INNER JOIN templates AS t ON p.templates_id = t.id WHERE t.id = '{$template->id}' GROUP BY data" ); $ids = $query->fetchAll(PDO::FETCH_NUM); // Multidimensional array (2 levels) [0] => array(2047, 4419, 12). The second level corresponds to the selected columns in the query. // Add options that are in use by our products to a whitelist. foreach ($ids as $item) { $whitelist[]= $item[1]; } $options = $inputfield->getInputfield()->getOptions(); // Returns simple assoc array [4777] => dieren, [4778] => tweeling, etc. // Remove unsued options from the field. foreach ($options as $pageID => $pageTitle) { if ( !in_array($pageID, $whitelist) ) { $inputfield->getInputfield()->removeOption($pageID); } } if (!count($ids)) continue; // No pages are using any of the option of this field, so don't add it to our form. } This shaves off about 100 ms of of 150 ms, so it's pretty darn fast compared to the way I did it before. I suppose maintaining a counter as suggested by BitPoet may be even faster, I'll have to compare it someday. Thanks everyone!
    2 points
  12. If you want HTTPS for the entire site, do it via .htaccess. That's more efficient. Template setting is an easy way to force it on for specific templates only.
    2 points
  13. Hi Tiffany - is this what you are looking for? foreach($page->tbl_CompanyURLs as $c_url) { if($c_url->url_company) echo "<a href='{$c_url->url_company}'>$c_url->url_company</a><br />"; if($c_url->url_updated) echo "<a href='{$c_url->url_updated}'>$c_url->url_updated</a><br />"; }
    2 points
  14. Still some work needed, but I just pushed the whole new version to GH and renamed it as MarkupCookieConsent. https://github.com/CanRau/MarkupCookieConsent/ (beta) It's now doing everything on it's own, means there are no externals involved. EDIT 1: Added screenshot to repo EDIT 2: Okay, I would say anything works (at least in Chrome on Mac) except the translatable config fields. Both themes are ready having each 2 available positions (top/bottom). Extended screenshots to show all 4 versions Added readme Added to module directory http://modules.processwire.com/modules/markup-cookie-consent/ EDIT 3: Lanaguage fields will work using this patch from Ryan, or you can just wait for the next PW devns release (probably on friday) Changelog 0.0.9 - Changed style injection, now prepends to first <link> in head makes it easier to add custom css tweaks without the need for !important because of the cascading order 0.1.1 - Fixed issue with cookie not being set, two strings wouldn't recognize translation, default cookie expire now 1 year, updated readme 0.1.2 - Added minified CSS & JS 0.1.3 - don't remember what changed in this version 0.1.4 - cookie bar now fully translatable, added devns branch which is meant to be used with PW 3.x devns as it adds namespaces 0.1.5 - fixed issue on single language installations Still have to test some things. For example, you can now select a page from your tree as policy page using InputfieldPageListSelect instead of entering the url, so now the link should work with multiple languages, too. Though I haven't exactly tested it yet! The language fields draw my attention. They look nice but only default language is saving at the moment. So this is how I build the config fields using MarkupCookieConsent.config.php file I kept only settings for one field.. public function getDefaults() { return array( 'messageText' => __("This website uses cookies to ensure you get the best experience on our website"), ); } public function __construct() { $this->add(array( array( 'type' => 'text', 'name' => 'messageText', 'label' => __('The message shown by the plugin'), 'useLanguages' => true, 'columnWidth' => 70 ) ) ); }); I'm not sure if/how I need to define default values for languages, too? I checked some other modules from Ryan but there he still uses the config field building ways getConfigInputfields() for example, so those are not really applicable, are they? So visually everything looks good, even when inspecting the fields the field names seem to be alright.. Or is this approach not yet multi lang capable? Everything else should work already. Ah except for the Default settings button at the bottom. It's more like to-do list for myself ;-) Ah and regarding "dependencies". When "Enable Ajax" checked, the form will be submitting using ajax (magic! haha), anyway..just to let you know it's using plain vanilla js so no jquery or anything else needed. Although it should work well, it's only tested in newest Chrome on Mac and the script is not handling errors. It's actually removing the cookie information right after the click and then making the request. So worst case would be, considering any error, the message popping up again even so the user thinks he already agreed... I figured it's probably not the kind of module which many will use, cause when you're a little into PW you now how to easily include such an information yourself. But for me it's especially practicing PHP.. So I would really love to get some hint on the language fields Side note: For everyone interested in disabling cookies at all to avoid every possible need for this plugin checkout out this blog post from Ryan http://processwire.com/blog/posts/multi-instance-pw3/#more-session-control
    1 point
  15. Needed to show someone how to quickly setup some settings for various things in a simple text area: could be used for slider settings, site settings, etc; What it does: gives you a matching variable for each key of each line... 1.) setup a textarea field for the settings ; i'm calling it settings_ta 2.) add delimited settings, 1 per line; i use a pipe (|) delimiter; example: address|some info here facebook|https://www.facebook.com twitter|https://twitter.com phone|(999) 999-9999 3.) in your _init.php, get the settings - replace the page number and the name of your settings field: $settings_ta = $pages->get(1644)->settings_ta; $settings_lines = explode(PHP_EOL, $settings_ta); foreach($settings_lines as $settings_row) { $settings_pair = explode('|', $settings_row); ${trim($settings_pair[0])} = trim($settings_pair[1]); } more condensed version, for those of you who like brevity... foreach(explode(PHP_EOL, $pages->get(1644)->settings_ta) as $settings_row) { $settings_pair = explode('|', $settings_row); ${trim($settings_pair[0])} = trim($settings_pair[1]); } now you can do this in your templates: echo $address; echo $facebook; echo $twitter; echo $phone; Edit: made the code simpler....; 2nd edit - added trim to support using ace editor with tabs Addendum: as an added convenience, you could use the Ace text editor module which would give you a monospaced text field and the ability to use tabs for your settings, which could be more readable and easier to edit. The code has been updated to support this by trimming the exploded strings prior to generating the variable/value. address | some info here facebook | http://www.facebook.com twitter | http://twitter.com phone | (999) 999-9999
    1 point
  16. Hey, The Form API has CSRF protection build in, but if you for some reason don't want to use the API you can however use the CSRF protection. Its very simple but it took some time for me to find out, so i figured i share my findings with the rest. What is CSRF? First you need to create a token and a token name you do that as following: $tokenName = $this->session->CSRF->getTokenName(); $tokenValue = $this->session->CSRF->getTokenValue(); Very simple. Now what you want to do is create a hidden input field like this: $html .= '<input type="hidden" id="_post_token" name="' . $tokenName . '" value="' . $tokenValue . '"/>'; Now this will generate something that will look like this: You are done on the form side. You can now go to the part where you are receiving the post. Then use: $session->CSRF->validate(); This will return true (1) on a valid request and an exception on a bad request. You can test this out to open up your Firebug/Chrome debug console and change the value of the textbox to something else. Basicly what this does is set a session variable with a name (getTokenName) and gives it a hashed value. If a request has a token in it it has to have the same value or it is not send from the correct form. Well I hope I helped someone.
    1 point
  17. 'outer_tpl' => '<ul class="right">||{$langSwitch}</ul>', Dragan use double quotes in his code. Your code should be: 'outer_tpl' => "<ul class='right'>||{$langSwitch}</ul>",
    1 point
  18. Awesome - thanks for letting me know. I did just make another change though in an attempt to fix the problem @Ipa is still having with the Variables panel. Hopefully this might work and hopefully I haven't broken anything for anyone else
    1 point
  19. @adrian: I just pop in to report that Tracy Debugger 0.5.5 on ProcessWire 3.0.8 with PHP 5.6.10 works without a hitch so far Thanx once more!
    1 point
  20. @BernhardB - please try the latest version for me.
    1 point
  21. ok last time it was not critical but now it was, so i implemented this little hook to check unsaved changes via javascript when clicking on the button defined at line var buttons = '#button_example_id'; when the user clicks the button the confirm-dialog appears code: /** * show warning message on button click if there are unsaved changes in the form **/ public function confirmUnsavedChanges($event) { $page = $event->object; // only add this to admin pages if($page->template != 'admin') return; ob_start(); ?> <script type="text/javascript"> $( document ).ready(function() { // buttons to observe var buttons = '#sendLoginLinkButton, #newInvoice'; $('body').on('click', buttons, function(e) { var msg = InputfieldFormBeforeUnloadEvent(true); if(typeof msg != "undefined" && msg.length) { if(!confirm(msg)) { e.preventDefault(); return false; } } }); }); </script> <?php $script = ob_get_clean(); $event->return = str_replace("</body>", $script."</body>", $event->return); }
    1 point
  22. Exactly. config.php is just a php files as well. You can do whatever you need there as long as you're at sometime setting the correct properties to the $config variable. But I'd limit it to things really needed at that stage. Anything else should rather go into init or ready.php.
    1 point
  23. Update version error is gone, thanks!
    1 point
  24. Hello, I'm coming back to you since I've finally managed to extract the 'buggy' part of my code. Here's my problem : When a player loses a level, I want this player to lose all his equipment, so I wrote : foreach ($player->equipment as $equipment) { $equipment->delete(); } But here's what happens : The original equipment pages get deleted ! Not just the item in the AsmSelect ! And I just can't figure why this happens ! Yet I'm sure I am misunderstanding some basic principle here... So if anyone could give me a hint, I'd appreciate. To be more precise : my equipment list is in my tree in equipment/weapons/ and has many pages, such as sword, bow, gun... (It looks violent but it's not, it's a classroom experiment to motivate teenagers ) and my AsmSelect resides in a player template so whenever a player has the possibility, he can select an equipment page. Everything works fine, except when I use this 'delete' line In other words, how could I clean this asmSelect without actually deleting the pages in the original equipment tree? Thanks in advance !
    1 point
  25. Thank you so much ! I can't believe I've passed through this one... It caused me a real headache having to manually repair the bad work with my 'delete' function. Now I've learned something again tonight thanks to both of you and I'm still enjoying more and more discovering ProcessWire Thanks again !
    1 point
  26. @Ipa and @tpr - can you please try the latest version and see if that error is now gone? Speaking of the latest version, it includes a few new features. The ability to force superusers to always be in DEVELOPMENT mode, even on a live site. The ability to restrict non-superusers by their IP address - this is very useful if you need to debug a live site for a guest (or non-superuser role) and want the debugger bar and other features normally restricted to development mode. You can set the mode to DEVELOPMENT, give the user the "tracey-debugger" permission, and then restrict to your current IP address. The Users panel provides details of IP Address restriction so you can always easily check if you're safe.
    1 point
  27. Hola amigos I'm quite excited about this one and really wanted to finish it myself or at least come with "bigger" problems^^ But now I need some advice as I'm stuck on some basics. The module is derived from FieldtypeEvents by Ryan. What it does It's a customizable two column table for key value pairs. Right now customization is about changing columns headings and column width. Customizing sorting of the rows is planned, and the input is already there but not yet working. Drag and drop sorting is planned for the future two. Translatable column headings are almost there, but I got the same issue like with the MarkupCookieConsent, so only default language is saving..and many more features are planned (and hopefuly will be included in the future) except those it's already working quiet nice. So when editing a page you can add/remove columns (ah they got sorted alphabetical at the moment). What it doesn't (And that's for me the most important part right now!) The API side is lacking remove of single and all rows capabillities, which I personally need right now because I build a small front end page edit screen to let users edit some data. I got the whole key/value input running adding rows on the fly like in the backend, but I'm not able to delete anything at all.. ^^ What I tried After digging and digging I realised that FieldtypeEvents is really basic and KeyValueArray.php (former EventArray.php) is missing some methods. At least I thought because some other modules are implementing there own remove() methods, even if I thought it should inherit all methods because it extends WireArray, I decided to copy some code without luck, trying to understand and alter as needed (seems really easy to understand) but still no luck at all. While writing this I thought it might be interesting to review the thread from Ryan about his FieldtypeEvents and found that someone just managed to remove an event by using remove($event) without changing Ryans code. So digging again trying some things, stumbling over public function removeQuietly($key) and finally this one deleted the row! So for now I just copied removeQuietly method into KeyValueArray.php and renamed it to remove($key) and it's working. But I would love to know why all this? Why didn't remove just work from WireArray.php? And why the copied methods still didn't worked? I tend to write and write and write haha.. Use cases What is all this useful for? Consider a contact template, you could use this field to store all contact information like so Some minutes ago I had some more examples but it's gettin late.. Ah Know that you can (like with FieldtypeEvents) not only foreach the whole table, but get them row by row: $row = $page->keyValues->get("Responsible"); $label = $row->key; $value = $row->value;Just noticed that the contact example would be even better with another sorting than alphabetical to just iterate the whole tableBut you could already get them line by line as needed ;-) Kay that's it for now.
    1 point
  28. $text = $doc->createTextNode($form_fields); $form_fields is an array: https://gist.github.com/somatonic/5233338#file-form-upload-php-L25 Depending on whether you limit your upload to just one file, or multiple files, you have to add some $form_fields foreach stuff to create one XML for each file...
    1 point
  29. hey this is great and was something i was eventually going to work on also, because it would be good to have a dedicated fieldtype for key value where they are entered into fields like this. Currently i use tables for this, and here is a thread with some other info, possible use cases; one thing that might be cool would be to have another column as in Martijn's example, so there is a name (key) label and value, and in his example there is also a trick for hiding the name of the keys from non super users (so they wouldn't break the front end in case they changed an in-use variable) https://processwire.com/talk/topic/8373-use-delimited-texarea-table-or-yaml-for-settings/
    1 point
  30. Could you please try: ❯ curl -I https://raw.githubusercontent.com/ryancramerdesign/ProcessWire/master/wire/core/ProcessWire.php What does this return? The error message occurs, if this curl request returns a state not equal to 200. Edit: This error message contains now more detailed information, there will be also an option `-v` to increase the verbosity of messages (coming soon): [RuntimeException] Error loading sha `xxx`, curl request failed (status code: XXX). Try `curl -I https://raw.githubusercontent.com/ryancramerdesign/ProcessWire/xxx/wire/core/ProcessWire.php` This should return `HTTP/x.x 200 OK`.
    1 point
  31. here is the documentation. I'll try to reproduce this error.. Edit: For me everything works as expected.
    1 point
  32. From the default PW htaccess file: # ----------------------------------------------------------------------------------------------- # If you only want to allow HTTPS, uncomment the RewriteCond and RewriteRule lines below. # ----------------------------------------------------------------------------------------------- # RewriteCond %{HTTPS} off # RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    1 point
  33. Adrian, you're my hero!!!!!! Should have posted my question earlier, thank you so much! Tiffany
    1 point
  34. Adrian, Perfect! You are a Champ! Many thanks.
    1 point
  35. Yep, so this is what you need: $user->of(false); $user->favs->add($page_id); $user->save("favs"); This of course assumes you are editing the currently logged in user. If not, then something like this: $u = $users->get($user_id); $u->of(false); $u->favs->add($page_id); $u->save("favs");
    1 point
  36. You don't have to start over again, when you're are not developing PW3 only modules as I'm doing these days.
    1 point
  37. Now I got it working ! I check again the username in this case, therefore I grab the username at the beginning of this code. $usernamevalue = $sanitizer->username($input->post->user);//grab the username after submit $database = $this->wire('database'); $name = $usernamevalue; $query = $database->prepare("SELECT attempts FROM session_login_throttle WHERE name=:name"); $query->bindValue(":name", $name); $query->execute(); $numRows = $query->rowCount(); if ($numRows) list($attempts) = $query->fetch(PDO::FETCH_NUM); echo $attempts;//this outputs the login attempts Hope this helps others with the same problem.
    1 point
  38. I am just about to go to bed so will continue working in the morning. Just thought I would say I have succeeded in getting SAML logins working All i had to do was set the session name in the ProcessWire config and do a bit of work on the user matching and signing in Now when I go to the admin URL when not logged in it will do a SAML login, if the user logging in has a ProcessWire user (matched by email at the moment) then it will log them in. Need to work on log outs though, as when you log out it takes you back to the ProcessWire login page which then of course starts the SSO process again and just lands you right back where you started in the admin panel with a helpful notification saying "logged out" despite being logged into the admin panel :| Will work on that tomorrow, I may release this module if I can polish it up enough need to add configuration pages and such before I will consider that though.
    1 point
  39. update - if you need to be able to access your variables inside functions or the admin you can use $config.. in config.php, setup an empty array for siteSettings like this: $config->siteSettings = array(); then in ready.php file, array merge values from a settings table (profields table) or any other type of setting (MultiValue Textformatter, YAML settings ...), in the admin like this: // Get your settings from wherever $st = $pages->get('/settings/')->settings_table; // temporary array to merge with global $settings = array(); foreach($st as $row) { if(!$row->value) continue; if($row->disable == 1) continue; $settings[$row->setting] = $row->value; } // merge $config->siteSettings = array_merge($config->siteSettings, $settings); i'm curious if anyone sees any possible issues with this; it works now and i can access my siteSettings everywhere doing this; you can access the settings like this from templates: echo $config->siteSettings['yourKey']; or in function.. echo wire('config')>siteSettings['yourKey'];
    1 point
  40. Not sure if wireshell does allow for that, but if not you could go that way. > php -a php> include "index.php"; php> $pages->find("template=some_template")->each(function($p){ $p->setAndSave("field", "value"; });
    1 point
  41. I use MultiValue Textformatter for such cases. Mainly for social links, contact data and such. http://modules.processwire.com/modules/textformatter-multi-value/ https://processwire.com/talk/topic/10827-multivalue-textformatter/
    1 point
  42. A settings field based on a hooked Profields Table. When running the code (in the spoiler), superusers are able to edit, drag & delete all, while other users are limited to edit the setting only. (Thanks MacRura for the idea) Superuser sees: Everybody else sees: Code lives in the spoiler. Maybe some time I build a Module for this one.
    1 point
×
×
  • Create New...