-
Posts
4,054 -
Joined
-
Last visited
-
Days Won
67
Everything posted by Pete
-
Off the top of my head I'd say that that looks correct. It should scale down until width or height hits one of those dimensions, then crop the other axis (so either a bit off the top and bottom, or a bit off either side) to become that exact size. It works well for most things as photos usually have the focus of the image in the center. Where it can cause issues though is a portrait photo for example (as in a head and shoulders shot of a person, not talking about landscape/portrait in terms of image orientation . I've had one where it chopped the top of the person's head off since I wanted all images to be cropped to a specific width and height, so you have to be careful or instead use Apeisa's wonderful Thumbnails module so you can specify image crops and custom-crop images in the admin.
-
I've no popped my head in yet due to time constraints, but can I suggest that if there is helpful code discussed over there that might be of use to others that we somehow post it on the forums too? That's the only problem with IRC I think, but otherwise it's a superb facility for more rapid discussion. Of course I only mean to post things if it's something really useful that's not already been covered to the best of your knowledge - not an easy set of parameters I know, but I'd hate to miss out on something amazing just because I wasn't on IRC at the time
-
This comes back to everything in PW being a page, even users. For example, I can fetch myself using $pete = $pages->find('template=user, name=pete, include=hidden'); You might want to check that field name though since I'm on my phone, but I think that's right anyway. Either way the users section is hidden so you will need that bit on the end I think.
-
The real question is what to do when you're workin with a very different alphabet - Cyrillic, Chinese etc. I think that most programmers are used to English spellings (or rather American spellings in the case of HTML - "color" ) and will be aware that they have to use the correct function names and API methods etc, but I would imagine that in vastly different alphabets we'll find that in the admin interface everything will be translated but they'll still be able to use it just fine. When we get members interested in translating into those languages then I would also suspect that the Cheatsheet might have its descriptions localised too, which would be cool.
-
Sounds like you're after this (Ryan posts a module part of the way down the page):
-
You would have to write some logic to check the width and height using $image->width() and $image->height() to see which side you want to scale it down on, but then I think it's just a case of using $image->size() and only putting in the width or height For exams I think I you had an image that was landscape and you wanted to scale to a width of 400px you should be able to do $image->size(400,0) and to scale by height only switch the numbers around. This is all off the top of my head but I'm pretty sure that setting 0 as one of the dimensions just let's PW work out that other dimension for you. Was that what you were after?
-
Does anyone know how to upload a form File threw the api
Pete replied to peterb's topic in API & Templates
Just a quick reply from my mobile so I can't type much detail, but your file data will be accessible through $_FILES['upload'] and not $_POST['upload']. Hope that helps a little, but for more information (such as where your file sits after submitting your form - it will have to be moved from your server's temp upload folder to the field in PW) you should run a quick search for $_FILES on PHP.net -
Nice - I see precisely what's happening and that's a clever way of doing it indeed For anyone confused as to what the new module does, it basically allows you to view the page as if it were published. In fact, for the current page it sets the status of the page as though it were published (I think) but only for the page launched by the preview button, and doesn't save that state, so you're viewing it as if it were published even though it isn't. I think that's right anyway.
-
Well after 3 months' worth of evenings (and various iterations over the last 11 years) it's finally in a state that I'm happy to show it to you in. You'll need a modern browser to view the site, as it looks a little off in IE8 and will almost certainly break in IE7 and older - I have the somewhat enviable luxury though of being able to ignore older browsers completely since the site's visitors overwhelmingly use new browser versions. Without further ado, I present StrategyCore I'll post a case study at some point, but here's a brief intro and a few of the highlights to get you started. My first website - X-COM.co.uk - was built in 2001. By 2003 it became apparent that there weren't going to be any more games in the X-COM series (although any fans of the series will know that there are now two more in development some 11 years later!) so it branched out into other strategy games and was re-labelled as StrategyCore - covering core games for strategy gamers. It's not a huge site by any means - a few hundred pages and a hundred thousand posts on the forums (not a great deal in 10 years ), and has been growing at a modest pace, but when I get time away from other website work I like to try new things with it and use it as a place to test some neat ideas that I can use in other projects as well. Several PW modules came about as a result of this - the SitemapXML, SocialTwitterUpdate and Maintenance Mode to name a few, as well as others I'm still polishing up the code on. Before this turns into a case study (it's getting late here in England) I'll post that list of (vaguely) interesting features: Forum integration - news articles on the site generate a topic in the forum software and if you're logged in there's a full commenting interface with various buttons (quote, edit, delete etc) as well as pagination, not that there are any articles with enough comments for that to show yet! Logins aren't integrated yet, but I'm working on it. Random header images and taglines The Dark and Light links next to the search box at the upper right - click on them I prefer the dark one personally. This will eventually be re-worked into a "Settings" button where you can set preferences for which header images to show, set your newsletter subscsription, choose which site colour to have by default etc, but for now on the site and in the forums these just change the colour) A nice bookcase - not a particularly original feature on websites by now, but still looks neat Some neat categorisation, archiving and pagination for articles Game playthroughs (After Action Reports) tagged on the forums are automatically added to a specific part of the Articles section (hidden by default of course) - saves us some work adding them to the list manually from now on My first foray into responsive web design. As such, I kept it basic, catering only to monitors (to far along with development to be thinking about tablets etc unfortunately) but having a set of minimum and maximum widths that should work on 1024x768 and 1920x1080 monitors equally well. A nifty bit that caused me a slightt headache is that when you view the homepage and make the browser window narrower, the right-hand block drops neatly below the "Featured" block at a certain resolution to give it more space to display longer article titles. There are plenty of other bits and pieces, but they're hard to spot without me pointing them out and a lot of it is behind the scenes stuff which I'll cover later on in a case study. I think that's the point though - if you get it right with web development then things should look simple and people won't know what went into making it look the way it does. There's still quite a to-do list - meta data is missing at present, I need to tidy up some hideously complex and disorganised CSS (should have used LESS, and the mess is a result of adding bits here and there as and when I get time to work on the site rather than categorising styles properly - not the norm, honest!) and minor styling fixes on the forums, but I'm happy with it. Anyway, these are a few random late-night ramblings and as mentioned a case study outlining all of the useful details will follow at a later date P.S. I know the Files section looks completely different. There is a plan to import all of the files into PW at a later date once I've built a proper file repository and do away with that third-party file repository script completely, but sadly real work is having to take precedence now.
-
I found the setting in the config file that sets permissions for uploaded files and this is now resolved. I noticed when looking into this that some files got given good permissions 0644 and others got too few permissions 0600 (which must be an issue specific to my server as it was random) but why is this config option not turned on by default? I'm not too bothered either way, but the actual line that uses it begins with an @ so it's not like it would throw an error if you enabled it in an environment that couldn't set it anyway. Just curious. I'm just happy to have solved this one
-
Hmm... it seems to be working now without setting autojoin (I forgot to change the field on my live copy but changed it locally and they both display correctly now) so not sure what I was doing wrong before. Oh well!
-
I'm currently trying to grab pages using different templates into an array to sort by a common field - publish_date - which is a datetime field. Here's the first part of my code: $day = 86400; $weekdays = $day*5; $fortnight = $day*14; $limit = 4; $featured = new PageArray(); $featured->import($pages->find('template=article, publish_date>' . (time()-$fortnight) . ', images.count>0, summary!=, sort=-publish_date, sort=-id, outputFormatting=false, limit=' . $limit)); So as you can see, I'm grabbing all pages with the template "article" added in the last fortnight. In another line further down I add items using a "news" template to it that are posted in the last 5 days. The problem is that I've put this code into my homepage template and sorting by publish date descending isn't working - this is because by the time it gets to the template the dates have already been converted from a timestamp to a human-readable time so it's displaying in a weird order (I suspect it thinks that 30 March is higher than 1 April as it only sees the number when doing this comparison, as it will have no clue what the date is now it's not a timestamp). The solution was to put it into a module that runs before page render, but it would be nice to have an optional flag to add to the $featured->import to set outputFormatting off for that set of selected pages, or even better just retain the unformatted date as publish_date_original or something. Not sure what the best way to go about this is, but I'm sticking with my module now as it works well there - this topic might be useful in case anyone runs into a similar situation though.
-
It turned out there was an error in another module I'd created. Well, not an error, but when I uncommented this line in the other module it worked: $mypage = wire('pages')->get($myid); Not sure why doing that in another module would cause outputformatting not to work though Still, I didn't need that line as it was only there for testing so it's no big deal.
-
Images I upload are getting their permissions set to 600 by default. Thumbnails get set to 644, which is fine as they can still be read, but the original images are 600 so they can't be read. I suspect it's a weird setting on my server now that the site is live (worked fine locally) but is there something I can do? Should there potentially be a check for this in the image upload function?
-
Cheers for that - it only appears to be keeping about 24 hours of them which is how it's suposed to work I see. Fortunately that stops it at 5,600 files
-
Hi folks So I've got a very active PW site up and running (finally) but I'm not ready to link to it until I finish my snag list I was just looking through the log files, and noticed the site/assets/sessions folder - it has almost 3,000 session files in it already and the site's not been online 24 hours yet! Are these required for something? They all seem to contain the same content: Session|a:0:{} Seems a bit pointless, and I'm not sure what they relate to - any ideas anyone?
-
Videos inside processwire: How to embed videos inside processwire?
Pete replied to jester.vergara's topic in FAQs
Nice one diogo! That's a far more advanced version of what I had in mind, except I was going to do it in PHP (whenever I get around to it). It certainlydoes help by having all the API information in one place! -
Wow! That's pretty awesome! There are some exciting things you can do when calculating a radius from a given postcode for finding things nearby (as the crow flies) etc, so this is very good news indeed and ideal for an upcoming project. That's the other thing I love about these forums - you find out cool new stuff every day because the community likes to share
-
Ouch! Those files cost a bit of money don't they?
-
Okay, so to add to the oddness, the hook runs without issue when I refresh an admin page and correctly updates the field. When refreshing a page on the front-end it fails with that error. Could something in one of my templates be causing the issue?
-
Hehe, yep - it was originally relating to the current page, hence the $event argument, then I thought I'd shift it to its own function and maybe do LazyCron to update all pages every 20 minutes or so rather than running it on every page load. Still, this version is still set to run after Page::render now so should still work, right? It's throwing me an identical error, though obviously different line numbers. The error is:
-
It's set to run after page render, but here's the latest version (probably not much use out of context though): public function checkCommentCounts() { if ($this->initializeIPB()) { $topics = array(); $commentPages = wire('pages')->find('template=news,forum_topic>0');//|article,forum_topic>0'); if ($commentPages->count()) { $topics = array(); foreach ($commentPages as $commentPage) { //echo $commentPage->title; $topics[$commentPage->forum_topic] = ''; } } $this->DB = $this->registry->DB(); $this->DB->build( array( 'select' => "tid, posts", 'from' => "topics", 'where' => "tid IN (" . implode(',', array_keys($topics)) . ")", 'order' => 'tid ASC', ) ); $this->DB->execute(); echo $this->DB->getTotalRows(); //exit; if ( $this->DB->getTotalRows() ) { // Iterate through each result while ($row = $this->DB->fetch()) { // If there is a result that doesn't have a corresponding page on the site, then add it if ($commentPages->get('id=1582')) {//,forum_topic=' . $row['tid'])->article_comments != ($row['posts']-1)) { //if ($commentPages = 1582) { $currPage = $commentPages->get('id=1582'); echo $currPage->title; //exit; //$currPage = wire('pages')->get(1582);//$commentPages->get('forum_topic=' . $row['tid']); $currPage->of(false); //echo $commentPages->find('forum_topic=' . $row['tid'])->count(); //exit; //echo is_string($currPage->article_comments) ? 1 : 0; //exit; $currPage->article_comments = 2; $currPage->save(); $currPage->of(true); } } } } } $topics is an array of post counts for the topic IDs searched for using the $this->DB. The DB functionality is from the forum software, so that can be safely ignored. The bit that's really confusing me is that at some point in the last 4 weeks this has worked (not this exact code, but one like it that I've also double checked and doesn't work ). Oh yeah, and it's very scrappy as I'm in the middle of trying half a dozen different things trying to fix it - sorry if that's making it less legible!
-
I decided to move it into a different module entirely without success either, then tried saving a page in the template code instead to rule out an issue with modules - no success on those either. Is there any reason why it would give that error with outputFormatting turned off?
-
Cheers Steve I'll merge that soon as it's very useful! There was a looping issue mentioned under very specific circumstances (something about a user who's not a superuser getting an infinite redirect) by someone recently too so I'll investigate that at some point next week and put any and all changes into a new version.
-
I've not tested this thoroughly yet, but to hijack the thread slightly and go back to my earlier request - we don't need to. I realised the other day that if PW is just made to use the default theme (called "default") then we can just have additional CSS in the admin CSS file to override colours etc instead of my idea to somehow support multiple themes. So... ignore my previous posts asking about that. Back on topic, I'll try to test these changes over the weekend if I get time Soma!