-
Posts
11,185 -
Joined
-
Last visited
-
Days Won
372
Everything posted by adrian
-
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 -
Error saving file coming from Pagefile (kinda urgent)
adrian replied to evanmcd's topic in API & Templates
Just a quick observation - there is a "//" in the from path -
Does parse_str do what you need? http://www.php.net/manual/en/function.parse-str.php
-
XML needs numeric character references, rather than named entities. I wonder if a nice addition to the RSS module might be to convert an named entities to numeric automatically. This would take care of preventing any errors when body/summary etc fields are included in the RSS output.
-
BTW hafa - please ignore my original answer - I really didn't read your question properly at all
-
Willy, thanks for the heads up about that PW function. hafa - here is the details of that function: https://github.com/ryancramerdesign/ProcessWire/blob/dev/wire/core/Functions.php I had to look it up myself
-
Take a look at PHP's strtotime() - it should handle every you need. http://us.php.net/manual/en/function.strtotime.php Let us know if you need any help making it work. EDIT: I should also add that you will probably want to make use of PHP's date() to then format the results from unix time to something human readable: http://php.net/manual/en/function.date.php
-
True - forgot about that - thanks for clarifying Soma!
-
If you do want to stay with TinyMCE there is a plugin to take care of formatting code in the editor: https://github.com/tinymce-plugins/codemagic
-
Filter results of selector using select/checkbox?
adrian replied to antknight's topic in General Support
Thanks - I should mention that this really comes in useful when you have lots of different categories assigned. You might want to change the generation of the $search_string variable depending on your needs. At the moment the different filters search such they match a resource with any of the selected options (ie OR), but between filters, the search works as AND. Hopefully that makes sense - have a play and you'll see what it does. Pretty easy to change this logic if needed. -
Filter results of selector using select/checkbox?
adrian replied to antknight's topic in General Support
This is some code I have been using to generate filter options based on the page fields in a template. I cleaned it up a little, but there is still some stuff in there that is specific to me regarding formatting/output, but might be a useful start for someone. Basically it gets all the fields in the template for the current page (except those you choose to exclude) and builds a filtering form with all of them. You will likely want to ditch the text search field. The reason I excluded body and then added it back in like this was for labeling and ordering changes, but this could be done other, less lazy, ways. This is a POST, rather than GET form. It could be adapted, but the GET that is returned by InputfieldForm is not clean. One thing you'll obviously need to change is where I have the format_results function. I am also using HTMLKickstart, so the output of the filter side div and the no results message won't look great without it. <?php $filter_formcode = ''; if($input->post->filter_save) { // Search selector builder $search_string = ''; $current_field = ''; 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 = ''; } $filter_form_page = new Page(); $filter_form_page->template = $page->child()->template; // 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'); $form = $modules->get('InputfieldForm'); $fields = $filter_form_page->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 find 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); } // render out form $filter_formcode .= $form->render(); $filter_formcode = strip_selected_tags_by_id_or_class('InputfieldPageAdd', $filter_formcode); //Strip out the option to add new item to page field (if this has been allowed through admin) 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 $out = ''; $out .= '<div class="col_8">'; $filter_results = $page->children($search_string); if(count($filter_results)==0){ $out .= '<div class="notice error"><i class="icon-remove-sign icon-large"></i> Sorry, there are no results, please change your search parameters.<a href="#close" class="icon-remove"></a></div>'; } else{ foreach($filter_results as $result){ $out .= format_results($result); } } $out .= '</div> <div class="col_4"> <h6>Find a Book</h6> <p>Leave filter options blank for all</p> ' . $filter_formcode . '</div>'; echo $out; EDIT: See this post for a cleaner version: http://processwire.com/talk/topic/3583-filter-results-of-selector-using-selectcheckbox/?p=36182 -
Awesome, I'll be using this with a couple of projects that are just winding up. I'll let you know if I come across any issues. If I find time I might try to go through and clean up that class too - there is a fair bit of unneeded code in there and lots of undefined variables. Thanks for your hard work on this.
-
On another note - just noticed that the uninstaller routine does not remove the indexer field.
-
Ok, I just tried integrating that original pdf2txt script I sent you into your module and it always returns nothing. However if I place the attached version in a web accessible location, edit the last line to point to a PDF file, it works perfectly (albeit with lots of non-fatal php errors that should be dealt with at some point). Can you try this and see if it works for you at least? pdf2txt.php