Skip to main content

Get the Aegir Platform path when editing a vhost

I was setting up a static mobile website for a Drupal site that was installed within the Aegir hosting environment today. We had been given a static mobile version of the website to load. So, we added the mobile site to a directory within our theme and we needed to setup an alias for this site. To accomplish this we created a new mysite.drush.inc file within the .drush folder and added the following code:

  1. function MYSITE_provision_apache_vhost_config($uri, $data) {
  2.   if ($uri == '<a href="http://www.MYSITE.com&#039">www.MYSITE.com&#039</a>;){
  3.     $mobile_path = d()->site_path . '/themes/MY-THEME-PATH/mobile-directory';
  4.  
  5.     return array(
  6.       '',
  7.       '# Mobile site alias setup',
  8.       '',
  9.       'Alias /mobile-site ' . $mobile_path,
  10.       '',
  11.       '<Directory ' . $mobile_path . '>',
  12.       '  DirectoryIndex index.php',
  13.       '</Directory>',
  14.       '',
  15.       '# End mobile site alias',  
  16.     );
  17.   }
  18. }

The key here is the  d()->site_path which will return the platform path that the current site is installed in. So, we won't need to update this whenever the platform changes.

References:
- http://community.aegirproject.org/dev-cheat-sheet


Comments