Jump to content

AtkFileAttribute

From NusaATK
Revision as of 13:20, 10 June 2009 by Patrick (talk | contribs)

Attribute: atkFileAttribute

API docs | Flags

List of other attributes

atkFileAttribute screenshot

See also the tutorial about Image_processing_with_the_atkFileAttribute

Description

The atkFileAttribute allows the management of files as attributes. They can be uploaded, replaced, and removed - users can also choose from a list of already-uploaded files.

Params

$name: Name of the attribute $dir: Can be a string with the Directory with images/files or an array with a Directory and a Display Url $flags: Flags for this attribute $size: Filename size

Initial value

If you want the attribute to display a default file when adding a new record, then you might want to add an entry to the initial values array like in this example:

function initial_values()
{
  return array(
    "avatar" => array("filename" => "myavatar.jpg")
  );
}

Note that of course the file myavatar.jpg needs to be present in the specified directory.

Examples

Adding an attribute "filename" which uses a config setting for its path and does not allow selection of previously uploaded files.

$this->add(new atkFileAttribute("filename", atkconfig('images_dir'), AF_FILE_NO_SELECT));

For more attribute flags, look at Attribute_Flags#atkFileAttribute - this is a very flexible attribute.