Leaderboard
Popular Content
Showing content with the highest reputation on 06/06/2012 in all areas
-
This should do it (cleaned from other module, so not sure if this works without fixing, but idea should be pretty clear): <?php class Elections extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Elections', 'version' => 101, 'summary' => 'Simple module to demonstrate how to automatically create subpages.', 'singular' => true, 'autoload' => true, ); } public function init() { // add a hook after the $pages->save $this->pages->addHookAfter('save', $this, 'afterPageSave'); } public function afterPageSave($event) { $page = $event->arguments[0]; // We want to create subpage only when using if ($page->template == 'election' && $page->numChildren == 0) { $p = new Page(); $p->template = $this->templates->get("candidates"); $p->parent = $page; $p->title = "Candidates"; $p->sortfield = wire('fields')->get('v_candidate_number'); $p->save(); $p2 = new Page(); $p2->template = $this->templates->get("votes"); $p2->parent = $page; $p2->title = "Votes"; $p2->save(); $this->message("New election created."); } } }2 points
-
Hi guys, I've been doing events sections for a few sites and for each I needed to make an iCal feed. I've wrapped up this functionality into a module now to make it a little easier for myself and anyone else that needs to make these feeds. The module is basically a simple wrapper around the iCalcreator library (a copy is included). It's modelled on the MarkupRSS module from Ryan, so anyone familiar with that should have a feed up and running in no time. Usage The module takes a PageArray and creates the feed from that. The [tt]->render[/tt] method will send the output to the browser with a generated filename and will automatically download. Because it will return HTTP headers, it has to be included before any html and is best in its own template or followed up by [tt]exit;[/tt] <?php $today = time(); $items = $pages->find("template=event, sort=start_date, start_date>$today"); $ics = $modules->get("MarkupiCalendar"); $ics->title = "Upcoming Events"; $ics->description = "Some upcoming events"; $ics->itemStartDateField = 'start_date'; $ics->itemEndDateField = 'end_date'; $ics->itemLocationField = 'location'; $ics->render($items); You can use the [tt]->renderFeed[/tt] method to return the output as a string instead, which is particularly useful if you want to debug or write the output to a file. <?php $today = time(); $items = $pages->find("template=event, sort=start_date, start_date>$today"); $ics = $modules->get("MarkupiCalendar"); $ics->title = "Upcoming Events"; $ics->description = "Some upcoming events"; $ics->itemStartDateField = 'start_date'; $ics->itemEndDateField = 'end_date'; $ics->itemLocationField = 'location'; $cal = $ics->renderFeed($items); echo $cal; I often put RSS and iCal feeds at the top of my listing pages so as not to clutter up the site tree with extra templates. This way /events/ may point to my events page, and /events/ical will point to it's feed. Here is an example: <?php // iCal feed if ($input->urlSegment1 == "ical") { $today = time(); $items = $page->children("sort=start_date, start_date>$today"); $ics = $modules->get("MarkupiCalendar"); $ics->title = "Upcoming Events"; $ics->description = "Upcoming events for my company"; $ics->itemStartDateField = 'start_date'; $ics->itemEndDateField = 'end_date'; $ics->itemLocationField = 'location'; $ics->url = $page->httpUrl; $ics->render($items); exit; } // Render the template as normal. include("./includes/head.inc"); Download and feedback You can download or fork the module here: https://github.com/f...MarkupiCalendar At the moment it only supports all day events (as these are all I have dealt with) but I hope to add time based events soon. Any feedback is warmly appreciated and feel free to report bugs or suggestions for improvement. Stephen1 point
-
Here is the module Just install it and create a page as child of "admin" with the "admin" template, and assign the process "ProcessCommentsList" to it. Edit: changed some details on the module Edit2: added some options to the module settings Edit3: updated the module with some changes suggested by Ryan Edit4: minor change -- replaced the word "Sentence" by "Message" on the options Edit5: No need for a title when outputting the link to the page. If it is not there, the name is used instead ProcessCommentsList.module1 point
-
See, this is what I love about ProcessWire. I was just in a meeting, and the question came up whether it was possible to export a list of events and dates as a calender, i.e. in iCal format. I wasn't sure about it, but I took a wild guess that there would be some way to do this. Back at home, checked the modules page, BAM, there you go. For someone like me who is not able to do "real" PHP coding, this is a life saver. Thank you so much.1 point
-
You can easily list all pages that have pending comments and link to their admin pages like this: foreach ($pages->find("comments.status=0") as $c){ // status 0 means pending echo "<li><a target='_blank' href='{$config->urls->admin}page/edit/?id={$c->id}'>{$c->title}</a></li>"; } If I have time tomorrow, I can try to make a process module with this, so you can have the list on an admin page.1 point
-
I quickly looked into it and created an additional hook for what you might after. There's my other already created ones you can also test and comment it if not needed. It's a snippet I just posted here https://gist.github.com/2878361 Uncomment unwanted hooks int he init() method of the module. The third hook... $this->addHookAfter("InputfieldPageListSelect::render", $this, "findRelated"); does look for any pages that has the current edited page selected in a page select field. You can specify what field you want to attach it in the function findRelated(): $field_filter = "select_architect"; Let me know if it works for you.1 point
-
Just went through this old thread and noticed that there's no link or note here that there is a module for this already. I created the PageEditSoftLock module for this particular problem, with a little help of Ryan to get easy starting. I got it installed in all our PW projects and it won't lock the page completely (still editable) but throw a fat red message and a js alert. It workes very well and has been a saver already a couple times preventing two people editing the same page. It has been released here: http://processwire.c...edit-soft-lock/1 point
-
Made a little update to this module. I strongly encourage to update with the latest version. - unfortunately it stoped working in the latest PW since script/css version (..script.js?v=100) in the admin were introduced (1,5 months?). Since I have to manually str_replace the script tag into the header right after jquery core js, it failed because the string is now different :/. Changed it to use replace on another location/part of the code which will hopefully stay there. - added the admin root path to the script url, so it now also works on PW installed in a subdir. - added script versioning appended to file name ..?v=101.1 point
-
Ryan, yes! Doh, I also had forgotten/missed the button 'Save + Keep Unpublished'. I'll go edit my original post. Thanks for putting me straight1 point
-
The audience for making Process modules is small enough that time for documentation is getting put towards broader scope stuff first. I think there might just be 4-5 of us that have an interest in making Process modules. But this will be in the documentation at some point, especially as interest for it grows.1 point
-
Hey rob. What diogo said. You can create a admin page using the "admin" template. It would be placed under the locked "admin" page tree. The admin template has a field "Process". After creating the page you'll see it under tab "content". Now you have to create a process module to serve functionality for the newly created admin page. Once installed it can be selected from the field "Process". I did a quick example that shows such a module, and even how to use the ProcessPageList module of processwire to create a tree. The id set will be the parent page (your Architects) for example. ProcessPageListCustom.module create the module under /site/modules/ and install it. <?php class ProcessPageListCustom extends Process{ public static function getModuleInfo() { return array( 'title' => 'Custom Page List', 'summary' => 'List pages in a hierarchal tree structure', 'version' => 100, 'permission' => 'page-edit' ); } public function execute(){ $pl = $this->modules->get("ProcessPageList"); $pl->set('id',1001); // or any other parent page return $pl->execute(); } } You can, of course, use any code to generate a list of pages.1 point
-
@ryan I realise that unix timestamps include a time as well, but this seems to confuse Google Calendar somewhat as multiple day events where I had not specified a time seemed to begin at 1 in the morning. It may well be something to do with the timezone and/or daylight savings though. I've not had time to debug this so for the sake of ease I am passing the events as dates rather than timestamps, eg: CREATED:20111005T020915Z DTSTART;VALUE=DATE:20111028 I used Google Calendar originally on my sites and I really love it. I was pulling the events in via an RSS feed. I will definitely be interested in your new module for my simpler sites now. @mjmurphy It's actually from the UX perspective that I have suggested having separate time fields. The datepicker lets you pick a date with relative ease and you can manually amend a time to that. This is a bit confusing for users though. Also, changing the date with the date picker, seems to remove the time. I encourage my users to stick to the jQuery UI picker as we are used to writing d/m/Y here in the UK, which is indistinguishable from m/d/Y to PHP. No amount of prodding or helpful reminders seems to make entering in a different format (such as Y-m-d) stick for them. Your date picker changes look like a very good solution to this problem for me though! I have considered making a new dates InputType/FieldType for events that more closely mimics Google's excellent one to tackle some of these problems (see attachments). I'm not entirely sure how to go about that though. Aside from date entry, having events in PW is a doddle and presents some great possibilities in terms of linking them with other aspects of a site or providing more than a summary for each event (bookings!). I would strongly suggest anyone else working on events to check out fullCalendar, a great little jQuery plugin. I pass my events to this with a simple JSON feed in order to make a scrollable calendar widget. Stephen1 point