Remote Files Framework Readme Remote File Browser
This fieldtype allows you to have a Rackspace Cloud Files, FTP and Amazon S3 file browser inside of your EE publish page. Flexible settings allow you to only show one, two or all three file browsers in a single field as well as customize your settings to have each field connect to different Cloud Files, FTP, or Amazon S3 accounts. The file browser also includes Caching to ensure your keep you Cloud Files and Amazon S3 requests to a minimum.
Info
Developed by Christopher Imrie, http://www.christopherimrie.com
Requirements
- ExpressionEngine 2.1 +
Browser Compatibility
- Firefox 3.5+
- Safari 3+
- Chrome 4+
- Opera 10+
Installation
- Copy the
system/expressionengine/third_party/remote_file_browser
folder to yourexpressionengine/third_party/
folder.- Copy the
themes/third_party/remote_file_browser
folder to yourthemes/third_party/
folder. If the third_party folder does not exist, create it.- Go to Add-ons → Fieldtypes in the ExpressionEngine control panel and install the fieldtype labelled Remote Files Browser
- You will be prompted to install a module as well as the fieldtype, this module is needed for secure AJAX communication, select 'install' to both the module and the fieldtype
- To setup global settings, go to Add-ons → Fieldtypes → Remote Files Browser and enter the details for the Remote File protocol you wish to use. You may leave file protocols you do not wish to use blank
Cloud Files Settings
The Username is the same username you use to access the Rackspace Cloud control panel. The API key can be found in the Rackspace Cloud control panel by going to Your Account → API Access. The API Key is 32 characters in length and when copying it into the API Key field, make sure you include no spaces.
The Restrict to container field is optional. Entering the name of one of your Cloud Files containers in here will allow you to restrict the user on the publish page to that container.
FTP Settings
The FTP host should be the web address of the FTP server you wish to contact, without "http://". An Address such as ftp.mysite.com is valid whereas http://ftp.mysite.com is not.
The FTP username and password are the same credentials you use to access your site via your desktop FTP program.
The FTP Path is the server path to your public folder on your server with a trailing slash. This is unique to every server environment but some valid examples are: "htdocs/", "www/" or "www.mysite.com/web/content/".
The FTP Server URL is the full public web address to the same folder you specified in the FTP Path setting with a trailing slash. So this could be "http://www.mysite.com/" or if you specified a subfolder in the FTP Path setting, "http://www.mysite.com/subfolder/"
Amazon S3 Settings
The S3 Username is sometimes referred to as the "Access Key", but this along with the S3 Secret Key, can be found in your Amazon AWS control panel
The Restrict to bucket field is optional. Entering the name of one of your S3 buckets in here will allow you to restrict the user on the publish page to that bucket.
- Create a custom channel field as usual, and select Remote Files Browser as the Field type. You may override you global settings in the Custom Field Options section when creating a new field. This will allow you to connect to different servers for each of your fields and channels
How to use
Publish Page
The file viewer
The Remote Files Framework will display a tabbed file browser in your publish page, with each tab representing a different connection protocol. You can navigate the folder structure of your remote server connection by simply clicking the files or folders in the file viewer.
Depending on the nature of your Remote Files Browser package you purchased, you may be able to allow / disallow certain file protocols in the Custom Channel Fields settings when creating a new Remote Files Browser field. This will change the number of tabs shown on the publish page for that field.
You may switch between different connection protocols whilst browsing and the framework will remember your last position.
When selecting a file, the name will be highlighted in blue to confirm you have selected a file. You may preview this file whilst it is highlighted by double clicking the filename or clicking the Preview button
Caching
The Remote Files Framework has a built caching layer that intercepts AJAX requests to save on bandwidth costs when connecting to services such as S3 and Cloud Files.
All file data shown in the file viewer is cached by default and this cache can be dumped by click the Refresh button. When the cache is dumped, only the cache for the current protocol you are viewing is dumped, however, the cache dump erases the entire cached file tree for that protocol.
The Refresh button will also have the Remote Files Framework fetch the file data for the protocol you are viewing again
There are no automatic cache refreshes (eg: after a specified amount of time)
Templates
The field type supports single tags only. Use the field name you specified in your Custom Channel Field settings, to return the full web url to the file you selected in the file viewer on the publish page.
The field also supports a parameter called "show" which allows you to specify what data you want to show in your templates
Simple Example
Lets say you have defined a custom field with a field label of Remote File and field name remote_file and through the publish form selected a file called "my_picture.jpg" using the file viewer.
You can produce the full web url to the selected file by simply calling the field name tag on its own:
{exp:channel:entries channel="channel_name"} Your selected file url is {remote_file} {/exp:channel:entries}
Returns:
Your selected file url is http://www.example.com/path/to/image/my_picture.jpg
Parameter Example
Using the file you have selected in the above example, we can retrieve different file attributes by using the show parameter:
{exp:channel:entries channel="channel_name"} Your selected filename is {remote_file show="filename"} {/exp:channel:entries}
Returns:
Your selected filename is my_picture.jpg
Parameters
show
{field_name show="filename"}
Allows you to specify what file attribute to return. This parameter is optional, and if not used, the tag will return the full web url by default.
Accepts the following variables:
- filename - Filename including extension
- path - Server path to the file
- public_url - Full web url to the file
- method - The short name for the file protocol used (eg: ftp, cloud_files, s3)
Known Issues
Using a masked Control Panel or non standard system folder location
If you have renamed your control panel file to something different than
index.php
or you are masking your control panel URL in some other way, you will need to ensure you specify the$config['cp_url']
in your control panel index file.Example
Lets say you have moved your entire
system/
folder above your web root. You have copied the file that was located atsystem/index.php
, renamed itadmin.php
and placed it at your web root (This would allow you to access the Control Panel via www.example.com/admin.php)In order for the Remote Files Browser to work, you will need to ensure you specify the new name of the control panel file as a config variable. To do this, you open up the new
admin.php
in a code editor and CUSTOM CONFIG VALUES section, add the newcp_url
setting:/* * -------------------------------------------------------------------- * CUSTOM CONFIG VALUES * -------------------------------------------------------------------- * * 'cp_url' is typically the only config override variable * that would need to be managed in the control panel index.php file * * Un-comment the $assign_to_config array below to use this feature * */ $assign_to_config['cp_url'] = 'admin.php'; // masked CP access only
You can learn more about masking your control panel for extra security by reading the ExpressionEngine documentation.
Change log
1.5.1
- Fixed URL issues for when using a masked CP or renamed system folder
1.5
- Public release
1.4
- Beta release