diff --git a/source/_posts/2012-07-14-install-nomensa-media-player-drupal.md b/source/_posts/2012-07-14-install-nomensa-media-player-drupal.md new file mode 100644 index 00000000..c71157d9 --- /dev/null +++ b/source/_posts/2012-07-14-install-nomensa-media-player-drupal.md @@ -0,0 +1,58 @@ +--- +title: Install and Configure the Nomensa Accessible Media Player in Drupal +slug: install-nomensa-media-player-drupal +tags: + - Accessibility + - Drupal + - Drupal Planet + - Nomensa +--- +*The official documentation for this module is now located at . This post was accurate at the time of writing, whereas the documentation page will be kept up to date with any future changes.* + +This week I released the first version of the Nomensa Accessible Media Player module for Drupal 7. Here's some instructions of how to install and configure it. + +## Initial configuration + +### Download the Library + +The library can be downloaded directly from GitHub, and should be placed within you *sites/all/libraries/nomensa_amp* directory. + +~~~~ +drush dl libraries nomensa_amp +git clone https://github.com/nomensa/Accessible-Media-Player sites/all/libraries/nomensa_amp +cd sites/all/libraries/nomensa_amp +rm -rf Accessible-media-player_2.0_documentation.pdf example/ README.md +drush en -y nomensa_amp +~~~~ + +### Configure the Module + +Configure the module at admin/config/media/nomensa-amp and enable the players that you want to use. + +## Adding videos + +Within your content add links to your videos. For example: + +### YouTube + + Checking colour contrast + +### Vimeo + + Screen readers are strange, when you're a stranger by Leonie Watson + +## Adding captions + +The best way that I can suggest to do this is to use a File field to upload your captions file: + +1. Add a File field to your content type; +2. On your page upload the captions file. +3. Right-click the uploaded file, copy the link location, and use this for the path to your captions file. + +For example: + + Checking colour contrast Captions for Checking Colour Contrast + +## Screencast + +Nomensa Accessible Media Player for Drupal \ No newline at end of file diff --git a/source/_posts/2013-01-09-checking-if-user-logged-drupal-right-way.md b/source/_posts/2013-01-09-checking-if-user-logged-drupal-right-way.md new file mode 100644 index 00000000..53981f38 --- /dev/null +++ b/source/_posts/2013-01-09-checking-if-user-logged-drupal-right-way.md @@ -0,0 +1,56 @@ +--- +title: Checking if a user is logged into Drupal (the right way) +description: How to check if a user is logged into Drupal by using the user_is_logged_in() and user_is_anonymous() functions. +tags: + - Drupal + - Drupal 6 + - Drupal 7 + - Drupal Planet + - PHP +--- +I see this regularly when working on Drupal sites when someone wants to check whether the current user is logged in to Drupal (authenticated) or not (anonymous): + +~~~~ +global $user; +if ($user->uid) { + // The user is logged in. +} +~~~~ + +or + +~~~~ +global $user; +if (!$user->uid) { + // The user is not logged in. +} +~~~~ + +The better way to do this is to use the [user_is_logged_in()](http://api.drupal.org/api/drupal/modules!user!user.module/function/user_is_logged_in/7) function. + +~~~~ +if (user_is_logged_in()) { + // Do something. +} +~~~~ + +This returns a boolean (TRUE or FALSE) depending or not the user is logged in. Essentially, it does the same thing as the first example, but there's no need to load the global variable. + +A great use case for this is within a `hook_menu()` implementation within a custom module. + +~~~~ +/** + * Implements hook_menu(). + */ +function mymodule_menu() { + $items['foo'] = array( + 'title' => 'Foo', + 'page callback' => 'mymodule_foo', + 'access callback' => 'user_is_logged_in', + ); + + return $items; +} +~~~~ + +There is also a [user_is_anonymous()](http://api.drupal.org/api/drupal/modules!user!user.module/function/user_is_anonymous/7) function if you want the opposite result. Both of these functions are available in Drupal 6 and higher. \ No newline at end of file diff --git a/source/_posts/2013-11-19-dont-bootstrap-drupal-use-drush.md b/source/_posts/2013-11-19-dont-bootstrap-drupal-use-drush.md new file mode 100644 index 00000000..9d973f70 --- /dev/null +++ b/source/_posts/2013-11-19-dont-bootstrap-drupal-use-drush.md @@ -0,0 +1,46 @@ +--- +title: Don't Bootstrap Drupal, Use Drush +tags: + - Drush + - Drupal Planet + - PHP +--- +There are times when doing Drupal development when you need to run a custom PHP script, maybe moving data from one field to another, that doesn't warrant the time and effort to create a custom module. In this scenario, it would be quicker to write a .php script and bootstrap Drupal to gain access to functions like `node_load()` and `db_query()`. + +To bootstrap Drupal, you would need to add some additional lines of code to the stop of your script. Something like: + +~~~php + This is useful in case where you do not want email sent from a Drupal site to reach the users. For example, if you copy a live site to a test site for the purpose of development, and you do not want any email sent to real users of the original site. Or you want to check the emails sent for uniform formatting, footers, ...etc. + +As we don't need the module configured on production (we don't need to reroute any emails there), it's best to do this in code using settings.local.php (if you have one) or the standard settings.php file. + +The first thing that we need to do is to enable rerouting. Without doing this, nothing will happen. + +~~~php +$conf['reroute_email_enable'] = TRUE; +~~~ + +The next option is to whether to show rerouting description in mail body. I usually have this enabled. Set this to TRUE or FALSE depending on your preference. + +~~~php +$conf['reroute_email_enable_message'] = TRUE; +~~~ + +The last setting is the email address to use. If you're entering a single address, you can add it as a simple string. + +~~~php +$conf['reroute_email_address'] = 'person1@example.com'; +~~~ + +In this example, all emails from the site will be rerouted to person1@example.com. + +If you want to add multiple addresses, these should be added in a semicolon-delimited list. Whilst you could add these also as a string, I prefer to use an array of addresses and the `implode()` function. + +~~~php +$conf['reroute_email_address'] = implode(';', array( + 'person1@example.com', + 'person2@example.com', + 'person3@example.com', +)); +~~~ + +In this example, person2@example.com and person3@example.com would receive their emails from the site as normal. Any emails to addresses not in the array would continue to be redirected to person1@example.com. \ No newline at end of file