Skip to main content
 

Let's all turn off on-site commenting, and allow replies via moderated trackback. Anyone can start a blog and participate with increased civility and ownership. DONE.<p>#status </p>

 

Enum label lookup

In your datamodel you might have a Enum field such as this date-based dropdown:

public static $db = array(
    "Year"        => "Enum('2013, 2014, 2015')"
}

Internally, SilverStripe stores the index, so that when you retrieve the value in methods such as onBeforeWrite, instead of 2013 you will receive 1. Use the function below to retrieve the label of the Enum:

public function EnumLabel($field_name) {
    $enumValues = $this->dbObject($field_name)->enumValues();
    $label    = $enumValues[$this->$field_name];
    return $label;
}

// $year = $this->EnumLabel('Year');

 

LessThanOrEqual in SilverStripe 3.0

When adding a filter on a DataList sometimes you need to do a <= rather than a <. Unfortunately the LessThanOrEqual and GreatherThanOrEqual search filters do not exist in SilverStripe 3.0.x, they were added in 3.1.

Therefore we have to write our own where clause like the following example:

// Return all the sessions on or before the $date
$sessions = new DataList('AcademicSession');
$sessions = $sessions->where('"SessionStartDate" <= \'' . $date . '\'');

 

Ad tech is killing the online experience

Apple blogger John Gruber started off a new debate about these issues recently, when he noted that a 537-word text post on the website iMore.com weighed in at 14 megabytes. (Fourteen megabytes of text should correspond to about 7m words, or about 10 times the combined length of the Old and New Testaments.)

Gruber blamed iMore.com, but really it’s not the website’s fault, since to a very large degree the owner of the website you’re visiting doesn’t actually control what you see, when you see it, how you see it, or even whether you see it. Instead, there are dozens of links in the advertising-technology chain, and every single one of them is optimising for financial value, rather than low-bandwidth user experience. Many pages, if you’re on a slow connection, simply time out; they never load at all.

When you are a website owner, you are responsible for all the content on your site. If you don't have any control over the ads, then that's a process issue that should be addressed.

Why not band together with a few large sites and create a standardised ad submission and review system that advertisers can integrate into their content tools and websites can set criteria about ads on their sites.

Maybe the bigger problem is that those websites cannot afford to reject ads.

 

App.net is now receiving snippets from my site. ?<p>#status </p>

 

"the best of the year of high quality of life and the other hand is the only thing that would have to go back."<p>#status </p>

 

Open a new note, enter the first word, then keep pressing the text suggestions button and see what stream of consciousness erupts.<p>#status </p>

 

Tip: keep a list of domains covered by security certificates and their expiry dates.<p>#status </p>

 

BugzScoutLogWriter 1.0

I've released another SilverStripe add-on called BugzScoutLogWriter that I have been using for several months on some of the sites at work.It supports SS 3.0 and 3.1.

BugzScoutLogWriter is a LogWriter that integrates logs with FogBugz, an integrated web-based project management system featuring bug/issue tracking made by FogCreek.

A LogWriter is attached to errors, warnings and notices that occur in a website due to programming errors or runtime errors and then sends / saves a log of this event. SilverStripe comes with built-in functionality to e-mail or save the logs to a file, however if you use a third party bug reporting system then it's nice to have all the issues collected there instead.

I've used FogBugz for years now and one of the nice features is that multiple occurrences of the same issue get collected in the same ticket. This keeps the whole process manageable. Say, in the event that a mistake that affects all pages on a website, FogBugz collects the first 50 occurrences of that error and lets you close the ticket with one click. This is an improvement to a flood of email.

Anyways let me know if you find it useful and feel free to raise issues.

 

Tip: disable IFTT URL shorthening via account > preferences > URL Shorthening to post meaningful URLs to Twitter et al.<p>#status </p>

 

How to provide and manage your own permissions

At some point on your journey through the jungle that is SilverStripe, you will want to create permissions and assign users to them. You might have created a Page Category model admin to categorise your pages, and setup the relations between pages and their category. By default when you create a category as an admin they will not be visible to any content authors and any content authors that can access the model admin can't create any new items.

The solution to this dilemma is to create a new permission (for example PROJECT_CategoryAdmin) and then let people with that permission mange the category items. This is how to go about it:

Create the permission

You will need to tell SilverStripe you are implementing permission by changing the class declaration as follows (changes in bold):

class Category extends DataObject implements PermissionProvider

To create the new permission you will have to write a providePermissions() method for the Category class:

      public function providePermissions() {
        return array(
            "PROJECT_CategoryAdmin" => array(
                'name' => 'Administer categories',
                'category' => 'PROJECT',
                'help' => 'Manage categories.'
            )
        );
    }

