Relative Path of File in HTML block1 user found helpful
I'm building a site that I'm going to move later. I have a ton of audio files uploaded to the file manager, and I want to code some of them into the HTML block audio tags directly, as they will play inline.
Problem is my site name will change when I move it, and then all the src URLs will die!
I know I can upload the files to a separate directory, and call them in the HTML like you do from a theme's image folder, but I want to do this from the file manager.
This is the bast way to grab an object from the file manager and embed it on the page.
<?php $file = File::getByID($fID); $path = $file->getPath() ?> <embed src="<?php $path ?>" hidden="true" autostart="true" loop="1">
appearing on the page. I'm trying to do this inside the HTML block, maybe that's the problem?
So one option would be to use the Content block, click the "HTML" button in the toolbar, and paste in your HTML there, making sure the links follow the appropriate format so they will automatically get rewritten upon deployment.
--Sanity check: SELECT * FROM btContentLocal WHERE content LIKE '%/old/base/dir/%'; --Run the update (with optional WHERE clauses at the end as a "safety feature"): UPDATE btContentLocal SET content = REPLACE(content, '/old/base/dir/', '/new/dir/') WHERE content LIKE '%/old/base/dir/%';
Run the first line first, just to make sure it gives you sane results and you're not going to accidentally break anything.
Then run the second line to actually perform the update.
This probably doesn't apply to you, but If you have any url's in image blocks (in the "Image Links to URL" field), you also want to run these:
SELECT * FROM btContentImage WHERE externalLink LIKE '%/old/base/dir/%'; UPDATE btContentImage SET externalLink = REPLACE(externalLink, '/old/base/dir/', '/new/dir/') WHERE externalLink LIKE '%/old/base/dir/%';
(same deal as above -- run the first line first, make sure it's sane, then run the second one to perform the update).
I'll figure something out. I've had to do a lot of DB work on this project, so I guess I'll just have to do it that way.
Just for clarity, this is what I'm trying to embed in the page:
<audio controls preload="auto" autobuffer> <source src="http://mydev.com/stage/files/3512/9953/8707/audiofile.mp3"/> <source src="http://mydev.com/stage/files/3512/9953/8707/audiofile.ogg"/> </audio>
or in some cases:
<a onclick="this.firstChild.play()"><audio src="http://mydev.com/stage/files/3512/9953/8707/audiofile.mp3"></audio>Play Button Graphic Coming Soon</a>
I really want to replace the hardcoded path with something wieldy.
Thanks for the help guys.
I think what you really want is just a "raw text" block of some kind.
I found this php block on the marketplace which is close:
But you're definitely going to want to edit the packages/nd_php_package/blocks/nd_php/view.php file, changing this:
<?php echo $content; ?>
And then for that sql query I had above, you want to run it against the "btNdPhpBlockContent" table, not btContentLocal.
I really would love a hack to the editor that would let me insert file, such that the output on the page would be something like this:
<a onclick="this.firstChild.play()"><audio src="/index.php/download_file/view/32/"></audio>text</a>
The "text" is a word in Persian that is being read by a narrator. I want every vocabulary word read out onclick on the page (it's a Persian learning site, btw). I really want to do this without a player, since player controls are totally pointless when the sound file is 3 seconds and one word long.
Anyway I'd love the option in the TinyMCE's "add file" that would allow this kind of audio tag insertion.
UPDATE: This is a TinyMCE issue, submitted as bug.