-
☆ A M B ☆
- 24,524 Posts
Is there any way to assign a media source to resources? For example, having a structure of image folders such as images/dogs and images/cats is there a way to have a media resource for each, then have the dogs resources use the dogs media resource and the cats resources use the cats resource?
-
☆ A M B ☆
- 24,524 Posts
Right. I was thinking of the image insertion feature of the rich text editor.
I've often wished that resources had categories as well as elements, and that TVs and Media Sources and other elements could be assigned to resources by category.
you can place a snippet into the mediasource-pathes which gets the parent and replaces the path dynamically.
assets/[[getParentFolder]]
-
☆ A M B ☆
- 24,524 Posts
That is interesting. Opens up a whole new set of possibilities.
I'll have to give that a try and see how it would work. I'm still a Revo neophyte, so I'll have to first figure out how one fetches the current resource's parent in a snippet. I presume that [ [*parent] ] wouldn't work there?
Great! I didn't know that...thanks
Susan, $modx->resource->get('fieldName') will get you any field for the current resource, so $modx->resource->get('parent') will get you the parent's ID.
If you wanted the parent's pagetitle, you'd do this:
<?php
$parentId = $modx->resource->get('parent');
$parentObj = $modx->getObject('modResource', $parentId);
$parentName = $parentObj->get('pagetitle');
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html
-
☆ A M B ☆
- 24,524 Posts
Ok... this doesn't solve the question of how to assign a Media Source to the resources.
Sorry, should have read the OP more carefully. I haven't really had occasion to use Media Sources, but my impression is that they don't work with Resource (but I could well be wrong). I know you can assign one to a TV and probably to a static chunk, if that would help.
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html
-
☆ A M B ☆
- 24,524 Posts
That's OK, learning that we can use tags in the media source path and URL is great! Also your tips on fetching information.
I think that since the value being returned is to correspond to a directory name, perhaps just using the parent's ID would be a better idea. Resource pagetitles often have spaces and other characters that would choke a filesystem. If snippets can be used, can default resource values such as [ [*parent] ] be used as well? One way to find out, I suppose, is to give it a try in an image TV.