Assigning Media Sources to TVs
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.
$407 per month—let's make that $500!Learn more
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.