Jump to content

Pete

Administrators
  • Posts

    4,054
  • Joined

  • Last visited

  • Days Won

    67

Everything posted by Pete

  1. There are already commercial modules - ProCache and FormBuilder. I understandably concerns but wouor say don't worry about it If you take the commercial modules from a certain popular blogging platform as an example, theit functions would interact with the core code as well so it's a bit similar to that except you can tie in Mich more with ProcessWire's functions in PW modules. I don't believe you're bound by the license just because you're building a module. There was a discussion around this a long time ago but I can't find the topic - can anyobe remember where it is? I vaguely remember ryan giving his opinion on thus subject. Edit: you linked to it at the start - oops!
  2. If you are talking about one question and answer per page with a comments section beneath (or just a question with all answers as comments) then the current comments module would be your best starting point as it's already built to scale up. If the questions will all be separate pages like Stackoverflow for example then you could just do that with a normal page. It matters less about scalability there as you would only display one at a time, or if browsing tthrough all questions you would paginate them with 20 to a page or categorise them some other way.
  3. That's really great ryan - I need this for something I'm doing right now
  4. Indeed - it's a separate DB table like ryan says - if you take a look at the MapMarker module and a few others where they create their own tables you'll see that instead of just being a collection of different fields in their own tables like normal PW fields created in the admin these are like going back to a "normal" table with multiple fields. Very useful for some situations where you don't need to re-use fields elsewhere and have a pretty bespoke dataset that needs to scale to potentially millions of rows. This would also be good for things like invoicing systems, shopping carts etc where you want to store fields like item name, price, tax, total etc where you just wouldn't really need them as separate fields in the admin - they only make sense in the context of a single module. Which unfortunately means I need to change something I've done in an as-yet-unpublished module at some point to make it scale better
  5. Thanks Manfred - that was odd! I'd saved the page which was set to clear the cache but for some reason it didn't. I'll have to keep an eye on that as the only way I could clear it was deleting the cache file in FTP for some reason.
  6. I've officially launched this site today: http://www.kidderminster-husum-twinning.co.uk/ For those not familiar with twinned towns/cities - many places (in Europe at least) are twinned with other places in the world and these are two such places which have built links between their cultures, clubs, associations etc. It was a relatively straightforward site. A design I had made many months ago actually lent itself to the Foundation site profile (which I upgraded to Foundation 5 without too much hassle) and most of the content benefits from the default styling in this case, which was a bit of a fluke as I'd not done anything with Foundation when I originally designed this I was in two minds whether to use Foundation as I'd not really touched responsive before, but it works nicely on mobile and I'm glad I did it. There's a bit more going on behind the scenes than meets the eye, and I think that because this looks like a simple site it might well be worth a full case study with a few tutorials of how I personally approach things. As for the tools I used, here's my list of modules: CKEditor Markup Yahoo Weather (a modified version) Page Link Abstractor (I always use this now so links in the body don't break when moving the site to the live server) Thumbnails (I couldn't imagine a site without this!) Languages - all of the core modules for languages, as there are English, German and Danish versions of each page (not all translated before anyone spots that but I shall leave that to the Twinning committee ) I also turned on caching for each of the templates. Due to the weather constantly updating on the sidebar I didn't use ProCache on this occasion - I toyed with making the weather a JS/AJAX/PHP combo but it then loses it's synchronisation with the two images in the slideshow on the homepage and that looked so nice that I can live with what is still a relatively quick site without making design sacrifices for the benefit of a bit more speed. What do you think?
  7. Pete

    Website localization

    I really like the idea of that site/tool, but I would still worry that a crowdsourced translation might not be accurate. It's weird though, as I've been working on a multi-language site recently (soon to be launched!) and would feel happy to receive translation help from our German members on the forums here, but I sort of feel like I know them more than a stranger translating my content from afar if you know what I mean? I don't know them that well, but there's a level of trust here between members - it's a nice feeling On the other side of the coin, you can always run a crowdsourced translation back through Google Translate and check that the message is generally the same. This doesn't always work with technical terms, but definitely helps to reassure you that nobody's dropped in any swear words or anything malicious. I think there might be times I would use the website you linked to, but they would be for community/group projects where it's a small team and they can't afford the translation service or don't have the skills in-house. For all other sites I would pretty much always recommend a professional service as there's some sort of Service Level Agreement in place so you have someone to shout at work things through with in a short space of time if the translation is wrong
  8. Welcome to ProcessWire dhamilton51! The general way people work with websites is to treat local and live copies of websites completely separately. This usually involves working on it locally first and then going live by uploading the finished/near-finished site to the live server. Is there a reason you want your local copy to talk to the live version's API? Are Martijn or I actually understanding what you're doing? I think with some more details we can certainly help you
  9. Pete

    I'm so stuck :(

    If you need any help, just let us know. Everyone here teaches everyone else something at some point
  10. Ah, cool. The cheatsheet says that "matches" matches the selector, whilst "is" matches template, status or selector. And for those that haven't read the Cheatsheet by now, here you go: http://cheatsheet.processwire.com/ Soma - I feel like we've just taught a class or something
  11. And for those that don't know, you can do this in ProcessWire if you want to match against multiple templates, like this: if ($page->matches('template=template1|template2|template3|template4')) { ... instead of this: if ($page->template == 'template1' || $page->template == 'template2' || $page->template == 'template3' || $page->template == 'template4') { ... Just thought that was worth sharing as I was typing it the long-hand PHP way just now and stopped myself before I wrote a lot of extra characters for no real reason! A shorter PHP alternative than above would be this: if (in_array($page->template, array('template1', 'template2', 'template3', 'template4')) { ... but I much prefer the ProcessWire version. $page->matches is a lovely thing that can be used to test the current page against any selector you can think of that makes sense in your situation.
  12. Fixed - just realised it as you were posting!
  13. Thanks again Soma, I feel like an idiot right now having the status as a string (not done it anywhere else in my modules so was just being blind ). All working now - for those interested, this is the final code: public function init() { $this->pages->addHookBefore('trash', $this, 'preservePages'); $this->pages->addHookBefore('delete', $this, 'preservePages'); } public function preservePages(HookEvent $event) { $page = $event->arguments[0]; if ($page->template == 'template-name') { $page->addStatus(Page::statusHidden); $page->save(); $event->replace = true; $this->message("The page was hidden instead of deleted. Pages using the '" . $page->template . "' template can be linked to other pages, so deleting is prohibited"); } } As you can see, much simpler after Soma's expert help. @Soma: I can't mark both your replies as the Solved post, so will have to mark this one with the full code if that's okay?
  14. Thanks Soma, my function is now a lot shorter. I just can't get it to save the page status as hidden now though - any ideas? Basically there is a chance of someone other than me having superuser privileges and I don't want them to tweak some settings and accidentally delete a page. Just trying to make it super-foolproof.
  15. Ah, but I can't change the page's status Doing this before the redirect doesn't save: $page->addStatus('Page::statusHidden'); $page->save(); Code is now as follows: public function ready() { $this->pages->addHookBefore('trash', $this, 'preservePages'); $this->pages->addHookBefore('delete', $this, 'preservePages'); } public function preservePages(HookEvent $event) { $page = $event->arguments[0]; if ($this->page->template = 'template-name') { $page->addStatus('Page::statusHidden'); $page->save();; $this->message('Page has been hidden instead of deleted - need to work on the wording'); $this->message("The page was hidden instead of deleted. Pages using the '" . $page->template . "' template can be linked to other pages, so deleting is prohibited"); $this->session->redirect('../'); } }
  16. Hmmm... it seems I can instead do this instead of returning false in my code above: $this->session->redirect('../'); This way it shows the message, prevents the action and returns the user to the page tree. Only problem then is if they move it via drag and drop in the tree and it breaks the JS a bit, but at least it prevents the action. I guess my new question is: "is there a better way?"
  17. I've got a requirement to prevent a page being trashed or deleted and instead hidden and show a message. Essentially what I want to do is, for given templates, prevent anyone from being able to delete the pages. A reasonably common example of this would be in e-commerce where you would never want to allow a product to be deleted if it has ever been ordered, otherwise the order details page would break (there is an argument there for storing a JSON array of ordered products in case the name ever changes, but we won't go into that just yet ). What I want to do is something like this: public function ready() { $this->pages->addHookBefore('trash', $this, 'preservePages'); $this->pages->addHookBefore('delete', $this, 'preservePages'); } public function preservePages(HookEvent $event) { $page = $event->arguments[0]; if ($this->page->template = 'template-name') { $page->addStatus(Page::statusHidden); $this->message('Page has been hidden instead of deleted - need to work on the wording'); // Then some way of stopping the trash or delete methods runnning, but can't think of what would work here return false; } } Any ideas? Oh, and I don't want to do it with access control for some reason I can't remember right now. That would be easy as I could just prevent users being able to delete the page
  18. Hi leftblank Unless I'm missing something (and I probably am to be honest ) you might be interested in what's covered by these pages: http://processwire.com/api/ EDIT: Now I've re-read your post I think I'm completely missing the point - never mind! Someone with experience with ORM might weigh in soon though.
  19. Nice one Soma. I was thinking of a more complicated solution earlier, so +1 for keeping it simple and effective as these notes only need to be written once per template by the person building the site really
  20. There are maybe a few slight margin/padding tweaks that might need making to main header in PW's main.css, but that's all I've found today and I've been working with it all day long.
  21. I had a need to output two sets of weather conditions. You can achieve this by simply passing the woeid before rendering the output like this: <?php $weather = $modules->get('MarkupWeather'); // Husum, Germany $weather->woeid = 24907; echo $weather->render(); // Kidderminster, England $weather->woeid = 663053; echo $weather->render(); I've got a few ideas for improving this module and might have a go at them when I get a sec: Allow for multiple locations in config Have the module install the output as a template in the site/templates folder (so future upgrades don't break any template changes) I think that's it really - other than that it's awesome
  22. I feel sure someone at Google has made a typo and they mean "characters" not "digits". As in: "an article title less than 3 characters won't be shown". What they've written in the bit you quoted just seems like nonsense to me given that you and ryan have mentioned that you both have articles showing fine in Google News now.
  23. I've just been playing with upgrading the Foundation 4 profile to version 5. Here are my extensive steps for anyone that wants to attempt them: Overwrite all the .js and .css files Change <nav class="top-bar"> to <nav class="top-bar" data-topbar> in _main.php Fin! The Orbit slider works fine, and I wholly approve of the updated styles as they seem more refined in v5. I think it helps that the ProcessWire Foundation profile doesn't use much more than the grid, Top Bar and Orbit so upgrading wasn't too tricky.
  24. ryan did once tell me a long time ago that, if they have at least one event per month, it's actually less intensive to just generate all months and years from a given start date to today with just PHP and not iterating through every single event (the way it's being approached above doesn't scale infinitely basically, but would be fine for most sites). What you could do is get the single event with teh date that's furthest in the future, then iterate through all the months and years between the current month and that event and create links for each month and year that way. EDIT: Silly me, you want to print all the event details anyway so this is irrelevant in this case, but useful to bear in mind for someone who might just want to have a menu for months and years that click through to an events list (or blog or some such thing where you might want to have links to all past years etc with potentially thousands of pages behind them). But yeah, not relevant in this case at all!
×
×
  • Create New...