How do I Create a Field that will store a link to an MP3 file?
I thought I could use the filefield for this, but apparently not, b/c it seems to only allow for file uploads. I would rather just point to files I already have on the server.
Can anyone give me a short step by step method for doing such, or at least get me started? I thought I just needed to create a text field, and then just insert the web link in that text field, but I'm not really getting anywhere.
The end result is that I want to use the MP3 Player module or either SWF Tools to point the 1pixelout player to that field, so that it's showing the player and not the file link.
I've seen how to do this when I use the filefield, but since you can only upload with that one, it isn't what I personally need.
Any help on this one? Surely someone knows something about this idea.
Thanks for any help, suggestions

There may well be a better
There may well be a better way to do it, but here's what I would do:
1. Define a text field in a CCK custom content type which would hold the path of the mp3 - this gets the data into the $node object.
2. Define a custom node.tpl.php file which uses this data to link to the mp3 file.
I know you could use this method to display a regular hyperlink to the mp3; I'm not quite sure how to use it to get SWF to point at the mp3 but I think this would be the right approach.
Hmm, now I just need to find out how to...
Hmm, now I just need to find out how to create the custom node.tpl.php file.
Can I just copy the one from the default theme, and save it under /sites/default/ ?
I suppose perhaps I need to go through the whole podcast over at MustardSeedMedia.com about setting up a podcast. I know they talk about the node.tpl.php file there.
I did see in another podcast that Rob did there about the SWF tools usage. All he had to do (once the custom podcast node was created) was edit the php file on one line to point the player to the file instead of just showing a link to the file.
I was kind of hoping I could do it without the whole podcast method, and just stick a text field or whatever in a node.
I've got much to learn. I very rarely have touched any of the php code, etc, so far. It seems fairly strait forward, but I know how bad guessing can go in any programming language at times! ;0)
Any further suggestions gladly welcome as well. If I get the time this weekend, I'll look at going through the video podcasts I mentioned.
Start with the files that
Start with the files that are in your current theme (for the record, if you are making your own theme I'd start with Zen - http://drupal.org/project/zen - but this will work with any theme.
Let's take the Garland theme (i.e., the default Drupal theme on a new install) as an example. Consider the following files in the theme directory:
page.tpl.php
node.tpl.php
comment.tpl.php
block.tpl.php
Whenever Drupal wants to display a new page, it looks at page.tpl.php to see how to do it. Then, if that page contains any nodes, Drupal will look at node.tpl.php in order to see how to display those nodes. Ditto for comments and blocks.
The default node.tpl.php looks like this:
<?php
// $Id: node.tpl.php,v 1.5 2007/10/11 09:51:29 goba Exp $
?>
<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?>">
<?php print $picture ?>
<?php if ($page == 0): ?>
<h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<?php endif; ?>
<?php if ($submitted): ?>
<span class="submitted"><?php print $submitted; ?></span>
<?php endif; ?>
<div class="content clear-block">
<?php print $content ?>
</div>
<div class="clear-block">
<div class="meta">
<?php if ($taxonomy): ?>
<div class="terms"><?php print $terms ?></div>
<?php endif;?>
</div>
<?php if ($links): ?>
<div class="links"><?php print $links; ?></div>
<?php endif; ?>
</div>
</div>
?>
It's pretty straightforward, really. Mostly it just repeats the same syntax: if a certain thing exists, then print that thing, in its own div so that we can get at it for CSS purposes.
If you were to change the above file, it would change the display of all of your nodes. I guess you actually want to change the display of only one of the node types: the one that displays your mp3/SWF. I'm going to assume that you've created this node type in CCK, and called it "mp3". In this case, you need to create a new file called node-mp3.tpl.php and copy the contents of node.tpl.php into it. Then, whenever Drupal loads one of your mp3 nodes it will look at node-mp3.tpl.php rather than node.tpl.php to find out how to display that node.
Now look at the code in your node-mp3.tpl.php file. Find the following bit:
<?phpprint $content
?>
This is the bit we're interested in, as it displays all of the content of the node: the title, the body, and any other fields that you have created in CCK. Taxonomy terms, the "read more" link and the date the node was posted are all displayed by other bits of node-mp3.tpl.php.
We've got a bit of a problem here, though. $content contains all of your content, and is just printed in one chunk. We can't get at individual bits of the content and mess with them.
To get round this problem, add the following code to the bottom of node-mp3.tpl.php:
<pre style="background:#eee;border:1px solid black;clear:both;"><?php print_r($node) ?></pre>This code prints the $node object, which is where Drupal stores the content for the node that is being displayed. The $content variable that is printed in node.tpl.php just takes certain parts of $node and formats them so they can be displayed on the screen.
From here on you're going to be printing specific parts of $node. Check out http://www.alldrupalthemes.com/blog/theming-cck-node.html for a brilliant tutorial on how to do it. It really isn't too difficult when you start to get your head round it.
Thank you very much for all that detail!
Thank you very much for all that detail!
From what you have stated so far, I think I have a little better understanding of how it all is working - or at least this little piece. Before, I wasn't sure, but it just hit me while reading (assuming this is correct).
So, if I wanted to have a custom theme for each node type, I just copy/create a custom tpl.php file for each type?
So, if I understand correctly, then let's say I have these nodes:
And I wanted a custom template for each one, then I'd create 3 separate files based off the original, and call them:
Is that correct, or am I jumping down the wrong hole?
Thanks again for the help. I know I'm going to be really busy with several other things over the next 1 to 2 weeks, at least, so I may not get much time to go into depth working on this until after then. But when I do, I'll be sure to post back with my results.
Thanks again,
kjv
Yes, if you have three node
Yes, if you have three node types called mustard, ketchup and mayo, then creating those three .tpl.php files will allow you to theme each node type individually: http://drupal.org/node/17565.
This system works in other ways, too. I think if you create node-168.tpl.php then that file will be used to theme only the node with nid=168. I'm pretty sure there are other trick with the other tpl.php files, too.
Do post back your results and any further questions. I keep promising to write some accessible Drupal documentation on stuff like this, so helping out a specific individual gives me the motivation to do it!
_
See Core templates and suggestions for the defaults and Working with template suggestions for how to extend them.
===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz