Jump to content

adrian

PW-Moderators
  • Posts

    10,877
  • Joined

  • Last visited

  • Days Won

    348

Everything posted by adrian

  1. Hi guys, I want a simple selector to test if a checkbox field is empty. hide_from_top_menu=1 works as expected and finds those that are checked, but hide_from_top_menu!=1 does not work - it returns nothing. Now I understand that there is no entry in the hide_from_top_menu field for a page until the checkbox is checked and I guess that is the problem. I am using this with MarkupSimpleNavigation. Obviously I can easily hack the code of the module to add in a check something like this: if($child->hide_from_top_menu != '1'){ but I feel like I should be able to achieve this more cleanly. Obviously I could also turn this field around to be "show_in_top_menu", but since there is no way to set default values for fields, I'd rather avoid having users have to check this for each new added page. Maybe not a big deal, but thought this might be an issue at a more general level Thanks!
  2. Just wanted to say thinks for this - another nice little time saver and works great direct from templates - check if a field already has content and if it's empty use the lorem text instead of the field. Just one thing - the classname is incorrect in the modules directory: MarkupLorenIpsum That probably explains why I get this error when trying to install from the modules manager: TemplateFile: Could not open zip file Manual installation worked great
  3. Soma - sorry, been absolutely swamped. I reinstalled with the ModulesManager. Weird thing is that this is the second time it has happened, on the same server. It is the only module that has caused me any installation problems. Next time I go to install it I'll be sure to do some debugging. The server is one I manage myself and I think it is configured ok
  4. Not sure whether it is something related to my system, but the last two sites I have tried to install this on (using the modules manager), it has failed and prevented the site from loading at all. All I have to do to fix it is delete the module folder from the server, reload the PW admin and then install it again and everything is fine. Sorry I don't have any useful debugging info, but if someone else has this problem as well, it might be worth investigating.
  5. Thanks Joss, What I have actually ended up doing is using the example.html file from KS as a starting point and using that as my main.inc and everything is working beautifully I guess Ryan's example was before some significant KS changes.
  6. Has anyone used Ryan's converted example.html (http://processwire.com/talk/topic/2731-how-can-i-integrate-html-kickstarter-with-processwire/?p=26612)? I thought I'd give kickstart a go for a new project, but none of the new responsive goodness works properly. I'll have a play and sort it out, but thought if someone else might have already sorted this out
  7. Good reminder, thanks! I am so used to sanitizing in pure PHP, but sometimes I forget with PW - I tend to assume it takes care of absolutely everything for you And yes, also good to use "get" so it's not emulating "request"
  8. Beautiful diogo - I should have delved into the structure of the tags field to figure that out. Thanks! Also Macrura73, thanks for making the point about sorting the array at the end! On a more general level though I assume there is no way to use separate operators on different fields within a selector? I guess this is where you have to follow the approach of combining the results of two queries?
  9. Thanks, that does the job just fine! I would like to know if there is an option for doing it in one find statement though, just for simplicity's sake, although perhaps it really isn't that important in the end!
  10. Hi everyone, Hopefully a quick question. I am trying to search through all pages by a keyword that is in any of the following fields: title, summary, tags The first two on their own are easy, as is the last on its own, but I am having a problem combining things to search through all fields because of the nature of the tags field I can't figure out quite how. $images = $pages->get("/visuals/")->find("summary|title~={$input->q}, tags={$input->q}, sort=title"); That code forces the keyword to be in both summary|title and tags. Thanks for any ideas!
  11. n0sleeves, The reason the link from the logo always goes to the current page is because the href is blank. Have a look at the HTML source of rendered pages. This is what appears in your source code. <a href=""><div id="logo" class="center"><img src="/site/assets/images/logo2.png"></div></a> So firstly you have the href inside the div tags - this is not valid HTML as it is. Something like this should do what you want. <div id="logo" class="center"><a href="<?php echo $config->urls->root; ?>"><img src="/site/assets/images/logo2.png"></a></div> Or you could quite easily just go with: <div id="logo" class="center"><a href="/"><img src="/site/assets/images/logo2.png"></a></div> since it is to the root. Using $config->urls->root is useful as a starting point to build onto when making a URL to a lower level, but for root I think it is probably superfluous. Hope that helps.
  12. Hi Peter - a quick answer from a relative PW newbie - I would go with the github version to ensure you get 2.3. I am using it in production, as I think are many folks. It has lots of great new features. Agreed it does seem a little confusing as to which is the current stable version.
  13. Samuel, The field is automatically part of every page. You can simply echo $page->created_users_id There is also a $page->modified_users_id
  14. Thanks teppo - too easy! Still so much PW to learn
  15. Not sure if this is a bug or something funky with my setup, but I added a datetime field to the user template. When looking at the entry in the database (with PMA), the full date and time are in the field as expected, but when I view the user's profile in the PW admin, only the date is shown.
  16. No problem. It looks like you had it sorted in quick time anyways Just in case you haven't figured it out the difference between $page and wire('page') yet, there is a little explanation starting at this comment: http://processwire.com/talk/topic/3056-cant-use-input-urlsegment1-in-a-function-is-this-my-php-weakling-status-showing/?p=30044 As Ryan notes, wire('page') can be used anywhere, but is necessary inside a function due to variable scope. Generally though it is a little shorter to just use $page when you can.
  17. Do you have debug turned on in the config.php file? Also, add this to end of your body - at the end of your foot.inc file if that is how you have things set up: <?php if($config->debug && $this->user->isSuperuser()) include($config->paths->adminTemplates . "debug.inc"); ?> Let us know if those together produce any errors.
  18. This should do what you're after: foreach($page->siblings() as $sibling){ echo "<li" . (($page == $sibling) ? " class='active'" : "") . "><a href='{$sibling->url}'>{$sibling->title}</a></li>"; } Written in the browser and not tested, but should be close.
  19. Told you someone would have a simpler solution
  20. 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
  21. 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.
  22. 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.
  23. 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/
  24. 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.
  25. 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.
×
×
  • Create New...