-
Posts
11,241 -
Joined
-
Last visited
-
Days Won
374
Everything posted by adrian
-
Actually I am curious about that if statement in the module to show the url with ?page=n if allowpagenum is off. What is the scenario where you would want that? Sorry if I am missing something obvious.
-
Yep, I am talking about the MarkupPagerNav module. I simplified my code down to something that still causes the issue to appear. $results = $page->children('limit=10');$out .= $results->renderPager();I have a few different sections on the site like:training >training-items teaching > teaching-items publications > publication-item These represent the parent and child pages and the template names. Some of them work without page number option being on in the child template and some don't. The code is otherwise identical from what I can see.
-
Comment from Ryan that I think is appropriate: http://processwire.com/talk/topic/1176-hiding-uneditable-pages-from-users/?p=10436
-
Fantastic enhancement Ryan. I was trying to pass some custom variables to render today and couldn't - found this post, upgraded to dev, and voila! Made things so much easier
-
Ok, I saw some other posts from you about this. Did you end up using some of the code from this post: http://processwire.com/talk/topic/126-anybody-did-user-registrationlogin/?p=4812 Depending on your needs, you could add additional fields to the user template, rather than needing a separate page. Regardless, when the form is submitted you need to check for the existence of the username. If it already exists, return the error and get them to enter a different name. If it doesn't exist, save the user and if you need, add the new page using their new username for the page name. Probably stating the obvious here though. I assume you already have the front-end user registration form working? It sounds to me like you might be better served by extending that to add the page, rather than using the FormTemplateProcessor module. Maybe if you post the code you currently have it might make it easier to add the required functionality.
-
A couple of things to consider. Take a look at the sanitizer options for page names: http://processwire.com/api/variables/sanitizer/ One concern with using the title for the page name is name uniqueness. Take a look at this thread for more details/options: http://processwire.com/talk/topic/3262-create-non-duplicate-page-name-via-api/
-
I haven't used that module, but it looks like it is focused on processing a contact form. So the name of the page is being autogenerated as a datetime stamp ($this->contact->name = date('y-m-d-H-i-s-u');) so it is unique to each user's contact submission - the title is not really relevant for this purpose as I see it. If you want to save user generated content as a page, I would recommend this as a starting point: http://processwire.com/talk/topic/59-module-want-form-builder/?p=11639 You can use the title that the user enters and use it for the page's name. Hope that helps.
-
This is my second site using pagination. The first worked without a hitch. Now, setting it up on various sections of a new site and all was seeming straight forward until I came across a couple of pages on the site (not all) that needed to have Allow Page Numbers turned on for the child template (the one the holds the items to be paginated) as well. If it's not on, then the links appear as ?page=n. These links don't work (they load the first page), and if you manually enter /page2 as the URL, it works fine. The following lines in the module are what's relevant: $allowPageNum = $this->options['page']->template->allowPageNum; /////////////////// if($allowPageNum) { if($slashUrls === 0) $url .= '/'; // enforce a trailing slash, regardless of slashUrls template setting $url .= "$pageNumUrlPrefix{$item->pageNum}" . $this->queryString; } else { $url .= $this->queryString . ($this->queryString ? "&" : "?") . "$pageNumUrlPrefix=" . $item->pageNum; } It doesn't really matter - I just allow page numbers in the child template too and everything works as expected, but curious why it is happening. Anyone have any ideas?
-
Check the pageNum of the parent page - possible?
adrian replied to doolak's topic in API & Templates
That would do it too -
Check the pageNum of the parent page - possible?
adrian replied to doolak's topic in API & Templates
Makes sense. So you need to somehow capture the page number the users comes from. Not sure how your are linking the user to watch a gallery, but you could append the page number as a GET variable to the link to the gallery so that the back to the overview link includes the page number. Does that sound ok? -
Check the pageNum of the parent page - possible?
adrian replied to doolak's topic in API & Templates
I am not sure how a parent page can have a current page number. $page->pageNum will get you the page number of the current page. Perhaps you want the number of pages that would be generated when rendering the parent of the current page? Can you explain your structure and needs in a little more detail? -
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.