-
Posts
10,898 -
Joined
-
Last visited
-
Days Won
348
Everything posted by adrian
-
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
-
Just installed the module for the first time and received this error: Notice: Undefined index: maxlength in /xxx/site/modules/Indexer/Indexer.module on line 185
-
That is weird. I looked back at my php source downloads and I was running 5.3.3 at some point back in 2010 and that script was still working then. It is strange that none of those options are working. Let me know if there is any testing I can do at my end for you that might help. When I get a minute or two I might try implementing that class into your module and see how it works for me.
-
I haven't used this, but I went looking for other options and found this: http://pastebin.com/hRviHKp1 Might be worth trying.
-
I just installed this module and got exactly the same errors.
-
Hi Pete, I think PW needs a good forum integration option. My concern with Invision is that it's not free / open source. Ideally I would love to see an integrated PW solution, although it sounds like you have done considerable integration of Invision into PW, so maybe it would be ok. I have made use of apeisa's basic discussions module. This works well, but in some cases there is a need for something more feature rich, so I am definitely interested in other options. I don't like reinventing the wheel, but a PW specific forum would be cool - might be a good community-wide collaborative project to initiate?
-
Sorry you had no luck with that class. It has been working well for me - several hundred PDFs with no failures so far. I have attached one that definitely works so maybe you can figure out what the issue might be. EDIT: Notice that in the main function I changed it so it always uses the handleV2 function. The V3 one wasn't working for me, but you might want to look into that some more. ian_newsletter_405 (2).pdf
-
Looks good to me. The only feedback I have is that you could ditch the first line and replace $section in the second line with $page.
-
Looking forward to checking this out - thanks! I have been using the attached set of functions for a long time to extract text from PDFs. Probably not as powerful as poppler, but might do what you need. I made some poorly documented changes to the original. Anyway, maybe you'll find something useful in there. pdf2txt.php
-
Ability to sort and search through users in admin
adrian replied to adrian's topic in Wishlist & Roadmap
Thanks diogo - I hadn't actually used the admin search function before. Works a treat, although I still like the idea of column sorting spanning all users, rather than just those on the current page. -
One of my PW site has a LOT of users and I am finding myself wanting a way to find a user in the admin user interface. Search would be nice, but at a minimum, it would be good if the column sort functionality worked across all pages, not just the currently displayed one. I don't think this is currently possible, is it? Not sure if this should be a module or a core enhancement. Thanks, Adrian
-
Due to scope, you need to use wire('config') inside a function. Same is true for all the PW variables: http://processwire.com/api/variables/ If you'll be using it a lot in the function, you can do $config = wire('config') and then use $config as normal after that.
-
As an alternative, have you tried Ryan's Youtube/Vimeo module: http://modules.processwire.com/modules/textformatter-video-embed/
-
Automatic update of alt tag for image embedded in RTE
adrian replied to adrian's topic in Wishlist & Roadmap
All good points Teppo. I knew I shouldn't have posted late at night I am using the description field to automatically generate captions. Title is obviously a much more appropriate option for this, but either way it would be nice to have a simpler way to do this. But you are right - not appropriate for storing with the image itself due to the possibility of using the image in multiple places/contexts. -
I think it would be useful if changes to an image's description field automatically propagated to the alt tag when embedded in an RTE textarea. At the moment you need to select the image, click the select image button and then "insert this image". This will force the ALT tag to update, but I think it would be good if this step wasn't necessary. I don't think there are any negatives to this, but maybe I haven't thought it through. Also (and I think this has been brought up before), I think we need a title field for images. Thanks
-
Ok, I have ChromePhpLogger installed. Catch is that nothing gets logged because nothing is sent to the browser when I am logged in. When logged out, or that section of code is commented out, it works fine. The one error I do get (in Firebug) is: status: aborted
-
No, I have used FirePHP in the past, but since switching to Chrome I haven't got ramped up on that front yet. Doing a million different things at the moment, but will get it installed and see if I can figure it out.
-
This is actually more complicated than I thought. Turns out all that clearing "Delete cookies and other site and plug-in data" did was log me out. The page works fine when logged out, but produces the error when logged in. Something as simple as: $markers = $pages->get("/schools/")->children(); foreach($markers as $item) { error_log($item->sister_school->id); generates the error. sister_school is a page field (single) select. The error log receives a list of all the sister_school ids. There are no php errors generated. Currently baffled - will let you all know if I figure it out!
-
Select field values not getting edited in front-end form
adrian replied to onjegolders's topic in General Support
I don't think that should be a problem. I think you should just have to edit: foreach($mypage->fields as $f) { $mypage->set($f->name, $form->get($f->name)->value); } to iterate through the fields from the $input->post, assuming the fields already exist in the backend. Even if they don't you could easily add them through a foreach that uses the posted form data. Might be a little fiddly, but not too difficult.- 24 replies
-
- api
- front-end form
-
(and 1 more)
Tagged with:
-
Select field values not getting edited in front-end form
adrian replied to onjegolders's topic in General Support
Not sure if you want to go with diogo's option in that thread I linked to, but I just remembered - be sure to check out the last comment in that thread by me, because there is one change that should be made (fix a non-fatal error), and one key one (saving the page) that has to be made I have found his approach really great for front-end forms - if you're still having troubles, I'd definitely revisit it as an option!- 24 replies
-
- api
- front-end form
-
(and 1 more)
Tagged with: