Jump to main content Jump to doc navigation

This article describes how to assign a Media Source to a TV. It is recommended to read the Adding a Media Source article before reading this one.

Only "image" and "file" type TVs use Sources at this time.

Creating the TV

First we will start by creating a TV that we will attach a media source to. Go ahead and create a TV called "TestSourceTV", and save it. Notice then you'll see a new tab on your TV, a "Media Sources" tab. This will have a grid of Contexts that are available, and the Sources that are associated with those Contexts.

This means that TVs can use different Sources per Context. This will take effect when editing a TV in a Resource from that Context, as well as when that TV is rendered in that Context.

For now, go ahead and assign all contexts to the Source "My New Source", which we created in the Adding a Media Source article. Set your TV's input type, under the "Input Options" tab, to "image". Assign it to a Template. Save your TV.

Limiting the Source to Specific Folders

Often, you'll want users to select files from a specific folder when selecting a value for a TV. You can set up this restriction when you define your Media Source.

1. First, create your Media Source under Tools -> Media Sources 2. After you've created the Media Source, right-click it and select "Update Media Source" 3. Scroll down and edit the following properties:

  • basePath - set to something like "assets/images/"
  • baseUrl - set to something like "assets/images/"

Leave basePathRelative and baseUrlRelative set to "Yes". That's the most common way to set this up.

basePath and baseUrl should start without a slash, but they should end with a trailing slash.

Editing the TV

Now, when you edit that TV in a Resource, you'll notice that it uses the Source we created earlier:

Clicking the dropdown will load the MODX.Browser window using the Source that we specified - note that our source here only loads the contents of the assets/ directory.

Now we'll probably want to consider restricting access to this Source, so that our Content Editors can't accidentally edit it and mess it up. Read the next article to find out how.

See Also

  1. Adding a Media Source
  2. Assigning Media Sources to TVs
  3. Securing a Media Source
    1. Creating a Media Source for Clients Tutorial
  4. Media Source Types
    1. Media Source Type - File System
    2. Media Source Type - S3

Support the team building MODX with a monthly donation.

The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.

Backers

  • modmore
  • STERC
  • Jens Wittmann – Gestaltung & Entwicklung
  • Fabian Christen
  • Digital Penguin
  • Dannevang Digital
  • Sepia River Studios
  • CrewMark
  • Chris Fickling
  • deJaya
  • Following Sea
  • Anton Tarasov
  • eydolan
  • Raffy
  • Lefthandmedia
  • Murray Wood
  • Snow Creative
  • Nick Clark
  • Helen
  • JT Skaggs
  • krisznet
  • YJ
  • Yanni
  • Richard

Budget

$366 per month—let's make that $500!

Learn more