Finally, implement the permission by declaring the canCreate, canDelete, canEdit and canView methods to your liking:

    public function canCreate($member = null) {
        return Permission::check('PROJECT_CategoryAdmin');
    }

    public function canDelete($member = null) {
        return Permission::check('PROJECT_CategoryAdmin');
    }

    public function canEdit($member = null) {
        return Permission::check('PROJECT_CategoryAdmin');
    }

    public function canView($member = null) {
        return Permission::check('PROJECT_CategoryAdmin') ;
    }

Don't forget to create a Role and/or assign the permission to the right Group(s), to make sure the right users can manage your categories.

 

Security through insecurity

Schneier explained how, initially, NSA Director General Keith Alexander claimed in 2013 that he had disrupted 54 terrorists plots. A few months later, this was revised down to 13, and then to "one or two." Eventually, the only success that the NSA could point to was the prevention of a San Diego man sending $8,500 to support a Somali militant group.

Doesn't sound like a worthy trade-off.

 

Resolve Conflicted Files That Don't Exist

Download VisualSvn Server, open a command prompt and type svn resolved -R . to resolve all conflicts, then commit again.

 

The more I think about modern blogging; the more I think the out of the box concept WordPress et al presents us is outdated.<p>#status </p>

 

Am totally into CSS backgrounds with partial transparent color overlay in the element above. Nicely ties the palette together.<p>#status </p>

 

Slack users: do you setup channels per project or per content type (build; errors)?<p>#status </p>

 

Interrupting ads are as bad in games as they are on websites.<p>#status </p>

 

Experiencing "Slack and the case of the missing emails"<p>#status </p>

 

Updated my microblogging .htaccess gist so if you used that yesterday please try again.<p>#status </p>

 

Microblogging with WordPress and Twitter

Manton Reece has been having very interesting discussions about microblogging and content ownership recently. He's working on an unannounced project in this area and I've been following his progress.

A few days ago he wrote a post about Microblogging with Wordpress in which he describes most of the process of writing your status updates on your own blog first. As I had to adapt his process for it to work with my configuration of WordPress and as I am using Twitter instead of App.net I thought it would be useful to detail how I went about, based on Manton's write-up.

Requirements

  • A theme that supports post-formats.
  • an IFTTT and Twitter account.
  • A self-hosted WordPress installation, hosted using Apache.
  • (optionally) the DoNote app from IFTTT for your mobile device.

Step 1: Link a status updates feed to Twitter

In order to post only the status updates to twitter, we have to identify them in both WordPress and for IFTTT.

Create a dedicated category

In Wordpress, if you do not have a category for status updates, create a Snippets category (with the slug snippets). Note the category ID. In addition, create a new category called ifttt-status if you plan to post to Wordpresss from your mobile device later, as I did (this is a workaround to allow WordPress to convert from this category to the status post format).

Setup the RSS feed endpoints

With the category ID, we can now create a new feed by editing the .htaccess file in your WordPress installation directory, see my gist comment on manton's configuration. I had redirection issues with Manton's original setup so I amended it. What we do here is create two endpoints, one for posts without status updates (rss.xml); and one for only status updates (snippets.xml). We then point any requests to /feed (the default WordPress endpoint) to the first endpoint.

Update (26 June): I updated the gist comment after identifying issues in initial configuration. Please reread the gist if you had problems using the initial configuration.

Post new status updates to Twitter

Now create a new recipe that is triggered from the snippets RSS feed, with the action to post a tweet with the tweet text EntryContent.

You can now blog from WordPress to twitter (just leave the title empty).

Step 2: Post status updates from your mobile device

I'm using DoNote to post to IFTTT which then posts to WordPress.

Setup WordPress

Login to your WordPress blog and in the users section create a ifttt user with the role of Author (this allows the user to create posts).

Install the "IFTTT Post Formats & Post Types" plugin, it will convert posts with the ifttt-status category to the status post-format. It will also hide the ifttt-status category from showing up in your template for example.

Link DoNote to WordPress using IFTTT

Back in IFTTT, In the My Recipe's DoNote section, create a new recipe for WordPress (you might get asked to provide the WordPress username and password you created for this purpose) with the action to create a post with the following values:

  • Title: (leave empty)
  • Body: NoteText
  • Categories: Snippets,ifttt-status
  • Tags: (leave empty)
  • Post status: Publish immediately

You are not limited to using DoNote if there is a trigger for your service, and you are not limited to usin IFTTT at all if there are WordPress plugins for your status update service and WordPress support for your writing app, but these will require similar configuration as detailed in this post.

Hope this helps!