Jump to content

hellomoto

Members
  • Posts

    372
  • Joined

Everything posted by hellomoto

  1. 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?
  2. 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.
  3. 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).
  4. 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(); } }
  5. 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...
  6. ProcessAdminCustomPages works wonders.
  7. Sounds like a job for ProcessPreview?
  8. 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.
  9. 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...
  10. 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.
  11. 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.
  12. Actually I removed the field from the user template and profiles still won't save...
  13. 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
  14. Oh well here's something on searching by proximity from Google: https://developers.google.com/maps/articles/phpsqlsearch_v3
  15. 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.
  16. Yes! Just use the ID! I never would have guessed!
  17. Hey how about allowing ID as an option, in addition to title and date? To auto-generate the name only, not the title...
  18. I wish the Name Format For Children option was more fully developed. What I need at least would be so simple: to equal the page's ID.
  19. Hey! Ok so it doesn't quite work as I expected, though it does work great... but what I'm looking to do is actually use the IDs for pages of one of my templates. I have it set up to Redirect (default), Rewrite Links checked, Rewrite Format = /sales/listings/{$page->make->name}/{$page->model->name}/{$page->id}/ /sales/listings/ is the path preceding each listing anyway, which is the template I have the rewrite enabled for. So it works in my listings index on the frontend, but then those links redirect to their default URLs. I thought this might be accomplished with Load selected for Redirect Type instead of Redirect, but that gives me this error: Lines 5 and 10 are the beginning and ending of that function... So I don't know why that would be happening... Update: I changed my header to include_once the functions. This is fixed But what I really want is to redirect the default URL for each listing to the one I design. Like from the backend, the links still go to /sales/listings/{$page->name}/ when I want them to be what I set too, or at least redirect to what I set. I want the URL I set to be the absolute one. Anyone know how? Thanks.
  20. and it works great!
  21. @lsag: I had the same issue trying to install via classname just now, on v2.5, but it installs fine if you just download from the module page and manually upload to your PW.
  22. Ah, sorry. Re-reading my own post I was almost confused again... A listing (single) may not have children. The "New" link shows up beside the parent, for a "new" child; while the "edit" link shows up beside the actual pages. So the ones I can edit are the individual listings; but the "new" listing link shows up in its parent, which is plural Listings... so I guess since this user doesn't have permission to edit the listings (plural) template (listing's parent), the "new" listing (single) link isn't showing up beside it.(?) I'm sorry if that's confusing. Maybe someone knows what I'm talking about... or tomorrow I'll post a screenshot... like today...
  23. Hi, I have listings (listing template) that I am now adding a field to called Listing Broker. I made a role, listing_broker, and set the field to page field type, select input type, from users parent, user template, with roles=listing_broker. So the test_broker user appears just fine. But when I try to save, I get this: Page 1100 is the user test_broker. Can we not relate page fields to users? There must be a way. I just thought it was that easy. Apparently not quite?
×
×
  • Create New...