Closed taverin closed 11 years ago
Hey @taverin, extending Asset
is generally only useful if you need to add specific types of data to certain types of assets. It won't create custom-named collections of files for you.
You shouldn't need to add a special file type for mp3s though. For each type of file attached to a page, stacey will create a special named collection for it. So you can get a list of all mp3s attached to a page through page.mp3
, in the same way, all pdfs attached to a page can be accessed though page.pdf
, etc. etc.
If you really wanted to add a collection of files in page.audio
, then you would need to add some code to create_asset_collections
inside app/page-data.inc.php
, ie.
static function create_asset_collections($page) {
# page.files
$page->files = Helpers::list_files($page->file_path, '/(?<!thumb|_lge|_sml)\.(?!yml)([\w\d]+?)$/i', false);
# page.images
$page->images = Helpers::list_files($page->file_path, '/(?<!thumb|_lge|_sml)\.(gif|jpg|png|jpeg)$/i', false);
# page.numbered_images
$page->numbered_images = Helpers::list_files($page->file_path, '/^\d+[^\/]*(?<!thumb|_lge|_sml)\.(gif|jpg|png|jpeg)$/i', false);
# page.video
$page->video = Helpers::list_files($page->file_path, '/\.(mov|mp4|m4v)$/i', false);
# page.audio
$page->audio = Helpers::list_files($page->file_path, '/\.(mp3)$/i', false);
# page.swf, page.html, page.doc, page.pdf, page.mp3, etc.
# create a variable for each file type included within the page's folder (excluding .yml files)
$assets = self::get_file_types($page->file_path);
foreach($assets as $asset_type => $asset_files) {
$page->$asset_type = $asset_files;
}
}
I am designing a portfolio that needs to show examples of MP3 files. I feel like I did all the parts, but I nothing is populating the content area.
I added app/asset-types/audio.inc.html which is:
I then added this to populate any audio files.
Am I missing something here?