-
Posts
37 -
Joined
-
Last visited
Everything posted by ffub
-
@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. Stephen
-
I just ran into this problem. You can edit the .htaccess file robustly like so to catch every instance of this: # ----------------------------------------------------------------------------------------------- # ProcessWire requires mod_rewrite # ----------------------------------------------------------------------------------------------- <IfModule mod_rewrite.c> RewriteEngine On # ----------------------------------------------------------------------------------------------- # Reset directory prefix for mass virtual hosting # ----------------------------------------------------------------------------------------------- <IfModule mod_vhost_alias.c> RewriteBase / </IfModule>
-
This module looks like exactly what I need for migrating a couple of larger sites to PW. Would it be possible to hack this for adding users as well? Thanks, Stephen
-
Thanks for the feedback everyone. I hope it can be useful. As I said above, the module is still lacking support for times. I'd be curious to know how others are storing events - whether you are using a single field for date and time, or whether you are storing time separately and taking its absence to mean all-day? The main reason I can see for having it as a separate field is it leaves the date picker to work it's magic and thus makes adding events fairly painless for the user. mjmurphy: You are right to point out that the webcal: uri is informally used to denote iCal feeds. You can do this with the links in my examples above. While the [tt]->render[/tt] method will send the page as a download when accessed directly, I've tried it out with iCal and Google Calendar and it works just fine as a feed. If you wish to use the feed differently, such as sending different headers then [tt]->renderFeed[/tt] will let you do that. In addition to your suggested webcal:// link I tend to add Google Calendar links as many people use this now. Here's an example: <?php $gcalLink = urlencode($pages->get("/")->httpUrl . "events/ical"); echo "<a href='webcal://{$config->httpHost}/events/ical'>Subscribe to Calendar</a><br/>"; echo "<a href='https://www.google.com/calendar/render?cid=$gcalLink'>Add to Google Calendar</a>"; Thanks, Stephen
-
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. Stephen
-
Thanks for your excellent help, Ryan. I tracked down the problem in the end - the user I was testing this with did not have an email set so the comment was not added. Nevertheless, your feedback was really useful and I am refreshing the session as you described. Thanks, Stephen
-
That's the odd thing - I don't get any error messages, even with debug on. I tried your suggestion about hiding ouput before save but it had no effect. Additionally I'm running the latest 2.1 and both the methods [tt]$page->comments->add()[/tt] and [tt]$page->save()[/tt] return true. Stephen
-
Hi, I am trying to add comments for my site using my own custom form and the API. I was unable to create the form I desired using the inbuilt comment form and further more I only want commenting to be available to registered users. As such the cite and email fields are not so important to me and can be hidden and pre-populated. Below is the code I have been trying to get to work but so far I cannot get it to save the comments to the system. <?php foreach ($page->comments as $comment) { if ($comment->status < 1) continue; // skip unapproved or spam comments $cite = $users->get($comment->created_users_id)->name; // make sure output is entity encoded $text = htmlentities($comment->text); $date = date('m/d/y g:ia', $comment->created); // format the date echo "<div class='comment'>"; echo "<div class='comment-cite'><b>$cite</b> $date</div>"; echo "<div class='comment-body'>{$text}</div>"; echo "</div>"; } if ($user->isLoggedin()) { // Process submitted comments if ($input->post->submit) { $c = new Comment(); $c->text = $sanitizer->textarea($input->post['text']); $c->cite = $sanitizer->name($input->post['name']); $c->created = time(); $c->email = $sanitizer->email($input->post['email']); $c->user_agent = $_SERVER['HTTP_USER_AGENT']; $c->ip = $_SERVER['REMOTE_ADDR']; $c->created_users_id = $user->id; $c->sort = count($page->comments)+1; // set status (Spam = -2; Pending = 0; Approved = 1; ) $c->status = 1; // add new comment object to the page "comments" field $page->comments->add($c); $page->save('comments'); } ?> <div class="comments-add"> <form action="./" method="post"> <input type='hidden' name='cite' value='<?=$user->name?>' /> <input type='hidden' name='email' value='<?=$user->email?>' /> <input type='hidden' name='page_id' value='<?=$page->id?>' /> <textarea name="text" placeholder="Add a comment"></textarea> <input type="submit" name="submit" value="Add" /> </form> </div> <?php } else { echo "<div class='comments-add'>"; echo "<p>You need to be <a class='login-link' href='/login/?ref={$page->url}'>logged in</a> to add a comment</p>"; echo "</div>"; } ?> Any recommendation on where I am going wrong would be appreciated. Thanks, Stephen
-
Oh superb! I hadn't noticed it tucked in the filter box, my mistake. Thanks a lot!
-
Are there any plans to have show an interface for custom fields in the backend in 2.1? Perhaps list the user/role template in the templates screen but have it locked to avoid deletion. They you can add fields as per other templates and show these on the user edit screen.
-
Many thanks for your swift and detailed reply , Ryan. With a couple of minor changes your code works fine. I have to check the count was above 0, and pass the starttime into $date. This is what worked for me: <?php $channel = $pages->get("/news/"); $startYear = date("Y"); // this year $endYear = 2009; // or whenever you want it to end $now = time(); for($year = $startYear; $year >= $endYear; $year--) { for($month = 12; $month > 0; $month--) { $startTime = strtotime("$year-$month-01"); // 2011-12-01 example if($startTime > $now) continue; // don't bother with future dates if($month == 12) $endTime = strtotime(($year+1) . "-01-01"); else $endTime = strtotime("$year-" . ($month+1) . "-01"); $entries = $channel->children("created>=$startTime, created<$endTime"); // or substitute your own date field $date = date("F, Y",$startTime); $url = "/news/" . date("Y",$startTime) . "/" . date("m",$startTime); $count = count($entries); if($count > 0) echo "<li><a href='$url'>$date <b>" . $count . "</b></a></li>"; // output the month and count } }
-
Hi, I'm loving ProcessWire and the freedom it allows. Most of my sites are fairly hierarchical and a great fit for the tree model of ProcessWire (which I tend to think of like the DOM in HTML). Most of my sites also feature a blog or news section though and it's these bucket-like sections I'm struggling with. I tend to just place all the entries under a page, and use index and story templates to display them. In a previous topic you describe a way of filtering by date or another field. I would like however to create some indexes of these fields themselves rather than listing the actual posts. This would be very useful for creating an archives page, a list of tags or some archive links in the sidebar but I'm not sure how to query the tree in this manner. For example, how would I go about creating the following: Many thanks, Stephen