• Content count

  • Joined

  • Last visited

Community Reputation

3 Neutral

About Federico

  • Rank
    Jr. Member
  1. Thank you Macrura, by inserting the php variable inside the action brackets did the trick. So here's the bottom line, for those that might experience the same issue: <form name='search' id='yourID' method='get' role='form' action="<?=$pages->get("template=YOURTEMPLATE")->url?>"> .....form values.... </form> Thank you! regards
  2. Since the search form has to bring search results in the same page, the form action is simply action="" If I insert anything else, the form will redirect to other page (es search.php) which does not serve this case. Other options have been tested but no luck..
  3. These are the passages that lead to the issue: __.com/en/works/ this is the page that host all paginated items. So you can go back and forth through pagination and everything works just fine. In this website section, which contain also the search form, I've implemented the search engine that bring search form result values in the same page. If you go to page 3 or 4 or 5 (for instance), and than you decide to filter items by picking some selects in the search form and submit them (while in page greater than 1), than search results items are retrieved keeping the current page (e.g. page 3 o 4 o 5 depending in which page I was when submitting the form), instead of returning items starting from page 1 So if you submit search form values while in page 3 (__.com/en/works/page3), you might even get results but they will be not visible as they might be not enough to reach page 3 (__.com/en/works/page3?expertise%5B%5D=value01 instead of start over __.com/en/works/?expertise%5B%5D=value01)
  4. I've get rid of the pagination function and did echo directly in template, which is actually even better in terms of simplification. echo $results->renderPager(array('arrayToCSV' => false)); However the issue is still there, if I am going to page 3 and then filter results from that page, then again I get correctly the results but they are hidden as they are not numerically enough to have at least 3 pages to show (and so the pagination disappear). The only way to make sure I see filtered results is by submitting the selection only from page 1.
  5. Thank you for sharing this, it looks interesting. Sorry for my layman point of view, but what exactly $items as argument retains? I guess the pages with specific template, isn't it? And when it comes to pass $selector as argument, which contains the submitted search form values, where should be located? Many thanks!
  6. I am basically call the pagination as a function, passing it the search form selectors as argument : function pagination($selector) { $works = wire('pages')->find($selector); if(count($works)) { echo $works->renderPager(array('arrayToCSV' => false)); } } the search form is essentially as described in a previous post: So maybe this issue is caused by the pagination function, as I am echoing it in the search form page as: <?php pagination($selector); ?> but i cannot figure it out why it doesn't restart from page 01 when user submit a search form..
  7. Thank you for the tip, I've tried the following combinations within the action="" brackets, with no luck (results from the search form should be displayed in the same page as per the form, page named "example"): "/example/" "/example" "/" "?" "/?" "?/" "" All the above options brings back either an error for the pagination module, or filtered items but not starting from page 1
  8. Hello PW community, I've a search form which return selected items with pagination. Everything works fine, also the pagination display correctly all results through pages. The issue is given only for selected results pagination as the latter does not start from page 1 but it revert back results from the current page (e.g. if you are in page 3, and submit a result from selects form, than all related items are displayed - not starting from page 1 but from page 3, which means something a fake "no results"). This is the classic function of render pager: echo $works->renderPager(array('arrayToCSV' => false)); Any idea? Thanks! Edit: I've also tried the "start=0" within the selectors, however it Always re-start from page 1 and stick to that, regardless. So no more option to move to page 2, 3, ....
  9. Thanks LostKobrakai, you pointed me in the right path by suggesting the static google map. I've achieved the above by simply doing this in the pages2pdf template: <img src="https://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=12&size=400x400&key=______"> which simply return a static image map. Useful enough!
  10. Hello PW Community, Do you know how to export current page's map as a pdf? Extended explanation: I have a template which has lots of fields, among which there is a field "geolocation" populated by the googlemapmarker module. Now, I wish to export the whole template as a pdf (with pages2pdf module), but the normal code that works on the ordinary pw's templates does not seems to work within the Pages2pdf dedicated templates. Below the code (working but not producing anything within Pages2pdf module): // alternative 01 <?php $map = $modules->get('MarkupGoogleMap'); echo $map->render($page, 'geolocation'); ?> // alternative 02 <?php $page = wire('page'); $map = $modules->get('MarkupGoogleMap'); echo $map->render($page, 'geolocation'); ?> Thanks in advance!
  11. Brilliant! I should pay you at least a couple of beers... I'll mark this thread as solved, thank you Robin for you inputs! regards
  12. As you recommended, reversing the position of the php processing code before the html form, made the trick and now the whitelist start populating - sorry to raise such silly issues... maybe you know what is the best approach on defining which input (checkbox in this case) should be marked as "checked" by matching the string value against the whitelist array. I mean, I get the "checked" feature for all the checkboxes, regardless of the options really selected. In_array works perfectly (thanks again!), I think I should first validate which option to check before outputting the $checked variable like the following. Do you have better suggestion? <form name='search' id='search-works' method='get' role='form'> <?php foreach($pages->get("/sectors/")->children() as $sec) { if(is_array($input->whitelist->cb_sectors)) { if(in_array($sec->name, $input->whitelist->cb_sectors)) { $selected = ' selected '; //$selected['selected'] = 'selected'; //Working alternative? } } echo " <p class='checkbox'> <input type='checkbox' name='cb_sectors[]' value='{$sec->name}' id='{$sec->name}' $selected/> <label for='{$sec->name}'>{$sec->title}</label> </p> "; } ?> <input class="class" type="submit" id="search-submit" name="submit" value="Search"> </form>
  13. Thank you Robin, I've made some testing and debugging (also with tracy debugger) to see what these variables keep while filtering. However everything seems working ok, except when it comes to retrieve data from the stored whitelist...well it says NULL (e.g. never an array, no data, nothing). I've only managed to retrieve the array by using $input->get instead of $input->whitelist : <?php foreach($pages->get("/sectors/")->children() as $sec) { $attrs = array(); if (is_array($input->get->cb_sectors)) { if(in_array($sec->name, $input->get->cb_sectors)) { $selected = ' selected="selected"'; } } echo "<option $selected value='{$sec->name}'>{$sec->title}</option>"; }?> which yes retrieve the array but now the issue is that I am going to select all option instead of the only active ones. Weird...
  14. I've tried many solution, none of them seem to retrieve correctly the array from the whitelist. The nearest solution to what discussed here is like the following: if(is_array($input->whitelist('cb_sectors'))) { //check if any array exists if(in_array($cb_sectors->name, $input->whitelist->cb_sectors)) { //if yes, match the value against the array echo "$cb_sectors->name is checked "; //just to display if working , but nothing outputs... } } //alternative to above if(is_array($input->whitelist->cb_sectors)) { //check if any array exists if(in_array($cb_sectors->name, $input->whitelist->cb_sectors)) { //if yes, match the value against the array echo "$cb_sectors->name is checked "; //just to display if working , but nothing outputs... } }
  15. Thank you Kongondo for your help, here the html code: <form name='search' id='search-works' method='get' role='form'> <?php foreach($pages->get("/sectors/")->children() as $sec) { if(in_array($sec->name, $input->get->cb_sectors)) { //$input->get->cb_sectors is supposed to be an array, but it outputs nothing instead... $selected = ' checked '; } echo " <p class='checkbox'> <input type='checkbox' name='cb_sectors[]' value='{$sec->name}' id='{$sec->name}' $selected/> <label for='{$sec->name}'>{$sec->title}</label> </p> "; } ?> <input class="mettiqualcosaqui" type="submit" id="search-submit" name="submit" value="Search"> </form> Here the processor code: <?php if(count($input->get)) { $selector = ''; //Selector to store selected inputs - and it should have "=" as it is the first in the list $selector .= "template=PageSingleWork, "; //Start concatenation, picking up all pages using this template if ($input->get->cb_sectors) { $se_array = array(); foreach ($input->get->cb_sectors as $se) { $sec = $sanitizer->selectorValue($se); $se_array[] = $sec; $selector .= "sectors=$sec, "; } $input->whitelist('cb_sectors', $se_array); } $works = $pages->find("$selector, limit=2"); //process the inputs to get filtered works $filtered = $pages->find($selector); //process the inputs to get filtered works $count = count($filtered); //count found works items if($count) { //found items and so display them echo "Found $count projects matching your search, using selectors ($selector)<br>"; { else { //no search results echo "Sorry, no projects were found that match, using selectors ($selector)<br>"; } } else { // do something } ?> I think the code in the frontend does not retrieve the whitelist array correctly, but all seem to be correct..