-
Posts
4,928 -
Joined
-
Days Won
321
Everything posted by Robin S
-
You can also find the admin page name (and thereby the URL) by viewing the "pages" table in phpMyAdmin or similar. Look for the row with the id of 2.
-
Not very well - that's when you would want to use an inputfield that loads options on demand with AJAX. I think Autocomplete is the only core inputfield that does this. Misread your post and thought you meant Select Multiple. Page List Select Multiple uses the standard ajax-paginated page tree so that is fine for thousands of pages, although slower to use than Autocomplete. Inputfield Selectize is based on selectize.js which does have an AJAX load feature but I'm not sure this is available for pages in the PW module.
-
Maybe I'm misunderstanding something, but a Page field seems ideal for what you want to do. You leave the Song pages where they are (under Songs in the tree) and then select them in a "Songs" field in your "Playlist" template. Several of the available inputfields for a Page field allow you to sort pages in the field - Autocomplete is a good option for selecting from a large number of pages but you could use AsmSelect or some other inputfield if you prefer. In the screenshot below, imagine these "vegetable" pages are instead songs. This way you don't need any child pages under your Playlist pages. P.S. I think you forgot to add your screenshots.
-
Uploading files to page vs creating downloads 'folder'
Robin S replied to SamC's topic in General Support
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. -
Field for selecting form to embed (list all forms)
Robin S replied to heldercervantes's topic in Getting Started
There are a couple of solutions linked to in this topic in the FB VIP forum. -
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); } });
-
@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.
-
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
-
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.
-
Create a Module: image upload to another page and autocomplete
Robin S replied to Qualtext's topic in General Support
@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?- 7 replies
-
- image
- autocomplete
-
(and 2 more)
Tagged with:
-
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.
- 1 reply
-
- 4
-
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); } });
-
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
-
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.
-
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?
-
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?
-
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.
-
@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.
-
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.
- 5 replies
-
- 1
-
- collection
- collector
-
(and 1 more)
Tagged with:
-
$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.