Jump to content

Pete

Administrators
  • Posts

    4,043
  • Joined

  • Last visited

  • Days Won

    67

Everything posted by Pete

  1. You can change the search to include hidden pages: $matches = $pages->find("title|body|sidebar~=$q, limit=50, include=hidden ");
  2. Hehe, I was replying as you were replying. The cheatsheet did indeed hold the answer but for some reason I was originally trying to search for "images" on the cheatsheet before I remembered it would be an array anyway (oops). I blame the horrible cold I've currently got impacting on my brain's ability to think straight
  3. Never mind - I forgot PW allows you to do this instead to get $n random images. $a->getRandom($n) Code is now as follows and works perfectly: $homepageimgs = $pages->get("/")->images; $imgarray = $homepageimgs->getRandom(3); $resizedimgarray = array(); $i = 0; foreach ($imgarray as $img) { $scale = 262/$img->width(); $resizedimgarray[$i] = $img->size(262,round($scale * $img->height())); $resizedimgarray[$i] = $img->size(262, 149); $i++; }
  4. Hi folks I'm trying to grab 3 random but unique images from the images field on a website's homepage. Here's my code so far which does a bit of iteration, thumbnailing and cropping: $homepageimgs = $pages->get("/")->images; /*foreach ($homepageimgs as $k => $v) { echo $k; }*/ $imgarray = array(); for ($i = 0; $i < 3; $i++) { $imgarray[$i] = $homepageimgs->getRandom(); $scale = 262/$imgarray[$i]->width(); $imgarray[$i] = $imgarray[$i]->size(262,round($scale * $imgarray[$i]->height())); $imgarray[$i] = $imgarray[$i]->size(262, 149); unset($homepageimgs[$imgarray[$i]->name]); } The issue is that I want 3 unique images, so I need to remove whichever random image is selected during each iteration from the $homepageimgs array so it can't be randomly selected again. Sadly that last line of code returns an error. Any ideas? I was pretty sure the filename is also the key (as evidenced during the 3 lines of commented-out code). I also tried unset($homepageimgs->$imgarray[$i]->name); which is probably ridiculous, however my OO PHP knowledge is severely lacking hence why I tried it anyway
  5. up - useful if you have a section for documents, or a section for downloads etc so it's easily identifiable as to what the section's content is (although it should be obvious anyway it's always nice to have additional visual indicators).
  6. Indeed - I just assumed everyone knew already
  7. I just used the CheatSheet for the first time last night - I'd gone from an HTML template to an almost-completed website in 2 hours! This is a testament to how well this cheatsheet is laid out as much as it is to ProcessWire's ease-of-use, but the CheatSheet saved me having to look around for things and every minute saved soon adds up
  8. Nodes was the one that just popped into my head, but every time I think about it it would just make it more confusing to name them something other than pages, especially to an average user such as a business owner who just wants to be able to update their pages. --- I did have a slightly-related thought - why not change the "Pages" link in the admin to "Content", and allow the wording for a "page" to be changed on a per-template basis? That way you could have a template called "Products" and tell that template to call each child page a "product" instead? It's not a necessity by any means, but might make the workflow feel more... "right"
  9. Very nice! Some very neat javascript but not too over-the-top, and overall a nice layout and navigation. Good work!
  10. Not that it's much help, but wouldn't a better way be to leave the tree in-tact and instead just remove the Edit link for any page they can't edit? Perhaps somehow highlighting the pages they can edit? The only reason I mention that is because if you forget to give them access to the parent page of the one you want them to be able to edit then they won't be able to get to that page. I'm very interested in this by the way if you're creating a module from it?
  11. Very useful indeed - thanks!
  12. I can't speak for everyone, but I think most of us started with just the basic install. There are a few important things to read if you haven't already - the major one is the templates section on this page which will tell you how to actually output the content you're adding to the admin area into your template files when a page is loaded in the browser: http://processwire.com/api/templates/'>http://processwire.com/api/templates/ Assuming you haven't read it already, this entire section is worth reading: http://processwire.com/api/
  13. I think there would need to be more documentation actually written before that could be done - beyond the API docs I mean.
  14. If it's an option for any of you, this is quite good (aside from occasional crashes): http://www.my-debugbar.com/wiki/IETester/HomePage
  15. Not sure whether it will help you, but the database connection is kicked off in wire/core/ProcessWire.php around line 90 with this code: if($config->dbSocket) { $db = new Database($config->dbHost, $config->dbUser, $config->dbPass, $config->dbName, $config->dbPort, $config->dbSocket); } else { $db = new Database($config->dbHost, $config->dbUser, $config->dbPass, $config->dbName, $config->dbPort); } Wire::setFuel('db', $db); I'm not sure how you would set up another connection inside a module or template, as I doubt you would have access to the Database object, but something like this might work at the beginning of the template (untested): $mydb = new Database('localhost', 'username', 'password', 'db_name', 3306); or maybe (again, untested): $mydb = new Wire::Database('localhost', 'username', 'password', 'db_name', 3306); If either works let me know. The idea would then be to use $mydb instead of $this->fuel('db') for the queries.
  16. And the fact that your username has to be lowercase (gets me every time that one ). On that note, could you change the error message or give some more indication that it has to be lowercase ryan? That or change it so if you put in a mixture of uppercase and lowercase it doesn't error and instead just changes it all to lowercase behind the scenes and carries on. Back to the topic, I get what diogo is saying - sometimes it's handy for beginners to see just how easy something is so I was thinking about a very quick write-up with the relevant screenshots to help illustrate just how quick and easy it is. Some systems I've used are surprisingly less straightforward.
  17. This is on my list of things to do and makes sense to start with this.
  18. Another one for me to add to the docs
  19. I noticed that, looked into it and several people are pointing out these flaws to the admins over there, but apparently it's just a case of how their scanner works. You'd think it would be easy enough to train it to ignore jQuery and popular editors such as TinyMCE though as surely that skews all of the stats for most web-based projects. Still, it's yet more coverage which is good.
  20. Yet another awesome code snippet in that link ryan. I'm noting all these links down
  21. Marking the whole path back up the tree as active is something I looked at before but it hurt my head too much so I didn't do it in the end. I think what you need to do is start with the current page and grab all the page id's going back up the tree into an array, then use that to highlight the relevant pages in the menu as it's outputted. It sounds easy when you say it
  22. Can I just ask - did you create te news story itself UNDER the news index page? Looking the navigation on your page it looks like they're at the same level as a child story shouldn't be displaying there. If its not under the index page, go to the Pw admin and click on your news index page to open up the options, then click on your story, click Move and drag it so it's under the index page (it'll become indented).
  23. If they don't mind using something a bit external, you can display a Google calendar in a web page pretty easily from what I remember. There are advantages and disadvantages to doing so (we're going back a few years here so it might just be advantages by now) but you certainly get the benefit of a calendar you can sync with a smartphone or your favourite email software rather than one that has to be updated manually on the website. Beyond that, there seem to be a variety of calendar packages out there but none of the ones I've looked at were that straightforward.
  24. It does take a littel while to wrap your head around it (or at least it did with me) but on a larger site I'm working on I have a "Tools" section that's hidden (I think that was possibly ryan's suggestion) and then just had different sets of pages under there that form the basis of various selects. It doesn't feel "right" the first few times you do it, but when you think that all it actually stores in the database is a title and page ID, it's not like it's wasting space or anything (that was my initial concern) and also adds the flexibility for clients to potentially be able to reorder their own select lists or add to them etc. It's really flexible, it just takes a little while to get your brain around the idea of thinking it's wrong
  25. You'll need to use the $sanitizer, and in your case I think it would be: $url = $sanitizer->pageName($title, true); Obviously $title is whatever your title is. I'm not sure how it works with some characters, so let me know if that works for you. Full documentation on $sanitizer is here: http://processwire.com/api/variables/sanitizer/
×
×
  • Create New...