-
Posts
108 -
Joined
-
Last visited
-
Days Won
3
Everything posted by Alexander
-
Dear all, I have 205 pages with repeaters. Each repeater has 21 lines with two fields: date field and checkbox. I use this function to find free chalets for selected days and it's take around 10 seconds. Any suggestion of possible speedup this? Maybe PageTable is faster in this case? function find($selector) { if (wire('sanitizer')->name(wire('input')->get->dates)) { $dates = wire('sanitizer')->name(wire('input')->get->dates); $dates = strtotime($dates); $todate = strtotime("+1 day", $dates); $selector .= "template=chalet"; $chalets = wire('pages')->find($selector); foreach ($chalets as $chalet) { foreach ($chalet->clndr->find('arrival=' . $dates . '|' . $todate . ', booked=0') as $r) { ... } } }
-
Brilliant! It's 100% works! Now I can sleep well. Kongondo, thank you very much for your help!
-
Kongondo, yes and no. I know, that is not elegant way, but I try to find page parent that have the same name with user to provide access. $p->set('id', 15729) = working $p->set('id', $p_page) = no $p_user = $user->name; // set user name $p_page = $pages->find("title=$user->name"); // try to find page with the same with user name $p = $this->modules->get('ProcessPageList'); // kongondo's code goes here $p->set('id', $p_page); // setting the parent page to user name page May be you know the reason?
-
Thank you, Kongondo, you made me happy.
-
Good day everybody, I'm trying to make Custom Page with one of Pages Tree. I took this code https://processwire.com/talk/topic/6315-processpagelist-to-hide-some-pages/?hl=backend for custom page template: <?php $form = $this->modules->get('InputfieldForm'); // prep the form $wrapper = new InputfieldWrapper; // a wrapper $wrapper->attr('value', 'List of available articles'); $p = $this->modules->get('ProcessPageList'); // kongondo's code goes here $p->set('id', 4049); // setting the parent page $pageTree = new InputfieldMarkup; // the placeholder $pageTree->value = $p->execute(); // fill the InputfieldMarkup form field... $wrapper->add($pageTree); // put inside the wrapper... $form->append($wrapper); // append the wrapper ?> No success. The main idea is to give to each user separate space for editing only his pages and prevent access to system pages and pages of other users. What did I miss? Thanks for any hints.
-
ProcessWire conference, Switzerland (central europe)
Alexander replied to Soma's topic in News & Announcements
Hdesigns, I live in Chamonix and always ready for action! -
ProcessWire conference, Switzerland (central europe)
Alexander replied to Soma's topic in News & Announcements
Maybe in this year? -
I get one word — Φιλοξενία it's look similar with russian Философия (philosophy). Site looks great, but maybe more organic to put menu from right to left side, because greek people (I think) reading from left to right and most useful part of content must be on the left side. Good luck.
-
Ryan, thanks for your assistant, but it was my fault. I using date field without strtotime. But, I have some really strange bug. I use "limit" in selector and it works not very well. For example, if I use limit=1 or 2 or 3, I get the same numbers of result. But, if limit=4 or 5, result = 3 item. If limit=6,7,8,9 result = 4 item. Any idea why this happens? For sure, this bug happens only for dates. $result = wire('pages')->find($selector); return normal results with right limits. Here is my code: $selector = "template=chalet, limit=10"; $result = wire('pages')->find($selector); if (wire('sanitizer')->name(wire('input')->get->dates)) { $dates = wire('sanitizer')->name(wire('input')->get->dates); $dates = strtotime($dates); foreach ($result as $res) { foreach ($res->clndr->find('arrival=' . $dates . ', book=0') as $r) { $i++; if($i==1) {$result=$result->makeNew();} $r = $r->GetForPage(); $result->add($r); } } } return $result; For example: foreach ($res->clndr->find('arrival=' . $dates . ', book=0') as $r) if limit=8, $r= 7416,7889,7893,7898, (4 results) if limit=10, $r= 7416,7889,7893,7898,7903, (5 results) if limit=100, $r= 7416,7889,7893,7898,7903,7394,7402,7398,7817, (all 9 results) Sorry for this dummy question. Maybe someone can help, what to do with foreach ($res->clndr->find('arrival=' . $dates . ', book=0') as $r) pagination?
-
Now I see my fail. With strtotime works correct.
-
Dear Soma, million thanks for your help. Your words and logic as always direct to the correct result. For sure, your code is absolutely right and I try to use this code before, but with zero result. $p->calendar->find("booked=0, checkin_1=16.11.2013")All problem were with date field. In some reason (maybe output data format or something) selector don't find correct result for this date field. I try to use different date in selector, like d.m.y, y.m.d & etc but nothing works.So, I just change data field to usual text field. Now works absolutely fine.
-
This is all picture. pa=5773|5789 — Find result for 16.11. p=5773 — First property r=5975 — checkin 17.11, booked 0 r=5976 —checkin 18.11, booked 0 r=6816 — checkin 19.11, booked 0 p=5789 — Second property r=5919 — checkin 16.11, booked 0 The problem is, that I need to remove not correct dates from results.
-
As find result $pa=5773|5789 and this is correct. But $p->calendar->find('booked=0') return r=5773 r=5773 r=5773 r=5789, that is $r — all entry of booked=0 in repeater, and I need only for select date. Sorry for difficult explain.
-
Nik, thanks for your clarification. I feel that two deferent templates in one selector is not good idea. I tried another way, but it also return not correct result (without "booked" checking). $pa = $pages->find("template=property, calendar.checkin_1=16.11.2013, fireplace=1"); foreach ($pa as $p) { foreach($p->calendar->find('booked=0') as $r) { $r = $r->getForPage(); $content .= renderItem($r); } } Using the occasion, I want to thank you for great "selector test" module. It's really helpful.
-
$pa = $pages->find("template=property, calendar.checkin_1=16.11.2013, fireplace=1"); foreach ($pa as $p) { foreach($p->calendar->find('booked=0') as $r) { $r = $r->getForPage(); $content .= renderItem($r); } } Hi, I try to use this code to find free week for bookings. (calendar is repeater with dates and checkbox "booked") 1) Find all property with 16.11.2013 in calendar (by repeater). 2) Check that this week is free (checkbox "booked" = 0). But in some reason, I just get property for this dates and checkbox don't work. What I'm doing wrong?
-
$selector = 'template=chalet, fireplace=1'; $allresults = wire('pages')->find($selector); $availability = $allresults->find("template=repeater_calendar, checkin=17.11.2013, booked=0, include=all"); foreach($availability as $item) { $availability = $item->getForPage(); $content .= renderItem($availability); } Hello! I try to find some repeater from another selector, but nothing happens. Find for repeater works fine, but not for $allresults (only for $pages). Can you tell what I'm doing wrong?
-
Thanks a lot, Kongondo. That seems to be right. I'll think twice how to manage it in a deferent way. For example, if I upload "Martin_Johnson_House,_SIO,_La_Jolla_Shores_-_at_sunset_pano.jpg" I get "Martin_Johnson_House,_SIO,_La_Jolla_Shores_-_at_sunset_pano.640x480.jpg" and I would like to get "rndmname.640x480.jpg"
-
Hello, I'm trying to change all upload image files names for the random names. So I put in Pageimage.php this lines: $rand = substr(md5(microtime()),rand(0,26),5); $basename = basename($rand, "." . $this->ext()); // i.e. myfile But as a results I got a lot of random filenames during each page loading. Please advise what do I miss? Thanks, AP
-
Trouble with install (Rackspace Cloudsites)
Alexander replied to adamspruijt's topic in General Support
Great thanks, Craig! -
I use it. Maybe I use it in wrong way.
-
Thanks, Teppo. I trying all variants with ->name,->title but nothing works in my case. And what the difference between only one selection and multiple pages? Where I can check this option?
-
Hi again, I have another dummy question about Select field use. I made the field "boardbasis" with select options: 1:=Breakfast 2:=Catered 3:=Self-catered In template I use $page->boardbasis to extract result from "boardbasis" Select field. As a result I get on page "1 or 2 or 3" (just pointed numbers). What should I do achieve as a result "Breakfast or Catered"? Thanks a lot for your assistant. Have a great weekend, a.
-
Great, works perfect! Thanks Ryan! Better with title name. if($prev) echo "<a href='$prev->url'>$prev->title</a> "; if($next) echo "<a href='$next->url'>$next->title</a> ";
-
Luis, maybe I'm wrong, but this solution does not support sorting of search result. Anyway, thanks!
-
Thanks Mats and Luis for your help and time. I trying to use $page->next, but in my case it returns only numbers. I findet in blog demo this code and it's work perfect. function renderNextPrevPosts($page) { $bedroom = $page->getUnformatted('bedroom'); $nextPost = $page->parent->child("bedroom>$bedroom, sort=bedroom"); $prevPost = $page->parent->child("bedroom<$bedroom, sort=-bedroom"); $out = "<div class='next-prev-posts'>"; if($prevPost->id > 0) $out .= "<p class='prev-post'><span><</span> <a href='{$prevPost->url}'>{$prevPost->title}</a></p>"; if($nextPost->id > 0) $out .= "<p class='next-post'><a href='{$nextPost->url}'>{$nextPost->title}</a> <span>></span></p>"; $out .= "</div>"; return $out; }