-
Posts
4,035 -
Joined
-
Last visited
-
Days Won
66
Everything posted by Pete
-
Good shout - in fact it will mean anything on Github that links back doesn't work, but I think ryan may have a plan involving .htaccess for this (but changing the links would be helpful too). Unless another moderator beats me to it I might see if I can do a search for links and update them tonight.
-
Hehe, with great power comes great responsibility
-
You're not going mad - there was a final step I forgot to complete last night. I realised what it was at midnight, but it was a bit late by then. Welcome to the forums by the way They should all be visible and working now - fixed them about an hour ago.
-
Well spotted - there's another setting I need to change that I forgot about. Don't worry though, whilst your post counts won't increase til I sort it there is a recount button so it'll be showing correctly sometime tomorrow.
-
There is already a mobile theme if you check it out on your phone. I think there's also an app that links into this software to make the mobile experience slightly faster, but I might need ot alter some settings before we look at that. I've already got a list of style issues and hope to squash them by this time tomorrow, so if you spot any more after then that look really odd then please do let me know. EDIT: I've just fallen in love with the quote feature - try clicking quote on a few posts and watch it do all the hard work in the reply box. I've used this software before, just not updated the other site I use it on to this version so a lot of this is new to me too
-
There isn't currently a hook, but I was going to write one (for Twitter at least) and use Tijs Verkoyen's Twitter oAuth class that I've used for other stuff before: http://classes.verkoyen.eu/twitter_oauth You will need a hidden custom field in which to store the twitter status ID (and Facebook's equivalent, but I can't help you there as I inly know about Twitter in terms of the above class). For such a module, the steps I would take in the code are: Add hook after page save Check to see whether page status is published Check the hidden twitter status field - this stores the unique ID of the tweet If it's empty, add a tweet If it's not empty, do nothing Similarly, you might want to automatically delete a tweet if a page is deleted, otherwise you will have issues with tweets linking back to non-existent pages. Personally I would make this a configuration setting in the module so you can decide what to do for your particular scenario. The steps when a page is deleted (and I would say deleted from the trash - not just moved to the trash - just in case it's an error) are: Add hook after page save Check to see whether page has been deleted Check the hidden twitter status field - this stores the unique ID of the tweet If it's empty, do nothing If it's not empty, delete the tweet If you don't mind waiting a few hours, I need to build this module anyway so I might just do it this afternoon. Then you could use it as a basis for a separate Facebook version if you like?
-
It's actually: $page->httpUrl and that gives you the full URL to a given page, with http prefix.
-
No problem My first thought was making it something you can set per-template in the template settings, but that sounded too difficult and you would have to write some code when editing a template to check it has a cropimage field and then have a setting just for that. It also seemed too detached from the field itself. My second thought was to define it per cropimage field as it would be a bit more intuitive editing it there, but I don't like creating duplicates of the Images field just for things like this where you'll only ever define different settings once or twice in a website's lifetime I think. Which brings us back to the module configuration itself - seems to be the most sensible place and certainly the easier option to code!
-
Antti - just wanted to say I've (finally) just started using this module and it's amazing! Great work! The only suggestion I have is that it would be nice to have a way to make the configurations for thumbnails somehow able to link to certain templates, for example if I want a specific thumbnail size for news article images then I'm unlikely to want that thumbnail option anywhere other than when I'm creating a news article. I know, it's not straightforward, but rather than make it too technical, I thought maybe this could still be specified in the same place, but add extra parameters on the end if you want it only available to specific templates: thumbnail,100,100 portrait,100,150 largethumb,200,200 newsthumb,250,180,news_home,news_article In the above example, the first three thumb settings would be available to all cropimage fields, and the newsthumb would only be available to the news_home and news_article templates. Something like that anyway, and it's just a thought (although it might be worth somehow being able to specify fields as well as templates?).
-
I keep forgetting about Chrome Frame - thanks for reminding me as I can think of one site where I could offer that as an option other than telling users to simply upgrade.
-
That's what's always bugged me - one site had about 5% IE6 usage a few years back but I had to still make the site work in IE6 because 5% of 200,000 is still worth catering to Hopefully most system admins will not know about the automatic update program. I'm a system admin at work, but we only use the latest software anyway
-
Cheers ryan Forgot I had a Github account for a sec there. Added, updated the link in the first thread and added it to the growing modules spreadsheet on Google Docs Yup - I'll probably make the time configurable at some point in the future as it seems like an easy interim update before doing anything more complicated.
-
Very good point - I'd completely forgotten about that! One of the forum applications I use has this though I'm quite far behind on the versions. I believe they had one for forums, one for posts, one for calendars etc. It would have made more sense for them to split up posts by forum though as it gets a bit silly if it tries to put a million posts in one file (I don't have that problem fortunately ). So thinking about this a bit more, it would make sense to have some template settings for this module too in a future version and specify cache times and re-index periods for all pages there. It could then create separate sitemaps on a per-template basis as you say. I think that would cover most eventualities there. My only gripe would be that caching per-template wouldn't help if you were running a large blog/news site as one main template would apply to most of the content. Perhaps splitting it per year, or simply having it split the sitemap at X thousand pages if you have a huge amount of articles? I think per-year sitemaps for larger article sections would be best thinking about it. Presumably if a page from 2009 is modified and then ends up in the 2012 sitemap it's not a big issue - Google will be told in 2012 sitemap to index it again and it's not like you're going to modify old articles particularly often so I wouldn't see a need in cleaning up the 2009 cached sitemap in this case. It does look like you can easily have a master sitemap linking to sub-sitemaps though so that part is pretty straightforward at least (and it looks like 50,00 pages per sitemap is the maximum allowed): http://googlewebmastercentral.blogspot.com/2006/10/multiple-sitemaps-in-same-directory.html Anyway, this is one for when I next get a few free hours
-
I forgot to ask - is there a better way of having a module run when an admin-only page is loaded other than this: <?php if ($page->template != 'admin') { // Do stuff } ?> It's no longer relevant for this module as it now runs before the page data is available, but when I had it in the first version I gave myself a pat on the back for figuring I could check for the admin template like this. I can see how such a check would be good for other modules though so just wondering if there's a better way for checking if we're in the admin.
-
Thanks ryan - I was a bit worried about the 404 so this is a good solution and something I'll definitely bear in mind for future modules. I enjoy writing these modules as every one teaches me something new about how PW works behind the scenes. I've implemented your suggestions and replaced the file in the first post with the modified version with the new name (if anyone has this installed already, simply uninstall the old module, delete the module file and install the new one). I also implemented caching as you suggested and cached it for an hour (for most sites a day or more would probably be fine, but if you're writing articles or running a blog you want search engines to index your content as soon as possible so that seemed like a good period to set it at thoguh I've no idea how often search engines actually check a sitemap). I agree that there are quite a few potential issues on larger sites and not just because of the sitemap's size. Google doesn't always index everything on larger sites, and I was just reading about how someone tested this by telling Google that things like news posts and forum posts (individual posts, not threads) should on;y be indexed once as they're unlikely to ever change. This apparently frees up the search engine crawlers to check the new content rather than go over the same content each visit. I can see a few places that this would be useful in PW - for example a news section would only need each article to be indexed once (if you ever went back and edited a page, I believe the last modified date would force a re-index) and various other similar examples. There's a good list of tags for sitemaps here: http://support.google.com/webmasters/bin/answer.py?hl=en&answer=183668 and the tag to use would be <changefreq> , however that could get a bit tiresome if you had to have it on every page. A potential solution for a future version of this module would be to have such a field and simply have all child pages inherit the parent value if they don't have one set themselves. Another option as a possible alternative to caching would be to run the module once on the first time the page is called, then only re-generate the sitemap once a page is edited/created/deleted as those are the only three times a change to the sitemap would technically be required. I'll leave it as it is for now though.
-
Extending the ImageField with a watermark option
Pete replied to formmailer's topic in Module/Plugin Development
I've had some dealings with this before, however not in ProcessWire specifically. I agree with the idea of doing it per-image as I've had the need in the past to watermark exclusive images from computer games mized in with non-exclusive images in articles. You will have a few potential issues with any approach - if it's a light image, you'll want to apply dark text for the watermark, and if it's a dark image you'll want to apply light text. I would suggest an option be that you can watermark using another image (a transparent PNG) as well, but you can have the same issues as above (think I got around this by making my PNg watermark image with white text and a dark shadow so it stands out on all images). There is actually less code involved in placing a transparent image on top of another image as well, though it would be nice to have both options configurable in such a module. Another thing to take into account is that you only want this to be applied to large versions of images on the final page, though I guess it doesn't matter too much if the thumbnail included a tiny watermark (I'd prefer not on a thumbnail on the final page, but not sure how you would get around it as they're generated on the first page render). If you're resizing uploaded images over a certain size too (like I do) then that needs to be taken into account also as the filename has the large size appended to it, though presumably this new filename is easy enough to get hold of. So lots to think about, but I don't know where you would start either -
That's actually how I began this module - as a separate template - but then I thought it would be quicker as a module and then there's no need for an actual page or any templates and it's all in one file. Plus I really wanted to have that optional sitemap_ignore field that I'd used in the previous CMS I worked with. I'm glad I did start creating it as a template and page though, else I'd have had more hassle working out why it wasn't outputting XML (I needed to specify that XML was being outputted by using a PHP header).
-
Here's a list of services you can submit your sitemap to: Google Webmaster Tools Bing Webmaster Tools There used to be a service for Yahoo called Site Explorer that was similar in functionality to the above two services, but it appears that this has now been replaced with Bing's offering. On the bright side it's one less service to sign up to You can also submit to Ask using the following URL (replacing the relevant part with the full URL to your sitemap): http://submissions.ask.com/ping?sitemap=http://www.the URL of your sitemap here.xml Generally I find Google and Bing to be sufficient though, as the other search services seem to trawl their content reasonably quickly and find out about new sites that way sometimes I think.
-
I missed the XML sitemap generator that I used in a previous CMS so I built my own module to achieve the same functionality. This module outputs an XML sitemap of your site that is readable by Google Webmaster Tools etc. I've generally found that it reduces the time it takes for new sites and pages to be listed in search engines using one in combination with Webmaster Tools etc (since you're specifically telling the service that a new site/new pages exist) so thought I may as well create a module for it. The module ignores any hidden pages and their children, assuming that since you don't want these to be visible on the site then you don't want them to be found via search engines either. It also adds a field called sitemap_ignore that you can add to your templates and exclude specific pages on a per-page basis. Again, this assumes that you wish to ignore that page's children as well. The sitemap is accessible at yoursite.com/sitemap.xml - the module checks to see whether this URL has been called and outputs the sitemap, then does a hard exit before PW gets a chance to output a 404 page. If there's a more elegant way of doing this I'll happily change the code to suit. Feedback and suggestions welcome On a slightly different note, I wanted to call the file XMLSitemap originally so as to be clearer about what it does in the filename, but if you have a module that begins with more than one uppercase letter then a warning containing only the module name is displayed on the Modules page, so I changed it to Sitemap instead which is fine as the description still says what it does. File can be downloaded via GitHub here: https://github.com/N.../zipball/master
-
It literally runs your code before that process - saving the page in your case.
-
Urgent matter: Fatal error: Maximum function nesting level of '100' reached
Pete replied to Sylvio's topic in General Support
I think I encountered this one a while ago when I was writing a module that wasn't as optimised as I'd thought at first. Did you install any modules around the same time? Of course, xdebug might be complaining if multiple pages are saved at the same time, as is the case if you re-order pages for example (I think every page on the same level has to have it's position saved so the same functions will be called then and that could be what it's complaining about). I ended up not using xdebug as it was more hassle than it was worth and turned on proper PHP error reporting and put PW into advanced mode in the config to get detailed error messages that way. -
Yup - you may well face-palm when you see the copy function ryan posted, but I tend to get confused with this at times too, especially with form input (move_uploaded_file in that case, but you can also use copy in that case as well which confuses me more, even after reading PHP's notes on the move_uploaded_file function).
-
Just a guess, but do the other fields it's nor parsing contain a colon as well?
-
No worries - to be honest I didn't even realise it was a GIF until I uploaded it and I'll probably just convert it to a PNG anyway. I think in my code in the past to get around potential headaches with grainy thumbnailed GIFs I saved them as JPEGs instead to get better compression, but that's not always going to be the desired way to do it.
-
Hi I think there might be a problem when showing thumbnails in the page editor if they have transparent backgrounds (see attached image). Basically when an image is resized I don't think it's storing the transparency data. It's been a while since I looked at thumbnailing in PHP and I think you can save that data when thumbnailing gifs, but an easy solution here would be to set the canvas background to be white instead of black (which I seem to recall is the default) since the page background is normally white in the PW backend. Obviously saving the transparency would be the favourite solution as I know we have one dark admin theme already. Possible solution here: http://www.php.net/manual/en/function.imagecopyresized.php#104556 Not sure if there would be similar issues with PNGs?