Jump to content

Robin S

Members
  • Posts

    5,009
  • Joined

  • Days Won

    333

Everything posted by Robin S

  1. Not sure that you need to do the first pipe replace - you could just explode on commas and then trim(). You'll add the pipe when you implode. Also, passing by reference in a foreach can catch you out so perhaps better to avoid it. // Explode search input into array $search = explode(",", $input->get->search); // Sanitize each value foreach($search as $key => $value) { $search[$key] = $sanitizer->selectorValue(trim($value)); } But otherwise it looks fine to me; that's what I would do.
  2. Hi @mmc, welcome to the forums. It strikes me as unusual to use CKEditor in a contact form - I don't think I've ever seen a contact form that invites the visitor to submit their message using an RTE. A plain textarea is more typical. But anyway... For width you can set the inputfield columnWidth property: $field->columnWidth = 25; // sets width to 25% Or you can just set the width of the element that contains CKEditor in your CSS. For height, InputfieldCKEditor extends the InputfieldTextarea class so you can use the rows property: $field->rows = 3;
  3. This is very cool. Both the module and the bundled actions will be super useful. Thanks!
  4. Just adding Ryan's answer from the Github issue for future reference:
  5. I expect this wouldn't suit because you want the separate $bookings variable for doing other things with, but just wanted to add that you can get to an array of room data in a single query: $roomsData = $pages->find("date=$today, parent.room=roomOne"); // you'd probably limit by template here too
  6. @elabx, the unformatted value of an images field is always a WireArray. Having the value be a Pageimage for a single image field is the result of output formatting. I think what Soma is saying above is that output formatting is off when you bootstrap the PW index.php. So the issue doesn't occur because of an AJAX call, it occurs because of the bootstrapping. So solutions would be either: Just be aware that output formatting is off when bootstrapping PW and adjust your code accordingly In your AJAX call, load a normal PW page rather than a PHP file that bootstraps index.php
  7. I believe that each time you call $pages->find() or $page->find() the PageFinder class is used to query the database. If you're wanting to analyse performance in detail then Profiler Pro in the new ProDevTools would probably be money well spent. Besides the tool itself there is this benefit:
  8. This is trivial, but the template edit link in the Page List hover actions is 1 pixel lower than the other actions. Same in Chrome and Firefox.
  9. When editing field settings (Setup > Fields > my_field) I'm seeing an error: PHP Notice: Trying to get property of non-object in ...\modules\AdminOnSteroids\AdminOnSteroids.module:1224 BTW, thanks for making this configurable:
  10. This line is different to what you show in the codeblock above it: namely, there is the extra ->id in there. The ID property of a page is an integer, so it doesn't have a mainImage that you can call size() on. If you remove the ->id it should work, but I recommend you check to make sure mainImage is actually populated (i.e. that an image has been uploaded to the field) before you do size().
  11. Have you seen this module? http://modules.processwire.com/modules/pages2-json/ I think a hook to Pages2JSON::getValue could be used to return the fields from the Repeater child pages.
  12. ProDev Tools: Sold! Sounds perfect to me.
  13. Ah, that's great news! When I was trying to resolve the problem I was focusing trying to adjust the position of the child <ul>s that flyout to the right - it didn't occur to me to try adjusting the parent <ul>. Good stuff!
  14. I don't think that will work. The submenu is positioned using the jQueryUI Position utility. Anything you do in CSS to change the dimensions and/or position of the submenu is accounted for by Position and it will just move the submenu further over as a result. The admin menus would be so much more manageable if they were just simple nested <ul>s. I don't understand why the admin theme takes the complicated approach it does.
  15. That's odd - I don't see how that can happen. An images field will return an array of images (a 'Pageimages' WireArray) if you have chosen that in the field settings. This approach is okay, but if it were my project I think I'd find that a bit awkward. Hard for editors to make a clear connection between which text field goes with which image. And 10 identical fields seems like something to avoid where possible (maintenance would be a pain for a start). Suggestions... If the text field only needs a normal text input then use the Description field for each image. If the text field needs to be a textarea then try the Image Extra module. If the text field needs to be a CKEditor field then consider creating a Repeater containing an image field limited to 1 image and the CKEditor field. Then you can fix the Repeater to 10 items using Limit Repeater (shameless self-promotion )
  16. It's Bootstrap-specific in that Bootstrap requires you to add (among many, many other things) an unnecessary data-toggle="dropdown" attribute to the <a> element. It's unnecessary as that element can already be targeted as a direct child of an <li> element with "has_children" class (or whatever other class you might want to use for dropdown menu purposes). That is what @ottogal referred to above: MarkupSimpleNavigation does not equal ProcessWire - it's a third-party module for ProcessWire. PW allows you to generate your markup any way you choose. Personally I find MSN to be a very useful module but it's not compulsory to use it. Some people create their own menu markup from scratch using just the API and basic PHP functions like foreach(). And there are other modules for generating menu markup such as Menu Builder (haven't used it myself). I'm not a good one to answer this as I don't like CSS frameworks - I find them a hindrance rather than a help. I prefer to create my stylesheets for each project from scratch using SCSS. That way there's no bloat and I can build exactly to my design mockups without needing to conform to any framework expectations. I understand UIKit is popular with others though.
  17. You will find debugging much easier using Tracy Debugger than with $this->message. Have you seen these modules and topics relating to Amazon storage? http://modules.processwire.com/modules/amazon-s3-cloudfront/ http://modules.processwire.com/modules/schedule-cloud-backups/
  18. Well, the markup you want to output is actually quite complicated. Needlessly complicated too IMHO, but that's Bootstrap's fault. @Soma, author of MarkupSimpleNavigation, said it pretty well: Couldn't agree more. Soma does have a Gist for generating Bootstrap markup with MSN, but it's for Bootstrap 2: https://gist.github.com/somatonic/6258081 Here is one way you could generate markup for your menu: $nav = $modules->get('MarkupSimpleNavigation'); $options = array( 'has_children_class' => 'has_children dropdown', 'levels' => true, 'max_levels' => 2, 'selector' => 'template!=MediaLibrary', 'outer_tpl' => '<nav class="collapse navbar-collapse navbar-right" role="navigation"><div class="main-menu"><ul class="nav navbar-nav">||</ul></div></nav>', 'inner_tpl' => '<div class="dropdown-menu"><ul>||</ul></div>', 'item_current_tpl' => '<a class="current" href="{url}">{title}</a>', ); $nav->addHookAfter('getItemString', function(HookEvent $event) use($options) { $item = $event->arguments('page'); if($item->hasChildren() && count($item->parents) < $options['max_levels']) { $class = $item == $this->page ? ' current' : ''; $event->return = "<a class='dropdown-toggle{$class}' data-toggle='dropdown' aria-expanded='false' aria-controls='navbar' href='{$item->url}'>{$item->title}</a>"; } }); echo $nav->render($options); Don't know about your JS issue, but that won't be PW-related.
  19. Thanks @adrian, I knew there would be a simple solution. And, thanks @kongondo
  20. Is it possible to define a variable in the place that the hook is attached (e.g. ready.php or a template file) and then access that variable inside the hook function? $animal = 'cat'; $this->addHookAfter('Class::method', function($event) { // is there some way to use $animal here? }); I tried passing the variable as a second argument in the anonymous function but got an error. Missing argument 2 for ProcessWire\ProcessWire::{closure}()
  21. FYI, I released a Limit Repeater module.
  22. I'm really enjoying module development in PW. The flexibility that comes from hooks is brilliant. A couple more modules due shortly. An all-time classic.
  23. LimitRepeater Allows restrictions and limits to be placed on Repeater fields. For any Repeater field you can limit the number of items that may be added and also prevent the use of drag-sorting, toggling of published state, and the trashing of items. There is also an option to hide the clone button when the limit is reached. Usage Install the LimitRepeater module. Since v0.2.0 the module settings are configured at Setup > Fields > [your Repeater field]. The settings are contained within the "Restrictions" fieldset on the "Details" tab. Please note that the restrictions limits are applied in Page Edit with CSS/JS so should not be considered tamper-proof. Setting restrictions via a hook Besides setting restrictions in the field settings, you can also apply or modify restrictions by hooking LimitRepeater::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 field $inputfield This Repeater inputfield $page The page that is open in ProcessPageEdit The method returns an array of restrictions for the Repeater field. An example of a returned array: Example hook Prevent non-superusers from trashing any items in "my_repeater_field": $wire->addHookAfter('LimitRepeater::checkRestrictions', function(HookEvent $event) { $field = $event->arguments('field'); $restrictions = $event->return; if($field->name === 'my_repeater_field' && !$this->user->isSuperuser()) { $restrictions['notrash'] = true; } $event->return = $restrictions; }); Upgrading from < v0.2.0 There are two major changes to be aware of when upgrading from earlier versions of the module. The settings are no longer defined on the module config page, but rather in the field settings of each Repeater field: Setup > Fields > [your Repeater field]. If you visit the module config page you'll find shortcuts to the settings for each Repeater field. In earlier versions you could apply restrictions to a particular role. This is still possible but is now handled by hooking LimitRepeater::checkRestrictions as this is a more flexible and powerful approach. If you were applying restrictions to a particular role or roles you'll need to add hook code to achieve the same effect after you upgrade the module. See the hook information above in this readme. https://github.com/Toutouwai/LimitRepeater http://modules.processwire.com/modules/limit-repeater/
  24. @MaryMatlow, the commented default options in the MarkupSimpleNavigation docs say this... 'list_tpl' => '<li%s>||</li>', // template string for the items. || will contain entries, %s will replaced with class="..." string %s is a placeholder for the dynamic classes such as 'has_children', 'level-n', etc. If you remove the %s placeholder in list_tpl as you have done in your options there is nowhere for the dynamic classes to be inserted. So revert back to the default for list_tpl (and as @Speed said, you only need to set options you are changing from the default). If you want 'dropdown' to be added to the classes of every list item you set this... 'list_field_class' => 'dropdown', ...or if you want it to be added to the classes of only list items that have children you set this... 'has_children_class' => 'has_children dropdown',
×
×
  • Create New...