Jump to content

teppo

PW-Moderators
  • Posts

    3,208
  • Joined

  • Last visited

  • Days Won

    107

Everything posted by teppo

  1. If you need to handle a large quantity of pages, I'd probably rely on SQL. Sounds like a rather trivial task that way, though this, of course, depends on what you're actually after. If I'm reading your post correctly and it's just selected pages you're looking for: SELECT GROUP_CONCAT(data SEPARATOR '|') data FROM (SELECT DISTINCT data FROM field_myfield ORDER BY data LIMIT 5) f; After that you've got a list of pages you can pass to $pages->find().. though I don't quite understand why you'd want to do this with the limit, so there's probably something I'm misinterpreting here. I hope you get the point here anyway IMHO It's questionable whether selectors even should be able to handle every imaginable task. This, for an example, seems quite rare need to me (and is already easily solved by either loop or SQL). Selectors are good at finding pages in general, while finding distinct values, even when those values are later used for finding other pages, sounds like a job for something entirely different -- or some kind of combination of SQL and selectors.
  2. +1 for some of these, especially the force delete field/template ones. It's apparently a safety feature to make it harder to lose important data, but also very, very annoying at times. IMHO a proper warning would be quite enough: "this will remove [the field from following templates / following pages using this template], are you sure you want to continue?"
  3. teppo

    Heartbleed

    Thanks, netcarver -- the article was great and the video linked from there was even better. Every good explanation needs a hand (or mouse) drawn diagram
  4. teppo

    Heartbleed

    I found this post kind of interesting: http://article.gmane.org/gmane.os.openbsd.misc/211963. Haven't checked the facts myself so can't really vouch for it, but if it's true.. well, it does tell something about the mindsets of the developers working on this particular product. Security in general is very complicated thing like Matthew already pointed out, but too often vulnerabilities are (at least partly) a result of laziness, general ignorance and/or bad practices.
  5. RT @sandofsky: The data is in: hamburger menus kill engagement. "It was a disaster!"http://t.co/DlxaM1JIXM

  6. @bwakad: once again this depends on your use case, but you can always add page-specific notes in a field that you simply omit from page output. For template-specific notes Soma's module does good job.
  7. Already a bunch of good resources, but here's a couple more: Especially if you're at "absolutely beginner" level, there's a ton of useful video tutorials floating around. This one titled "Learn PHP in 15 minutes", for an example, seems pretty good. For more background there are also more thorough videos, such as this Harvard extension school lecture. Once you get up to speed, you should most definitely take a look at PHP: The Right Way. If you're really into it, I'd strongly suggest Programming PHP from O'Reilly. It's available as an ebook too. Another book worth checking out is Essential PHP Security. Short but good -- if every PHP developer knew at least this much about security best practices, PHP world would be a lot safer place. Just my two cents. Totally random fact: Designing Web Graphics by Lynda Weinman was one of the very first web design books I could get my hands on. That was some fifteen years ago, when quality learning material was still kind of scarce, at least around here. Should probably take another look at that book one of these days, could be sort of fun
  8. RT @HeyyThereDalia: So Nyan Cat and LulzSec are in my sociology textbook http://t.co/KQLrIP0ccZ

  9. $pages->find(..) returns PageArray, not regular array, hence the issue with array_merge(). Also there's no need for array_unique() (should it work), PW handles this already by grouping results by page ID's. Apart from that, I believe that DaveP is right; you'll have to do separate queries and merge results: $ps = $pages->find("customer=$page->customer"); $ps->add($pages->find("service=$page->service")); $ps->add($pages->find("business=$page->business")); // etc. One problem with this approach is that, depending on your situation, you might not be able to use limits and built-in pager functions to full extent. Anyway, hope this helps a bit.
  10. Take a look at mb_substr() for setting character limit. For word limiter you can use something like this: http://snipplr.com/view/12987/limit-words-in-a-string/. // basic mb_substr example $value = $page->my_field; if (mb_strlen($value) > 255) { echo mb_substr($value, 0, 255) . "..."; } else { echo $value; }
  11. “Submit your poster in PowerPoint format”. Whoever wrote that must hate Mac users. Two hours well spent. http://t.co/m7asD0KzI6

  12. RT @codepo8: Web apps that talk - Introduction to the Speech Synthesis API - http://t.co/8Ti42qpIgA

  13. RT @lukew: "You understand a product if you understand how it’s made." -Jonathan Ive

  14. RT @UCDNewsletter: Accessibility Features of HTML5 With Mark Sadecki, W3C / Web Accessibility Initiative http://t.co/Fn7fOPlewM

  15. RT @johnmaeda: Steve Jobs on the disease of believing that 90% of the work is having a great idea … via @cdixon http://t.co/4yT1EJlmrx

  16. @WillyC is right; the problem is most likely that you're calling renderDirectorProfile() .. a) for user that doesn't exist or b) for user that exists but doesn't have any images available. Adding proper checks for $user->id and count($user->images) / $user->images->count() before trying to output content is strongly recommended: function renderDirectorProfile($person) { if ($person) { $director = wire('users')->get("name=$person"); } if ($person && $director->id) { $o = "\n<div class='member span4'>"; if (count($director->images)) { $directorsImage = $director->images->first(); $o .= "\n\t<img src='{$directorsImage->size(369, 369)->url}' alt='$director->fullname' />"; } $o .= "\n\t<h2>$director->fullname</h2>" . "\n\t<span='position'>$director->position</span>" . "\n\t$director->body" . "\n</div>"; } else { $o = "<p>Couldn't find director.</p>"; } return $o; }
  17. You can definitely use size() in functions. If you take a closer look at the error you're getting, it's not saying that you can't use size(), but that you can't use size() "on a non-object", meaning in essence that $image (or whatever you're calling the size() method on) isn't defined or isn't valid object (it should be an instance of PageImage in your case). Without seeing your code this is just a guess, but it would seem that this is a scope issue, i.e. you're fetching the $image outside function and then trying to use it inside or something like that. Since $users->get() shouldn't work within function context at all (you should use wire('users')->get.. there) I'm wondering what exactly you mean by "equivalent" solution here
  18. I'm not entirely sure that I get your whole setup, but just a small pointer: The error you're seeing most likely comes from FieldtypePage and means that Page with ID "ID#" (from your error message) is not a valid value for "Field-Name". First thing I'd do here is check the settings of this field ("Field-Name") to see why this page isn't valid for it. Hope this helps a bit.
  19. "Verkkopalvelun ostajan opas" 17.70€ from @TalentumKirjat. Would prefer ebook, but that costs additional 40€. Right..

  20. @etling: that's right, include the domains you'll want to use this site with there and things should work just fine. @bwakad: sorry, I'm not really sure what you're saying there, but whatever domains your site uses need to be included in httpHosts config setting. It's that simple.
  21. You'll want to make sure that your Apache user has read, write and execute permissions to assets and it's subfolders. Other directories you rarely need to worry about. Setting permission 777 to whole assets directory recursively (chmod -R 777 site/assets/) is more than enough. You could be more specific and only allow it to only write into assets/files/, assets/cache/, assets/logs/ and assets/sessions/, but then there are modules that write directly to assets folder and would fail after this. Bad Gateway 502 as a result of this sounds like some strange server setting -- I've seen shared hosts throw errors if a file is executable/writable by all users (security feature attempting to mitigate risks usually caused by shared hosting itself, kind of ridiculous really), so this could possibly be something like that. In those cases you'll need to configure permissions properly: only give write and execute permissions to the user Apache is running as (often that would be your own user account). The host most likely explains this stuff somewhere. Apart from that I've no idea what could be causing that.
  22. I'm guessing that you're already familiar with it, but the Multisite module Antti wrote does awesome job when you want tightly connected sites. If that's too much, custom interfaces (or pages web service, as you already mentioned) make it possible to design exactly the type of coupling you need. Just saying; your idea sounds great, though not sure if this would make that much sense as a core addition, considering that it's pretty specific need you have there and all the building blocks are already available, so to speak
  23. You should be able to do this with sanitizeValue(). My experience with fieldtypes is very scarce, but AFAIK that's what this method is for Edit: unless you're already using it as a base for your own fileldtype, take a look at how sanitizeValue() of FieldtypeEvents works. That pretty much explains it, I think. If you don't like the value, throw exception. I'm not entirely sure if it's possible to entirely disable setting value via API though, if that's what you're after -- i.e. giving $page->yourfield a value that's an instance of the object it expects -- without disabling page edits etc. too.
  24. Actually what DaveP suggested would make a lot of sense as an addition to default ProcessWire .htaccess. Commented out by default, like it is in HTML5 Boilerplate, probably. I did not know that proxies dislike query strings, but that does make sense -- and I'm unlikely to be the only one caught out by this.. Taking things a bit further, options for enabling / disabling / configuring certain .htaccess settings easily during install phase could result in some very interesting possibilities. That's probably way out of scope for this particular discussion, though
×
×
  • Create New...