-
Posts
10,877 -
Joined
-
Last visited
-
Days Won
348
Everything posted by adrian
-
Lots of images to resize -> timeout in frontend...
adrian replied to titanium's topic in General Support
@Wanze, I wasn't thinking about the first time the front end page was viewed. I guess it is the view of a page with lots of new thumbnails at once that is causing the timeout problem. @Titanium I thought I mentioned the idea of making a proportional option for the thumbnails module somewhere, but can't seem to find the post. Seems to me like it would be very useful and not hard to implement. @diogo I agree, but experience tells me that people are lazy and also can't follow instructions -
Lots of images to resize -> timeout in frontend...
adrian replied to titanium's topic in General Support
Although, I thought things like $image->width(1000) were supposed to be cached: http://processwire.com/talk/topic/10-how-do-i-interact-with-the-image-field-in-processwire/?p=20 So I don't know why you are getting the timeout issue. Maybe someone else can enlighten us -
Lots of images to resize -> timeout in frontend...
adrian replied to titanium's topic in General Support
This module should take care of what you need: http://mods.pw/1b -
Filter results of selector using select/checkbox?
adrian replied to antknight's topic in General Support
Well it sounds to me like you probably only want to be able to filter against things like land_area, living_space, number of rooms, number of bedrooms, number of baths, and price. I think you'll have to do something custom for this. I am still not sure if you have seen the search.php file from the skyscrapers demo, so I have attached it. You should be able to modify that for your needs. In particular, look at the section starting with: foreach(array('height', 'floors', 'year') as $key) { Hope that gives you a starting point - sorry you went down the road of trying out my code - good for what it does, but won't work out of the box for your case. search.php -
Filter results of selector using select/checkbox?
adrian replied to antknight's topic in General Support
Well no, not really. It looks like you need to add the name of the images field you are using to the $myfields array. You should also add any other fields that are not page fields. The skyscrapers site has a series of dropdowns that are page fields. Is this what you are looking for? I have attached what I see with my code. To get the search term field you need to uncomment those two sections in my last version above and make sure that you change: $field->attr('id', 'Inputfield_body'); $field->attr('name', 'body'); to match the name of the field you want to search for those keywords. If you don't want the keword search, you can leave as is. It looks to me like the fields that are showing up in your screenshot are not Page fields. EDIT: Alternatively if this is all seeming too hard, then you could download the files from the skyscraper example and use that code. The reason I like my option is that it is reusable throughout different sections on a site and on different sites - no need to define the filter search form for each usage scenario. -
Filter results of selector using select/checkbox?
adrian replied to antknight's topic in General Support
Sorry, did you see my note above about needing to echo it out? I actually have all that code in a filter_form.inc file. Then wherever I want to use it, I just put: include("./filter_form.inc"); echo $filter_formcode; Does that sort it out ? -
Filter results of selector using select/checkbox?
adrian replied to antknight's topic in General Support
You can comment out that line if you want, or add this function somewhere: function strip_selected_tags_by_id_or_class($class, $text) { $regex = '#<(\w+)\s[^>]*(class|id)\s*=\s*[\'"](' . $class . ')[\'"][^>]*>.*</\\1>#isU'; return(preg_replace($regex, '', $text)); } I added that because my page fields have the ability to add a new item and I didn't want this visible on the front-end, even though it will only be visible to logged in users with rights to add, it is still not appropriate for a front-end filtering form. Chances are it won't be relevant in your situation anyway, so I would just delete the line. -
Filter results of selector using select/checkbox?
adrian replied to antknight's topic in General Support
Try this complete code. It is actually as I have it working except I removed the text search box in case you don't have a body field, or need that functionality. Of course you'll need to add an echo at the end. I use this as an .inc so it is not in this code block for me. <?php $filter_formcode = ''; if($input->post->filter_save) { // Search selector builder $search_string = ''; $current_field = ''; //print_r($input->post); foreach($input->post as $field_name => $field_result){ if (is_array($field_result)){ foreach($field_result as $f_value){ if($current_field == $pages->get($f_value)->template){ $search_string .= '|' . (int)$f_value; } else{ $search_string .= ',' . $pages->get($f_value)->template . '=' . (int)$f_value; } $current_field = $pages->get($f_value)->template; } } /*else{ //This is only needed if you want the text search field which is an optional add on below if($field_name == 'body' && $field_result != ''){ $search_string .= $field_name . '%=' . $field_result; } }*/ } $search_string = trim($search_string,','); } else{ $search_string = ''; } error_log($search_string); $message = ''; // Populate with the names of the fields you want to exclude OR include (see instructions below) // Leave empty to output all the fields $myfields = array('id','title','body','images'); $form = $modules->get('InputfieldForm'); $fields = $page->child()->getInputfields(); /* //This adds a text search field if you want it $field = $this->modules->get('InputfieldText'); $field->attr('id', 'Inputfield_body'); $field->attr('name', 'body'); $field->label = "Search term"; $form->append($field); */ // If array is not empty use it to filter the fields if ($myfields){ foreach($fields as $f){ // Output all the fields minus the ones listed in the $myfields array // Instead, to output only the fields that are in the array, remove the (!) from the condition if (!in_array($f->name, $myfields)){ $f->value = ''; $form->append($f); } } } else{ // Else, include all the fields $form->append($fields); } // Add save button $field = $this->modules->get('InputfieldSubmit'); $field->attr('id+name', 'filter_save'); $field->attr('value', 'Find'); $field->label = "find"; $form->append($field); // Process the form if($input->post->filter_save) { $form->processInput($input->post); } $display = 'block'; if($form->getErrors()) { $display = 'block'; } $filter_formcode .= ' <div id="collapsed_form" style="display:'.$display.'">'; // render out form $filter_formcode .= $form->render(); $filter_formcode .= '</div>'; $filter_formcode = strip_selected_tags_by_id_or_class('InputfieldPageAdd', $filter_formcode); //Strip out the option to add new item to page field even though it only appears to certain admin users $filter_formcode .= '<script> $(document).ready(function() { $(\'select\').css({"max-width":"270px"}); $(\'li\').removeClass("InputfieldColumnWidth"); $(\'li\').removeClass("InputfieldColumnWidthFirst"); $(\'li\').attr("style", ""); }); </script>'; //set select to max width and remove floating selects so each one on own line -
Filter results of selector using select/checkbox?
adrian replied to antknight's topic in General Support
That code also works for me without populating existing values ( a good thing), but you'd still need to remove some fields like images etc. -
Filter results of selector using select/checkbox?
adrian replied to antknight's topic in General Support
Try editing this line: $myfields = array('id','title','body'); to include your images field and any others that are not page fields that should be included as filter select options EDIT: Definitely - I have it working on several sections of a site I am working on -
Filter results of selector using select/checkbox?
adrian replied to antknight's topic in General Support
Right - I see what you mean now - "the value which is selected". This is why I have this line: $f->value = ''; This clears the selected values when displaying the filter form. I agree this doesn't seem efficient, but it works and no other way seems to. -
Filter results of selector using select/checkbox?
adrian replied to antknight's topic in General Support
Just to clarify my setup, the fields are all ASM Page fields and I want the values so the user can choose the values to filter from (hence the need for getInputfields()). Wish I could show you guys the working version of this, but it's not live yet. -
Filter results of selector using select/checkbox?
adrian replied to antknight's topic in General Support
Catchable fatal error: Argument 1 passed to InputfieldWrapper::append() must be an instance of Inputfield, instance of Field given, called in /xxx/site/templates/filter_form.inc on line 101 and defined in /xxx/wire/core/InputfieldWrapper.php on line 159 -
Filter results of selector using select/checkbox?
adrian replied to antknight's topic in General Support
Try replacing: $fields = $page->child()->template->fields; with: $fields = $page->child()->getInputfields(); It's working great for me and no need for all that new page stuff - thanks Soma. Are you getting the same error, or a different one? EDIT: Is properties-listing.php the template for the parent page or the child pages. The filter code as I set it up needs to be in the parent template. Does that make sense? -
Filter results of selector using select/checkbox?
adrian replied to antknight's topic in General Support
Actually that creates an error, but this works: $fields = $page->child()->getInputfields(); Pitbull, I think if you remove those two lines I mention in #15 above and then use this line for getting the fields it should hopefully work for you. Let us know how it goes and I'll amend the initial code example. -
Filter results of selector using select/checkbox?
adrian replied to antknight's topic in General Support
Soma, Thanks for chiming in. Good point - actually not sure now why I went that route. However I do think it would be good to be able to make this code more portable so you don't have to specify the template. I actually use the above as an .inc in many templates and it works great, although obviously can be improved. Pitbull - Soma is suggesting to eliminate these lines: $filter_form_page = new Page(); $filter_form_page->template = $page->child()->template; and replace: $fields = $filter_form_page->getInputfields(); with: $fields = $templates->get("mytempl")->fields; I am not sure if that will work the same way, but maybe it will I would still like to see something though that grabs the appropriate fields based on the template of the child of the current page. At least that is what I need to make it work for my purposes since it is the child pages that contain all the content we want to filter down to. Untested, but maybe something like: $fields = $page->child()->fields; -
Filter results of selector using select/checkbox?
adrian replied to antknight's topic in General Support
I don't think it is a subdomain issue. Did you make the change I suggested in 2 above? Does this error happen when loading the page, or not until you've chosen some filter options and clicked find? -
Filter results of selector using select/checkbox?
adrian replied to antknight's topic in General Support
Hey Pitbull, Sorry it's not working for you. A couple of things I can think of: 1. Does your current page have a child? The code above relies on that to set the template and therefore generate the filter fields. 2. Perhaps try replacing: $filter_form_page = new Page(); with $filter_form_page = $page; Let me know if that helps at all. -
Blocking the regular admin pages, and using custom forms with the api and hooks is what I do. It is possible to make the forms match the fields for the page so you can re-use the same code anywhere. Again, sure you have seen it given all the reading you have done, but this is a good place to start: http://processwire.com/talk/topic/59-module-want-form-builder/page-4
-
Peter, Not sure if this really answers your question, but members do not need create/add/edit rights, or any rights that allow them to see the admin panel. You can still create custom forms that allow them to add and edit data. Even a guest user can submit a form that updates a page. Although I think you already probably know this, but just in case it helps
-
Pitbull, Sorry I don't have time for a step by step right now, but the code I posted here: http://processwire.com/talk/topic/3583-filter-results-of-selector-using-selectcheckbox/?p=35204 has been working well for me for filtering based on existing category/page fields. Might be helpful for you.
-
Not sure that you need to get that complex. I did the following. Not sure how you handle front end logins or redirects from the login page, but you get the idea. if($user->isLoggedin()){ echo $page->comments->renderForm(); } else{ echo '<hr /><br /><h3>Post Comment</h3><p>To leave a comment, you must be <a href="/login/?pid='.$page->id.'">signed in</a></p>'; }
- 7 replies
-
- 2
-
- comments by users
- permissions
-
(and 1 more)
Tagged with:
-
Error saving file coming from Pagefile (kinda urgent)
adrian replied to evanmcd's topic in API & Templates
I am confused - something that seems to be happening a lot lately , but why does a local file copy need allow_fopen_url? What am I missing? Is it something to do with the fact that you are setting the source to https://..... rather than just the full path? The original error message doesn't seem to show this though? Sorry, probably not much help - I will bow out now -
Ability to define convention for image and file upload names
adrian replied to adrian's topic in Wishlist & Roadmap
Ipa, Currently PW should not change the filename at all, except that it appends a number if you go to upload the same file again. So long as you delete the original, save the page, then upload it again, you shouldn't have any issues with filenames being changed. What changes are you seeing? -
Error saving file coming from Pagefile (kinda urgent)
adrian replied to evanmcd's topic in API & Templates
Based on the error, I don't see it making any difference at all, because it is a filesystem error, but I have always uploaded photos like so: $entry->entry_photo->add($config->paths->files . $input->post["entry_photo"]); I am sure you have entry_photo set to only support 1 image, but maybe there is something related to that, due to the way it will still be an array via the API. I might be totally off the plot here, but when you're in a hurry to get a live site working again, sometimes it is worth trying anything