Collection Path URLs & Trailing Slashes
Permalink 1 user found helpful
Hi,
I've noticed that the getCollectionPath() returns a path with a trailing slash and Page::getCollectionPathFromID(id) returns a path without a trailing slash.
I figured I'd post here because I don't really know enough about C5 yet to know if that's supposed to happen or if that's a bug.
Seems like they should be the same to me. Anyone with more experience with C5 core want to comment on this?
Thanks!
-john
I've noticed that the getCollectionPath() returns a path with a trailing slash and Page::getCollectionPathFromID(id) returns a path without a trailing slash.
I figured I'd post here because I don't really know enough about C5 yet to know if that's supposed to happen or if that's a bug.
Seems like they should be the same to me. Anyone with more experience with C5 core want to comment on this?
Thanks!
-john
I feel like this information could help me, but I'm not sure how to apply it. I'm having issues with an audio player going down when I change the month on my site wide calendar. On all but the homepage (it works fine on the homepage), the resulting URL that crashes the audio player, looks something like this:
domain.org/currentpage/?next=1&CurrentMonth=...
However, the following URL would not crash the player, leading me to believe that being able to return the URL without a trailing slash in this one instance could be very useful.
domain.org/currentpage?next=1&CurrentMonth=...
Any ideas on how I could go about doing that? I'm remotely familiar with "extending" helpers, but not entirely sure how to do that or even if it's what I should in fact be doing here. Any advice would help - and either way thanks for the post!
domain.org/currentpage/?next=1&CurrentMonth=...
However, the following URL would not crash the player, leading me to believe that being able to return the URL without a trailing slash in this one instance could be very useful.
domain.org/currentpage?next=1&CurrentMonth=...
Any ideas on how I could go about doing that? I'm remotely familiar with "extending" helpers, but not entirely sure how to do that or even if it's what I should in fact be doing here. Any advice would help - and either way thanks for the post!
How exactly are you outputting the audio URL's?
Thanks for your help! There's an .xml file located next to the player's .swf file which is where I put the paths for the audio files:
The actual coding on the page that calls the files looks like this:
And the problem is that adjusting the month on the calendar results in the "flashcontent" div being written instead of the page loading a fresh player.
The actual coding on the page that calls the files looks like this:
<div id="flashcontent">this will be replaced with flash </div> <script type="text/javascript"> var so = new SWFObject("audio_player_files/audioPlayer.swf", "player", "270", "100", "6", "#C2B5A1"); so.addVariable("xmlPath", "audio_player_files/data.xml"); so.write("flashcontent"); </script>
And the problem is that adjusting the month on the calendar results in the "flashcontent" div being written instead of the page loading a fresh player.
The paths you're using for the song files are relative paths (because they don't start with a slash or withhttp://domain.com), so they will be interpreted differently depending on which page in the site is being viewed. Is this a block or just some code you have in your page type templates? If it's in a block you want to put:
(that's assuming the audio files are in the block's directory)
If it's in your page type template, you could do something like this:
(that's assuming the audio files are in the theme's directory)
<song file="<?php echo $this->getBlockURL(); ?>/audio_player_files/music/filename1.zip" etc. etc.
(that's assuming the audio files are in the block's directory)
If it's in your page type template, you could do something like this:
<song file="<?php echo $this->getThemePath(); ?>/audio_player_files/music/filename1.zip" etc. etc
(that's assuming the audio files are in the theme's directory)
Sorry... no luck. I've always kept the audio_player_files folder inside the public_html folder, as per the directions it came with. But I just tried moving it into themes/default and adjusted the coding on the page (which is sitting inside an HTML block on each page) so that the player would be able to find it. The same problems occurred with the player not appearing on pages with a slash between its original URL and the appended back/next/CurrentMonth/CurrentYear info. I've since moved it back.
Keeping in mind I don't exactly know what I'm talking about here... is there a way for me to ask the Calendar to getPathFromID instead of just getPath?
Keeping in mind I don't exactly know what I'm talking about here... is there a way for me to ask the Calendar to getPathFromID instead of just getPath?
This is tricky, because the instructions that came with your audio player are assuming a non-CMS site. The problem is that all CMS's (including Concrete5) don't actually serve their php/html files from where you think they do -- they're all routed through some other file in some other directory.
I think the easiest way to solve this for you is to put your audio files back where they were before (was it public_html/audio_player_files/music/?), then in your XML file you want to put COMPLETE url's to those files -- something like this:
http://yourdomain.com/audio_player_files/music/whatever.mp3...
Ideally you'd actually serve these audio files from the File Manager, but that is a bit more complicated to set up if you're not already familiar with php and C5 and creating your own blocks. So the solution above is a good compromise.
I think the easiest way to solve this for you is to put your audio files back where they were before (was it public_html/audio_player_files/music/?), then in your XML file you want to put COMPLETE url's to those files -- something like this:
http://yourdomain.com/audio_player_files/music/whatever.mp3...
Ideally you'd actually serve these audio files from the File Manager, but that is a bit more complicated to set up if you're not already familiar with php and C5 and creating your own blocks. So the solution above is a good compromise.
Well, whenever possible I prefer to do things in a way that is ideal, so I might as well become more familiar with php and C5 so I can do this right. I honestly feel like the audio paths aren't the issue, but if this will help the pages in question find the .swf file and load that, then I'm all for it. I get the feeling you know exactly what you're talking about too, so I appreciate your guidance. Looking forward to building my first block :^)
Hi Jordan,
I've built a block (named Beer Player, located in public_html/blocks/beer_player) based on the HTML Block and the Basic Test block. I managed to get it installed, but I can't get the player to show up. There is room made for it, but no image/player appears. The block's folder is attached and this is the code I am entering into the edit.php field created by form_setup_html.php
NOTE: The <?php echo did not appear to be printing when I would view the page source. I tried single quotes and getBlockURL, but neither worked.
On a related note, I could not get it installed at first, because of an XML error (reserved name?), so I moved the data.xml file into the audio_player_files folder, which also contains the music folder. Should it stay there to avoid some kind of a "Two XMLs, One Block" situation, or can they both exist in the same folder after installation. And as mentioned, I went with getBlockPath over getBlockURL like you originally suggested. Are either of those preferred over the other in this situation?
Also, please note that I have excluded the audioplayer.swf file as it's not mine to flaunt - it is normally located in the block's root folder with the bulk of the files. And there's normally mp3s in the music folder, but for the sake of upload... there is not.
I've built a block (named Beer Player, located in public_html/blocks/beer_player) based on the HTML Block and the Basic Test block. I managed to get it installed, but I can't get the player to show up. There is room made for it, but no image/player appears. The block's folder is attached and this is the code I am entering into the edit.php field created by form_setup_html.php
NOTE: The <?php echo did not appear to be printing when I would view the page source. I tried single quotes and getBlockURL, but neither worked.
<div id="flashcontent">this will be replaced with flash</div> <script type="text/javascript"> var so = new SWFObject("<?php echo $this->getBlockPath(); ?>/audioplayer.swf", "player", "270", "100", "6", "#C2B5A1"); so.addVariable("xmlPath", "<?php echo $this->getBlockPath(); ?>/audio_player_files/data.xml"); so.write("flashcontent"); </script>
On a related note, I could not get it installed at first, because of an XML error (reserved name?), so I moved the data.xml file into the audio_player_files folder, which also contains the music folder. Should it stay there to avoid some kind of a "Two XMLs, One Block" situation, or can they both exist in the same folder after installation. And as mentioned, I went with getBlockPath over getBlockURL like you originally suggested. Are either of those preferred over the other in this situation?
Also, please note that I have excluded the audioplayer.swf file as it's not mine to flaunt - it is normally located in the block's root folder with the bulk of the files. And there's normally mp3s in the music folder, but for the sake of upload... there is not.
You have a lot going on here, unfortunately I don't have the time to go through all of your code and requirements to figure it out for you :(
It might be worth the $15 for this marketplace addon which lets you embed and flash file and then put in the XML data via the C5 editing interface:
http://www.concrete5.org/marketplace/addons/flash-embed/...
Otherwise, if you have specific questions I can answer quickly I'd be happy to do so but can't really build this whole thing for you.
-Jordan
It might be worth the $15 for this marketplace addon which lets you embed and flash file and then put in the XML data via the C5 editing interface:
http://www.concrete5.org/marketplace/addons/flash-embed/...
Otherwise, if you have specific questions I can answer quickly I'd be happy to do so but can't really build this whole thing for you.
-Jordan
No doubt Jordan - I probably should stop high-jacking this post for my own topic too eh? I think you might've solved everything with this Flash-Embed block anyway... note to self: become more familiar with forum etiquette and marketplace inventory. Cheers!
As of recently, the core system is on github, which makes it a lot easier for other people's changes to be rolled back in, so hopefully things like this will start getting cleaned up by other people outside the core team.
-Jordan