-
Posts
4,033 -
Joined
-
Last visited
-
Days Won
66
Everything posted by Pete
-
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.
-
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('../'); } }
-
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?"
-
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
-
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.
- 4 replies
-
- data capture
- ORM
-
(and 1 more)
Tagged with:
-
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
-
Insert Link Module (TinyMCE) with "Link to Page" language support
Pete replied to Relmos's topic in Multi-Language Support
You being the author? -
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.
-
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
-
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.
- 14 replies
-
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.
-
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!
-
Resurrecting this slightly, but I did something along these lines just now with help from this thread (actually approached it netcarver's suggested way from the first post). It's one where I wanted to skip the first page of adding a name (for events in a calendar) but didn't want to use a repeater - which would achieve the same, but I wanted separate pages. Code as follows: In init function: $this->pages->addHookBefore('ProcessPageAdd::execute', $this, 'generateName'); The function that does the work (specific to my case): public function generateName() { if ($this->input->get->parent_id == 1019) { // 1019 = some page where we want to auto-generate child page names $page = new Page(); $page->parent = $this->input->get->parent_id; $page->name = $this->pages->get($this->input->get->parent_id)->count()+1; $page->template = 'child-template-name'; $page->addStatus(Page::statusUnpublished); $page->save(); $this->session->redirect("../edit/?id=$page"); } } So it checks we're creating a page under a certain parent, sets the right template, creates a page using an integer as the name based on the count of pages under the parent page and then takes you to the edit form for that page. The beauty of it is that since there has been no title entered so far, the user has to fill out the page fields - well title at least - to continue. So why did I do something so convoluted here? Because for what I'm using the title field for I needed to allow duplicate titles, so different names is key to this. The individual pages themselves will never be visited - they're just being pulled into a table into the parent page. Of course I could have used repeaters, but on this occasion I didn't want to. I think that with a little work, and the addition of multiple config lines like in my ProcessEmailToPage module you could expand this to monitor certain parent pages, hook into new page creation and create the page with a specific child template nice and neatly instead of hardcoding it as above. When I get time I might just do that... which might not be any time soon For now the above code works though for anyone wanting to adapt it to do something similar.
-
Insert Link Module (TinyMCE) with "Link to Page" language support
Pete replied to Relmos's topic in Multi-Language Support
I've updated the CKEditor plugin to work for multiple languages too. Embarassingly I've forgotten how to do a pull request for someone else's repo on Github, so here's the changed .js file - just put it in site\modules\InputfieldCKEditor\ckeditor-4.2.0\plugins\pwlink It's largely based on Soma's code but altered marginally for CKEditor. plugin.zip -
Love it, looks like it was a perfect match for ProcessWire (as in I can see how everything would work, like staring at The Matrix when browsing the site ). I look forward to reading the case study
-
Alert is good - turns out with an update to another CMS a while ago there were too many sites that I had to update, whereas if it had been a scheduled part of my monthly checks then it would have felt less onerous. Of course if I switched them all to ProcessWire I'd also be fine But alert is good even with PW.
-
Yep, but Wordpress wouldn't put his name, they'd put Automattic Inc. instead as that's the company behind it isn't it? That's the point I was trying to make, badly It seems now that I've re-read some of the earlier posts in this topic that it must stay as it is for now or until ryan gets some clarification from a legal perspective. The reasoning for leaving the ProcessWire name in plain view though is clear - whilst a client's next developer (should their current developer vanish) can see what the system is built in from the license files and so on in the installation folder, most clients wouldn't know they're there. Having something in plain sight enables them to get help from here if something goes wrong - this has in fact already happened once I think where a client has parted ways with their dev and come here for help, so we know it works and it helpful. I very much doubt there would be anything wrong with expanding upon the copyright line though by doing something like this, which clarifies things nicely: ProcessWire 2.3.5 © 2013 Ryan Cramer | Website designed and developed by YourCompany I daresay you could even prepend the words "Built with..." to that as well for even more clarity.
-
There's obviously merit to using newer versions of PHP and it would be nice to force hosts to be more up to date as this would in turn force software devs to keep up to date, as many already do, but I'm just not sure it would catch on. That said, it would probably only take a few of the more commonly-used programs like WordPress to push this and I could see it happening, definitely. I'd rather see it as a group effort though, with many devs throwing their hats into the ring and everyone getting a more equal share of the kudos surrounding the initiative, even if you do have to tout some big names to get some momentum.
-
Tackling a small part of what has been discussed first, I don't think white-labelling completely is a good idea at this stage. Wordpress has a very strong identity with their admin, and anyone who has used it would know what they were using without the branding unless they were using some really fancy admin themes. Whilst a system is still growing in popularity and can benefit from the simply line of text and the link back to the website I personally think it should remain. Wordpress, depending on the version, has one or more links in the footer linking back to the website just with the software name. MODx is managed under the company name "MODX Systems, LLC" so it's a bit easier for them to simply list "MODx" in their footer. ProcessWire is by "Ryan Cramer Design, LLC" (with many developers/contributors) but it would be confusing to have the full "Ryan Cramer Design" bit in the admin footer ("who designed the website?" might be what the client then asks ). Rather than me speculating further as to reasons why ryan has his name there it's probably best to wait for him to answer of course. All in all though, since I started this thread back when I'd been using ProcessWire for just a few months, I've not once come across a client who got confused by it nor have I noticed anyone else seeing it as a restriction. Obviously it would be interesting to see what ryan says, but I wouldn't see it as a show-stopper either way and I don't think other people do either or we'd probably hear a lot more concerns over it
-
Short of murder, pretty much anything, yes.
-
Yay! Joss is back! It just.... <sniff> wasn't the same without you
-
I'm really confused by what you're trying to do - why would the page ever be saved before the user clicks save? If you could post a few bullet points explaining what the user will experience whilst filling out this form it might help us come up with a suggestion. Other than that there are many topics here how to save the page (http://processwire.com/talk/topic/352-creating-pages-via-api/ ) but you appear to be talking about everything up to that point which I would have thought would just be the job of a normal form?
-
Well Evo is the "older" version anyway (Revo technically replaces is, but many users preferred Evo), but it's also not like PHP 5.5 is going to be mainstream for a while. Not making excuses, but that won't be a huge problem for many people just now pwired.
-
Cheers teppo - good spot! I... bumped that other topic
-
http://processwire.com/talk/topic/4812-field-names-using-arrays/ *whistles nonchalantly, hands in pockets, walking away from the topic*