• Content count

  • Joined

  • Last visited

Community Reputation

32 Excellent

1 Follower

About suntrop

  • Rank
    Sr. Member

Profile Information

  • Gender
    Not Telling
  • Location
    Germany, Cologne

Recent Profile Visitors

3,049 profile views
  1. JFYI β€” That loading screen won’t disappear on my iPad (iOS 11) Backend looks like a hell lot of work. πŸ‘
  2. Yes, I have. I would have to fork and modify Map Maker, because I need address in separate fields and with more data. And I need them to be manageable by PHP … I guess Map Maker counts on the JS API. And as wbmnfktr says, I really just need the lat/long … nothing more. I just figured out, where the conversion takes place. I put this into my wwwroot <?php include 'index.php'; // setlocale(LC_NUMERIC, 'C'); $json = json_decode( '{"test": 48.8555648}' , true); var_dump($json); die(); The code prints: array(1) { ["test"]=> float(48,8555648) } When I don't include the PW bootstrap file (index.php) it prints: array(1) { ["test"]=> float(48.8555648) } When I include the index.php and uncomment the setlocale() it prints: array(1) { ["test"]=> float(48.8555648) } I don't think it has to do with the Textareas module, but how the locale is set in PW. I couldn't find much about setlocale(LC_NUMERIC, 'C') but it seems the C sets numeric values to C++ default type (e.g. 3.14 not 3,14). It doesn't work if I put the setlocale() into my /site/config.php or /site/template/_init.php However, it looks more like a bug and not like "this is how it should work"
  3. Sure! I have something like a store locator and need to store the latitude and longitude for each place. Therefore I created a field named "latlong" This field is of type "Textareas" and has two "Text" sub-fields "lat" and "long". When I save a page the fields contents (the coordinates) are getting converted, the point turns into a comma This happens since I installed the German language pack. Prior saved locations don't have a comma saved. While the default German decimal separator is a comma, this conversion makes things very complicated. That is my hook in /site/ready.php $pages->addHookBefore('saveReady', function($event) { $page = $event->arguments[0]; if($page->template == 'location') { if ( empty($page->street) || empty($page->city) ) { return; } // Get address $address = $page->street . ', ' . $page->zip . ' ' . $page->city . ', ' . $page->country; // Get JSON results from this request $geo = file_get_contents('' . urlencode($address) . '&sensor=false'); $geo = json_decode($geo, true); if ($geo['status'] == 'OK') { $page->latlong->lat = $geo['results'][0]['geometry']['location']['lat']; $page->latlong->long = $geo['results'][0]['geometry']['location']['lng']; $this->message('Saved for: ' . $geo['results'][0]['formatted_address']); } else { $this->error('Error msg...'); } } });
  4. Does anybody know how to NOT convert these numbers ?
  5. Thanks for pointing to DC, sometimes it is ok to have it And that is some quiet simple code snippet ! Thanks again.
  6. Hi gmclelland. Thanks. Yes, that would be a way I would go. Maybe it's just me, but I would prefer not having an "invalid" URL – although if implemented as 301 it wouldn't be indexed by Google (but nonetheless doesn't count as a good link). And as I said, I really need to learn more about hooking into PW
  7. Sometimes I need pages in the site tree that are basically just a reference to another page – to redirect to the original page or display the same content under the new page url. I was surprised I couldn't find anything like that in the forum or as a module already. However, there is a new module by @Robin S but not exactly what I need. Example Home News Press Newsroom Media Services About Newsroom (virtual page for /news/newsroom/) Contact Example I: The page /about/newsroom/ should act as /news/newsroom/ – so, wehen I loop all pages for a sitemap both pages should have the URL /news/newsroom/. Example II: Another example (not often used) would be tu display the exact same content on /about/newsroom/ – although the page itself has no content on its own. Those examples don't have much in common, but they are just virtual or fake pages in the site tree. While the second one should be an easy task with wireRenderFile(), the first example isn't quite obvious to me. I think I have to use hooks and I have no idea where to start. I really appreciate you guys come up with a solution for everything, but I need to learn this myself So just some hints to start would be great! Do I put the code into a module or some of the _init.php, ready.php etc. files? Or do I have to use a template file (e.g. virtual-page.php)? When I look into Captain Hook – how do I find the appropriate point to hook into? (/wire/core/ Page.php and loaded()?) Do I need to create/manipulate each field separately (path, title, summary)? Sorry for the long read
  8. HI Robin. Thanks for checking. But I can't get this to work, double checked my wording. I am using PW 3.0.78. Perhaps we are using other "checkbox modules"? How can I tell what module this checkbox field is exactly? I am pretty sure I have not installed any module like this … but possibly I am wrong
  9. I have got a Textareas field (latlong) with two Text fields (lat and long). I query Google Maps for the coordinates and use a hook to save both fields. The problem is, after I installed the German language pack those fields are saved with a comma as decimal separator. But that doesn't work with Google Maps, because it needs 50.43578373748 and not 50,43578373748. As I remember Float can only take up to 7 points after the decimal point – so I can't just change it from Text to Float. Currently I just str_replace the decimal to a point in the template for my JSON fiel. But I was wondering if thee is a way I can tell PW to not convert the point to decimal – regardless of of the language.
  10. I thought it is possible within one selector … and I only have to rewrite my selector. My other solution looks better $page->children('highlight=1, sort=-chiffre')->add( $page->children('highlight=0, sort=-chiffre') )
  11. I know. The problem is it doesn't seem to work with checkboxes.
  12. Nobody loves my riddles It should read … "The 'checkbox' field is a default checkbox field, no special module" <?php foreach ($page->children('sort=-chiffre') as $child): ?> <div class="job <?= $child->highlight ? 'hightlight' : 'default' ?>">Chiffre <?= $child->chiffre ?> | <?= $child-title ?> – <?= $child->body ?></div> <?php endofreach ?> … will render … <div class="jobs"> <div class="job">Chiffre 734 | Job Title – Job Description …</div> <div class="job">Chiffre 732 | Job Title – Job Description …</div> <div class="job highlight">Chiffre 722 | Job Title – Job Description …</div> <div class="job">Chiffre 720 | Job Title – Job Description …</div> <div class="job">Chiffre 718 | Job Title – Job Description …</div> <div class="job highlight">Chiffre 605 | Job Title – Job Description …</div> </div> But what I need … <div class="jobs"> <div class="job highlight">Chiffre 605 | Job Title – Job Description …</div> <div class="job highlight">Chiffre 722 | Job Title – Job Description …</div> <div class="job">Chiffre 734 | Job Title – Job Description …</div> <div class="job">Chiffre 732 | Job Title – Job Description …</div> <div class="job">Chiffre 720 | Job Title – Job Description …</div> <div class="job">Chiffre 718 | Job Title – Job Description …</div> </div> … the pages with a checked "highlight" (the checkbox field) should be on top and ordered by the chiffre. The other pages should follow and ordered by chiffre too.
  13. Hi all! I want to sort child-pages by two fields but I don't know if it is possible within one selector or if I have to make two separate queries <?php foreach ($page->children('sort=checkbox, sort=-number') as $child): ?> I want to keep 'checked' pages on top and sort them and all following by the 'number' field. The 'checkbox' field is a
  14. That is great! Many thanks.
  15. I had added the title filed to the roles template. And I found I can configure the roles module to display other fields in the listing under Access > Roles – but currently I found no way to display the title instead the name on the user profile pages.