Jump to content

hellomoto

Members
  • Posts

    355
  • Joined

Everything posted by hellomoto

  1. I have a model field that depends on the selected manufacturer. Its options update upon manufacturer selection (both are page select fields). In my model field > Input tab > Selectable Pages > Custom selector, I have: parent=page.make, template=model, sort=title, include=all Where 'make' is the name of my manufacturer field. Try that?
  2. This works for me to support page references in Ryan's ImportPagesCSV.module, in function importPageValue: elseif($field->type instanceof FieldtypePage) { $value = trim($value); if(wire("pages")->find("$name=$value")) $page->set($name, $value); } I need to also be able to import repeater fields though.. Anyone know how to do that?
  3. Hi, I want to write up a module that upon installation generates my site fields, templates, and roles... What hook do I use? This is a better approach than simply exporting a Site Profile, no? Thanks...
  4. Thanks, apeisa. ->title is what I tried first... but, I never tried ->first()! Of course! That's what it was all along. That I should have known... at least... Thanks a mil!
  5. It's the pages themselves or the field. I changed their titles to their names and still can't get them. Couldn't get the names anyway.
  6. Yeah that's what I was going to do. I will. But why is that happening? I just tested another template type I have, renamed the title to '$' (sans quotes) and it appeared on the frontend...
  7. I have a price_currency field that references child pages of a page Currency. Its names are three-letter currency codes, and the titles are symbols: $, euro and pound. I tried inputting both $ and $ as the title instead for $ to see if it would echo; it's not. How can I get these values to appear? $item->price_currency outputs the ID, but $item->price_currency->name doesn't even work either...
  8. Had to tack ->save() on to the statement setting the field...
  9. public function init() { // add a hook after each page is saved $this->pages->addHookAfter('saved', $this, 'populateDefaults'); } /** * Populates model defaults after save for corresponding blank fields. * */ public function populateDefaults($event) { $page = $event->arguments('page'); if($page->template != 'vessel') return; //$this->message("hi {$page->model->hulls}"); if($page->model && !$page->hulls && $page->model->hulls) { $page->set("hulls", $page->model->hulls); $this->message("hi $page->hulls {$page->model->hulls}"); } } This sort of works; the message echoed is "hi 1082 1082". When I set the hulls to null in the above code, it then goes back to "hi 1082". However, it doesn't update the select input in the edit screen, and the "Missing required value" error for that field remains... Also the message shouldn't even be showing if $page->hulls is set... How can I get it to update the field value and the input?
  10. I have a page field 'make', which consists of manufacturer template pages. A new page can be created from that field, but I currently have that functionality disabled, since following that field is another page field 'model' with a custom selector, 'parent=page.make, template=model'. So since the model field parent is dynamic, new pages cannot be created from the field, as the first requirement for that feature is that a single parent and template be pre-selected... Is there some way I can hook into the options there and add an 'Add New' option at the bottom, opening up the new model in a modal? Thanks.
  11. How can I access the input variable from within this function? I want to add URL segments to the records. I tried adding: // record if segment $event->return = str_replace("</body>", "<p>Hello {$this->input->urlSegment1} World!</p></body>", $event->return); } also tried $page->input->urlSegment1 and $input->urlSegment1. Update: never mind, just had to make it $this->input->urlSegment(1) (in parentheses).
  12. I want to make a little module that tracks pageviews. This is my first module. I'm starting with a copy of helloworld.module. I already created the template pageviews and pageview manually, but I'll add their creation into the module later. Here's what I have: public function viewTracker($event) { $page = $event->object; // don't add this to the admin pages if($page->template == 'admin') return; if($page->template == 'vessel') { $r = new Page(); $r->template = 'pageview'; $r->parent = wire('pages')->get('/viewtracker/'); $r->user = $user->name; $r->vessel_id = $page->id; $r->name = $user->id . $page->id . date('YmdHisu'); //$r->status = $r->status | Page::statusLocked; $r->save(); } // add a "Hello World" paragraph right before the closing body tag $event->return = str_replace("</body>", "<p>Hello $user World!</p></body>", $event->return); } but the $user variable isn't coming through. How can I access the logged in $user? Edit: Got it. Replaced the $user with $this->user..... public function viewTracker($event) { $page = $event->object; // don't add this to the admin pages if($page->template == 'admin') return; if($page->template == 'vessel') { $r = new Page(); $r->template = 'pageview'; $r->parent = wire('pages')->get('/viewtracker/'); $r->user = $this->user; $r->vessel_id = $page; $r->name = $this->user . $page . date('YmdHisu'); $r->status = $r->status | Page::statusHidden; $r->save(); } }
  13. I just installed a fresh copy of PW 2.5.3 and the admin looks different now than it did even when I installed it. The font is slightly larger, and there is a new link alongside every page in the Page List, together with the "edit", "view", "new", and "move": "edit template"? Also the additional info in the Page List is formatted funky: , [model.title: L380 | model_year: 2006 | listing_status.title: For Sale] Anyone know why this might be...
  14. ProcessAdminCustomPages works wonders.
  15. I can't get this to work for the life of me. I've tried literally everything, everyone's snippets. I'm on localhost, PW 2.5.3. The closest I managed to get is a shot of the whole world, or a relative close-up of the correct location, without the ability to drag and see anything around it, and sans marker.
  16. So I added the office field back to the user template, since that's not the culprit. However I can't even edit that from the user edit screen, don't know why. I can edit the phone number and full name fields I added. Not this page field though. Doesn't show. Shows in my own uneditable profile edit screen (changed the selector to !=37 which is guest so the field is visible for all internal users) (also shows in the broker's uneditable profile edit screen; I have them both up side by side). I need to be able to edit profiles via profile screen and also need to be able to edit users' "office" value as superadmin or user admin...
  17. Actually I don't know if it was working then, when I added the phone field; I added that value to another user's profile from the admin by editing the other user. However as superadmin I can't even save my own damn profile, without editing myself (/access/users/edit/?id=xx works, /profile/ does not). I have no idea where or when this happened or why. No errors are logged. Profiles just won't save. That's it. No rhyme or reason. There's no reason they shouldn't be saving.
  18. Yeah. It was working the last field I added too (phone, had a number saved). It won't save any profile for any user with any role. What the hell did I do... I've only been messing with the frontend... And like I said, without the asterisk the field wouldn't show, period. But now I have even bigger problems.
  19. Actually I removed the field from the user template and profiles still won't save...
  20. I have a page field "office" that should appear only on users with the role "broker". So, I put under Visibility for the field, Show this field only if roles*=1075. It doesn't show without the asterisk. But when I try to update a user with an office selected, I get error message up top: "Profile not saved". Anyone know why? Update: See replies #5 and 6
  21. Oh well here's something on searching by proximity from Google: https://developers.google.com/maps/articles/phpsqlsearch_v3
  22. I don't understand why my MarkupGoogleMap won't work... I tried following the Skyscrapers example first, with RCDMap.js etc., that didn't work; so now I'm trying this MarkupGoogleMap and I get a blank map with just a gray background. In my head element, I have: <script src="//code.jquery.com/jquery-1.11.2.min.js"></script> <script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script> and this snippet in my listing page template: $map = $modules->get('MarkupGoogleMap'); echo $map->render($page, 'map_location'); and I just get a blank map canvas. No errors in JS console. Anyone know how I might get this to work? Thanks... Although, I've been skimming through this thread, and I'm very interested possibly trying to implement something like what Bwakad did, with Geocomplete... mentioned here. There's the first benefit of having the input validation taken care of, and then also what I'd like to do, I don't know if it can be done using this but I would like ultimately for the listings to be searchable, by proximity... not just location. Like for the visitor to be able to choose "10" or "50 miles from {$location}". Anyone know how this might be achieved? But for now just the maps would be nice.
×
×
  • Create New...