Jump to content

Robin S

Members
  • Posts

    4,772
  • Joined

  • Last visited

  • Days Won

    302

Everything posted by Robin S

  1. Rather than making duplicate Song pages as children under the playlist, could your Playlist template have an Autocomplete Page field "Songs" where you select Song pages?
  2. Media Manager might be the slickest option for this. Not 100% sure but I think it allows you to upload new media directly from a page being edited. If you want a no-cost solution you could look at adapting this module from @mr-fan, which is based on code by @adrian https://github.com/mr-fan/AutoImagePages But it doesn't allow for the uploading of new files directly from a page being edited - you must upload from the parent page of the files/images branch.
  3. There are a couple of solutions linked to in this topic in the FB VIP forum.
  4. HTML renders fine for CKEditor fields. For text or textarea fields there are two possibilities: Strip the tags... $this->addHookBefore('Fieldtype::markupValue', function($event) { $field = $event->arguments('field'); $page = $event->arguments('page'); $value = $event->arguments('value'); if($field->name == 'my_field' && $page->template->name == 'my_pagetable_template') { $event->arguments('value', $this->sanitizer->textarea($value)); } }); ..or decode entities (being mindful of potential security risks that this opens up)... $this->addHookAfter('Fieldtype::markupValue', function($event) { $field = $event->arguments('field'); $page = $event->arguments('page'); if($field->name == 'my_field' && $page->template->name == 'my_pagetable_template') { $event->return = html_entity_decode($event->return); } });
  5. @Ivan Gretsky, did kongondo's reply solve your issue? If you mean the additional template restrictions added by TemplatesChildPages, I didn't include a method for returning the allowed templates as the module is only intended as an admin helper (and it only autoloads on admin pages). If you still have a need to get the module's template restrictions for a given parent via the API let me know and I'll look at adding a method for that purpose.
  6. There's really no difference between a 'filter' and a 'search'. The filter sidebar is a effectively a search form that submits automatically every time one of the form elements changes (the submit is executed with Javascript). The index page is effectively a search results page - when no filters are set the search is fully open. Using a variable for your $pages->find() selector string it would be something like: $selector = "template=hotel, limit=5"; In the index template you look for $input->get() variables. As an example, take a single GET variable: stars=4 You check that the variable name is valid (is one of the variable names you are expecting, otherwise ignore it). You sanitize the value appropriately for that variable (in this case it should be an integer). Then you add to your selector string accordingly, narrowing down the results your selector will return... $selector .= ", $approved_var=$sanitized_value"; You will probably build up your selector string by looping over all of $input->get(). You don't need a separate template for the filter form. If you want to use the filter on several templates you can put the code in a separate PHP file and include it in your templates. Check out the Skyscrapers profile for a good example of a search template: https://github.com/ryancramerdesign/skyscrapers2/blob/master/search.php https://github.com/ryancramerdesign/skyscrapers2/blob/master/_func.php
  7. This is not the right way to get the url of a single image. When using image fields you want to select the "Formatted value" setting that suits the number of images your field is allowed to hold. I recommend you stick to two of these options: Array of items - select this when "Maximum files allowed" is set to either 0 (no limit) or greater than 1 Single item - select this when "Maximum files allowed" is set to 1 Next you need to understand what is going to be returned when you use $page->image (assuming your image field is named 'image'). If you chose "single item" then $page->image will be a single image object. If you chose "array of items" then $page->image will be an array of image objects. You don't want to ever echo an object itself (it may return some value but it's generally not good practice), but you might echo some property of the object (e.g. description) or call some method on the object (e.g. url or size). When dealing with an array of image objects you will either loop over them with foreach or you can get a single object from the array with a method such as first() or eq(). So take this code example from above: You want to get the URL of a single image in the field. If your image field is formatted as "single item" then you would do this: $image = $page->image->url; If your image field is formatted as "array of items" then you would do this: $image = $page->image->first()->url; One more thing... You are setting width and height attributes on the img tag so you should use the size() method to make sure the image is cropped to the same dimensions (or same ratio of dimensions if you are wanting a HiDPI image). $page->image->size(600,480)->url Otherwise you wont get the desired result if someone uploads an image with a different aspect ratio.
  8. @Qualtext, I tried your module in PW 3.0.45 but I couldn't get it set up properly. You'll see in the screenshot below that I have selected a parent page and an image field but the other settings are not applied automatically on save. Maybe this is due to the changes introduced to Page field settings in 3.0.45? It would be helpful if you listed the steps that users should go through in order to get the revised version of your module set up and ready to use. Something that we can refer to more easily than the video (which you could upload to YouTube and embed here in the forum BTW). The custom inputfield type seems to be unavailable?
  9. Maybe one of the parent pages has a template that has access restrictions and children inherit these? I routinely define access for all templates (because I often set restrictions on the Home template and these would otherwise flow down throughout the site). Less head-scratching that way.
  10. You could use a hook to override the decision not to show notifications in modals: $this->addHookAfter('AdminTheme::getExtraMarkup', function($event) { if($this->input->get('modal')) { $this->modules->get('SystemNotifications')->hookAdminThemeGetExtraMarkup($event); } });
  11. Yeah, looks like the extra markup isn't appended when the modal GET variable is present. https://github.com/processwire/processwire/blob/35df716082b779de0e53a3fcf7996403c49c9f8a/wire/modules/System/SystemNotifications/SystemNotifications.module#L113-L115
  12. That's strange. I didn't test with real modals (just appended "modal=1" to the urls) but see the screenshots below of Page Edit and a module config. Maybe something is different when the page is really inside a modal.
  13. Not sure I understand what you mean, but the native notices do appear regardless of whether an admin page is viewed in a modal (?modal=1) or not. Or do you mean you want to prevent the notices from appearing normally and open a modal window that only displays the notices?
  14. You don't have to symlink anything - just keep the CKEditor plugin inside your module folder and then load that path as an external plugin.
  15. I just private messaged you with some stuff, but for anyone else that is following the discussion, check out how Hanna Code Helper handles the loading of a CKEditor plugin: https://github.com/teppokoivula/HannaCodeHelper/blob/c26b3b7eeafa17dd8500dc1b89cbb88218ceca9c/HannaCodeHelper.module#L55-L97
  16. Just tested this and it works for me - I can also see checked checkboxes contained inside InputfieldMarkup (but not unchecked ones). public function getModuleConfigInputfields() { $post = $this->input->post; bd($post, 'post'); $inputfields = new InputfieldWrapper(); $f_name = 'addnew_text'; $f = $this->modules->get('InputfieldText'); $f->name = $f_name; $f->label = 'A text field'; $f->value = $this->$f_name ?: 'Add New'; $inputfields->add($f); $f = $this->modules->get('InputfieldMarkup'); $f->name = 'my_markup'; $f->label = 'My markup'; $f->value = " <label> <input type='checkbox' name='my_checkbox'> My checkbox </label> "; $inputfields->add($f); return $inputfields; } This approach seems strange to me. Normally your module config is what defines your settings - so you check the module config values in your module methods and do things accordingly. You seem to be doing it back-to-front, like you are looking for settings defined elsewhere and then putting fields into your module config. Wouldn't it be better to just use actual checkbox fields in your module config to define the settings?
  17. I think you want to have a method in your module that hooks Modules::saveModuleConfigData. At the top of that method you check if it is your module that was saved and return if not. $module_name = $event->arguments('className'); if(is_object($module_name)) $module_name = $module_name->className(); if($module_name !== $this->className()) return; Then do whatever based on the saved config data. $cfg = $event->arguments('configData'); I think you can also get submitted config values from $input->post within your getModuleConfigInputfields() method but that seems less desirable.
  18. @ryan, could you please make a full profile of the updated Skyscrapers demo available? So it is easily installable for people to try out, like the previous version. It has come up a couple of times in the forums recently.
  19. The Skyscrapers demo is a good example of a collection profile. http://processwire.com/demo/ https://github.com/ryancramerdesign/skyscrapers2 The demo was updated recently and I don't think a full profile of that is available yet. But the template files in the GitHub repo show how the site works. And the old Skyscrapers profile is available here if you're interested.
  20. $page is an API variable, so it's already defined at the time your _init.php runs. $child is not an API variable - it's a variable that you have defined yourself. So you need to make sure it is defined before you try and do anything with it such as $child->created. I don't see $child being defined in your _init.php. I tried both the renderPager() examples you gave and they execute fine. There must be something else that is causing the 500 error. Check your error logs to see if that sheds any light. Are you developing locally or on a live server? If it's a live hosting you may be getting false positives from mod_security if that is installed, so ask your host to disable mod_security in that case.
  21. @Elías Gómez, can you post the code you are using to loop over your event pages? It's hard to offer much advice without seeing that. Also let us know what you have selected for the "Formatted value" in the settings of your image field. As a general tip, if you spend a little time getting to know the Tracy Debugger module you will find it very valuable for investigating these kinds of issues. https://processwire.com/blog/posts/introducing-tracy-debugger/ http://modules.processwire.com/modules/tracy-debugger/
  22. Nothing useful on the body I think but there is a class on the h1 and also its containing div:
  23. I think maybe you are already onto this idea (saw your posts in another thread), but you could use RuntimeMarkup to create a non-editable table view in Page Edit showing the payments.
  24. Hi NikNak. That's correct - think of the role dropdown as a required field. Come to think of it, I will set the that config inputfield as required in a module update. While it would be possible to restrict PageTables for superusers with this module, I deliberately excluded superusers from the role dropdown. My view is that it is part of the PW philosophy that the superuser role is not subject to any access restrictions and I want the module to be consistent with that. IMHO the only user that should have the superuser role is the site developer - you shouldn't give superuser access to a client. Better to create new role for the client with whatever access is needed.
×
×
  • Create New...