Jump to content

adrian

PW-Moderators
  • Posts

    11,179
  • Joined

  • Last visited

  • Days Won

    371

Everything posted by adrian

  1. Right - just thought it might help - wasn't sure how far along you were. You might likely have already thought of this, but you could serialize or json_encode the array of users who have already visited the page and store that in a text field which you can do your check against. The array could contain the ID for each user who has visited the page. Within that you'd need to store the number of visits as well as the last datetime they visited. Then, if I understand correctly, each time the user visits, you can check if the user has visited once already and if they have and the date of that visit was before the modified date of the page, then increase counter, if not then load the required page. Or something like that anyway. Obviously you'd need to unserialize etc the array and search through it each time the page is loaded. After all that, I feel like a better solution might be a separate db table which adds a row every time the page is visited. The fields would be page_id, user_id, and datetime. Then you could easily query this to count the number of visits for that user_id and whether they were before the page modified date or not. I am sure you could do this through the PW API if you wanted to. You could set up a parent page called page-visits and add a new child page for every visit. Alternatively, it might be simpler to do it with SQL. Perhaps a PW guru could suggest which would be better, or more than likely, they'll come up with a much simpler solution altogether
  2. Hey Soma, Thanks - I understand that it is working in a normal use with both pages on the same domain. And I realize that different domains are the issue, and I am happy with the manual SQL fix. What I can't figure out is why the isLoggedin() check shows that the correct user is logged in. It doesn't really matter in the end, but it does seem weird.
  3. Hey Soma, Thanks for the suggestions. As I mentioned above, I have already taken care of things with SQL - does exactly what I need it to do. I just don't understand why the $page-save() isn't taking care of it. I initially assumed it was losing the logged in user too, but as I said, when I do the following just before the $page->save(): if($user->isLoggedin()){ print 'uid: ' . $user->id; } it prints the correct id for the user that is logged in. I think if no-one else is having this problem, then we shouldn't worry about it for now.
  4. LeiHa, Not sure if you have seen them, but these posts might be useful for you: http://processwire.com/talk/topic/2868-count-views-of-post/ http://processwire.com/talk/topic/1618-page-view-counter-and-cache/
  5. Just to follow up - I couldn't figure how to solve this via the API - every time I saved the page it kept setting the user's ID to 40, so I ended up resorting to an SQL UPDATE SET after the last save to override things, which is working fine.
  6. Hey guys - created_users_id and modified_users_id are both set to 40 (Guest ID). The API calls add the page and populate various fields, save it, then add an image and save again. I am guessing that is why modified_users_id is set, or maybe it actually gets set anyway on new page creation - I haven't checked. Maybe I should better explain what is happening. I have a full PW site where a front-end user logs in. The PW site redirects to a URL on another domain (but same server) which includes PW via include("/path/to/pw/index.php"); This external site creates the PW page. I just tried this from the external site to be sure of user logged in status: if($user->isLoggedin()){ print 'uid: ' . $user->id; } and it correctly returns the logged in user's id. Got me baffled. It seems like it should be populating these fields automatically, but even if it doesn't, I can't figure out why I can't do it manually. Thanks again.
  7. Ok, having a weird issue. I am including ProcessWire from another PHP script. From this script I am saving a new PW page. Everything works except that the page is saved with created_users_id and modified_users_id as guest, rather than the logged in user. I have tried manually adding changing these fields with several variations including these, but they still contain the guest id: $page->set('created_users_id', $user_id); $page->created_users_id = $user_id; This works fine: $user_id = (int)$_GET['user_id']; $user = wire('users')->get($user_id); print $user->name so I know that $user_id is correct. Should I have to manually set the created and modified user id's in this situation? Even if I shouldn't have to, I still don't understand why I can't! Thanks for any suggestions.
  8. Regarding the image resizing - it looks like CK does support it (works fine in FF), but webkit has a bug that prevents it working. TinyMCE has implemented a workaround for webkit. Here are some relevant discussions: http://dev.ckeditor.com/ticket/6668 http://drupal.org/node/1459176 http://www.tinymce.com/forum/viewtopic.php?id=29222
  9. I can't reproduce the undo problem now either - sorry. I know it happened several times in a row the other day though
  10. Hey diogo - cool idea and a great example of how easy it is to create a module. Looking forward to finding a little time to start creating my own soon. Thanks again.
  11. Hey Pete, Thanks for the module. Just wanted to let you know of a couple of small issues. I get this error: Notice: Undefined index: allowedPagePhotoParents in xxx/site/modules/SocialTwitterUpdate/SocialTwitterUpdate.module on line 113 Also, the page parents selectors are described as "A comma-separate list" which is not really the case for the user with your ASM implementation.
  12. Hey Ryan, Just started playing with this - looks very cool. Just a couple of things I noticed. CTRL/ALT+Z seems unreliable for undo. Edit > Undo from the browser menu seems ok still. This doesn't seem to be an issue with TinyMCE. Also, I don't seem to have a problem when using the demo on the CkEditor site, so not sure what the issue is. The other thing I noticed in the lack of ability to resize an image with the mouse. Seems like this option is not available (at least by default) with CKEditor, which is probably smart given that HTML resizing is a bad idea, but with PW's ability to actually resize the image on the server when resizing in the editor, it seems a shame that CK doesn't have this - can it be enabled?
  13. Ok, not really sure what to suggest now - might need someone morre experienced with PW to step in, but when you say you can save the page so long as you don't make any changes, are you sure the page is saving? Is the modified field being updated? Can you make any other changes to the page, like change the body or other simple field?
  14. Are you really wanting to do this: $page->htl_idiomas = $pages->get((int)$idioma_id); Don't you want to set htl_idiomas to the value of the checkbox from the post? This is something you might find quite helpful: http://processwire.com/talk/topic/59-module-want-form-builder/?p=11639 It shows you how to automatically generate a front-end form from an existing page's fields. This will probably take care of everything for you.
  15. I don't think "time_field" is valid. Does the following work as is? ie, does it change remove the unpublished status? $my_page = $pages->get($my_page_id); $my_page->setOutputFormatting(false); $my_page->removeStatus(Page::statusUnpublished); $my_page->save(); What does: echo $my_page->id return? Are you sure that $my_page_id is set correctly?
  16. Thanks Ryan, I have been trying to avoid using SQL directly in PW - just figured there was something in the API I was missing, but it seems that in some cases it will be more efficient.
  17. I haven't looked thoroughly through your code, but the one thing that stands out is that you are checking for posting of btn_submit and yet your submit button is not named as such. Try this: <input type="submit" value="submit" name="btn_submit" /> That should at least get your processing section to do its thing.
  18. Well it is all about variable scope. None of the PW variables (http://processwire.com/api/variables/) are available inside a php function. So you can use the wire function for any of those PW variables inside a function. If you're going to be using a variable more than once inside the function, it can be worth doing this at the top of the function: $input = wire('input'); and for any other PW variables you might need access to.
  19. Hey Alan, I think it is just that you need to use wire('input')-> when inside a function.
  20. Thank you both for those ideas - I didn't really know about the PageFinder class, but just did some more reading about it here (http://processwire.com/talk/topic/1227-lazy-loading-of-pages/?p=10907). Seems like that could come in handy for sure. I might also just start using SQL in cases like this.
  21. Thanks - I guess it's not a big deal to do it that way. I think I am just so used to using SQL to do most of the work first that the idea of returning so many results just to later throw them out seems weird
  22. Is this possible? I am trying to combine results of more than one $pages->find. I know I could append the results of one to the pagearray of the other, but I want to be able to apply a limit to the combined results of both, sorted by modified, before returning the results. Thanks
  23. Thanks diogo - a nice solution - I hadn't thought about the remove option. Only catch is that my find makes use of a limit selector. Obviously I can break the foreach loop after my limit requirement, but it will mean grabbing all the pages that match and then not using most of them in the foreach - just seems wasteful.
  24. Hi everyone, Trying to simply find pages where the modified date is greater than the created date. I would think this should work: $pages->find("modified>created"); but no luck. Thanks for any suggestions.
  25. Hi Soma - no worries - I know how you feel Basically what I am doing is creating a custom RSS feed and latest activity widget, but I only want to highlight details from certain sections of the site. I have some user edited pages, a user edited glossary, and a forum. These are the three parent pages. I ended up going with this which is a little ugly, but does the trick: $latest = $pages->find("sort=-modified, limit=30"); $items = new PageArray; foreach($latest as $lpage){ if(($lpage->rootParent=='1130' || $lpage->rootParent=='1192' || $lpage->rootParent=='1021') && ($lpage!='1130' && $lpage!='1192' && $lpage!='1021')){ $items->add($lpage); } } I actually might end up switching to a template selector as I think this will be cleaner and still achieve what I need.
×
×
  • Create New...