Pagefile::tags() method

Get or set the "tags" property, when in use.


$file = $page->files->first();
$tags = $file->tags(); // Get tags string
$tags = $file->tags(true); // Get tags array
$file->tags("foo bar baz"); // Set tags to be these 3 tags
$tags->tags(["foo", "bar", "baz"]); // Same as above, using array


// basic usage
$string = $pagefile->tags();

// usage with all arguments
$string = $pagefile->tags($value = null);


value (optional)bool, string, array

Specify one of the following:

  • Omit to simply return the tags as a string.
  • Boolean true if you want to return tags as an array (rather than string).
  • Boolean false to return tags as an array, with lowercase enforced.
  • String or array if you are setting the tags.

Return value

string array

Returns the current tags as a string or an array. When an array is returned, it is an associative array where the key and value are both the tag (keys are always lowercase).

See Also

Pagefile methods and properties

API reference based on ProcessWire core version 3.0.236

Latest news

  • ProcessWire Weekly #526
    In the 526th issue of ProcessWire Weekly we'll cover the latest news from the ProcessWire community: newly open sourced Functional Fields module, new site profile to accompany RockFrontend, and more. Read on! / 8 June 2024
  • ProFields Table Field with Actions support
    This week we have some updates for the ProFields table field (FieldtypeTable). These updates are primarily focused on adding new tools for the editor to facilitate input and management of content in a table field.
    Blog / 12 April 2024
  • Subscribe to weekly ProcessWire news

“We chose ProcessWire because of its excellent architecture, modular extensibility and the internal API. The CMS offers the necessary flexibility and performance for such a complex website like ProcessWire offers options that are only available for larger systems, such as Drupal, and allows a much slimmer development process.” —xport communication GmbH