PDA

View Full Version : Can <dax:track> be used inside of a track pa



Balok
10-18-2006, 03:33 PM
My goal is to provide links to the previous and next track on the track page. Seeing no tags for this, I thought to try Javascript. The simple code saved the current track in a variable. Then I attempted to iterate over all the tracks using <dax:track> and making a Javascript call inside each iteration. This appears to mess up the page context in some manner, for after attempting this valid HTML did not seem to work. Here's the Javascript:



<script language="javascript">
<!--
var thisTrackNum;
var prevTrackLink = "";
var nextTrackLink = "";

function saveTrackNum(trackNum)
{
thisTrackNum = trackNum;
}

function saveTrackLink(trackNum,trackLink)
{
if(thisTrackNum > 0 &amp;&amp; trackNum == thisTrackNum - 1)
prevTrackLink = trackLink;
if(trackNum == (thisTrackNum + 1))
nextTrackLink = trackLink;
}

function printTrackLinks()
{
if (prevTrackLink.length > 0)
document.write("P:" + prevTrackLink.toString() + "<br>");
if (nextTrackLink.length > 0)
document.write("N:" + nextTrackLink.toString() + "<br>");
}
-->
</script>


And here's how it's invoked:



<script language="javascript">
<!--
saveTrackNum(<dax:tracknum/>);
-->
</script>

<dax:track>
<script language="javascript">
<!--
saveTrackLink(<dax:tracknum/>,"<dax:tracklink/>");
-->
</script>
</dax:track>

<script language="javascript">
<!--
printTrackLinks();
-->
</script>

<!-- bottom table -->
<!-- first row: lyrics and notes on left -->

<table class="trackbottom">
<tr>

<td class="left" id="lyrics">

<h3 class="topper">LYRICS
<dax:if($allow_edit)>
<span class="addedit">
<a href="#" onclick="window.external.edittrk(0,0,3); return false;">
<dax:if(lyrics&#124;&#124;trackinstrumental)>(edit)<dax:else>(add)</dax:if>
</a></span>
</dax:if>
</h3>
<hr>

<p><dax:lyrics/></p>


When it reaches that <dax:lyrics> tag I get this message:


Unknown tag or section: 'lyrics' in C:\Program Files\OrangeCD\Templates\PaulB.dax at line 143, character 17.

<hr>

<p><dax:lyrics/></p>

</td>


Without the a <dax:track> construct the page loads fine, leading me to suspect that the <dax:track> construct doesn't work on a track page. But without it I see no way to obtain the previous and next track links, which is a feature I'd like in my template.

Any ideas?

andrei_c
10-20-2006, 10:10 PM
Without the a <dax:track> construct the page loads fine, leading me to suspect that the <dax:track> construct doesn't work on a track page. But without it I see no way to obtain the previous and next track links, which is a feature I'd like in my template.
<dax:track> does not work in a track page.

You can try to implement next/previous track links by modifying current URL which is accessible through document.location.

The theme track URL will look like this:


dadb:D:\Personal\Documents\My%20Music\My%20music.d ab?disc=080fd411&amp;track=4
All you need is to replace trailing track=4 with track=3 or track=5 and youll get next/previous track URL.

Balok
10-21-2006, 03:50 PM
Thanks, I'll try that!

Balok
10-22-2006, 01:41 AM
For those interested, here is the Javascript:



<script language="javascript">
<!--
function printTrackLinks()
{

var url = document.URL;
var track = <dax:tracknum/>;

document.write("<table class=\"tracklink\"><tr>");

// Left
if (track > 1)
document.write("<td class=\"lefttracklink\"><a href=\"" +
url.replace(/track=(\d+)/,"track=" + (track-1)) +
"\"><<<</a></td>");

// Right
if (track < <dax:trackcount/>)
document.write("<td class=\"righttracklink\"><a href=\"" +
url.replace(/track=(\d+)/,"track=" + (track+1)) +
"\">>>></a></td>");

document.write("</tr></table>");

}
-->
</script>


Invoke it by placing this code wherever you want the links to appear:



<!-- Track links -->

<script language="javascript">
<!--
printTrackLinks();
-->
</script>



And put this either in a style tag, or on your CSS page:



table.tracklink
{
padding: 0 5px 0 5px;
width: 100%;
}

table.tracklink td
{
font-family: verdana,arial,helvetica;
font-size: 70%;
font-weight: bold;
color: $x1_color;
margin: 20px 0 0 0;
padding: 0;
text-transform: uppercase;
}

table.tracklink a
{
color: $x1_color;
}

table.tracklink a:hover
{
color: $hv_color;
text-decoration: none;
}

table.tracklink td.lefttracklink
{
text-align: left;
padding: 0 0 0 5px;

}

table.tracklink td.righttracklink
{
text-align: right;
padding: 0 5px 0 0;
}


Of course, you can and should alter your styles to confirm to your own template. These are my choices, which may not work for you.