Search

I need help with this one. It's probably simple (as usually) but I can't get it to work :(

I have "Audio" section with list of the songs and I want to be able to see the count of downloads for every song.

In section I have fields: Song name, song duration,... and field I've named Down Count, which supose to hold number of downloads for particular song.

On frontend I've create something like this:

<a href="#" class="button">DOWNLOAD SONG</a>

<xsl:variable name="currNum" select="//get-song/entry[@id = $song]/down-count" />
<xsl:variable name="newNum" select="$currNum + 1" />

<form method="post" action="" id="addCount" enctype="multipart/form-data">  
    <input name="fields[down-count]" type="hidden" value="{$newNum}" />
    <input name="id" value="{$song}" type="hidden" />
    <input name="action[change-down-num]" type="hidden" value="Submit" />
</form>

&lt;script type="text/javascript">
    $('a.button').click(function() {
            window.location = <xsl:text>'/download/?file=workspace/audio/</xsl:text><xsl:value-of select="//get-song/entry[@id = $song]/audio/filename" /><xsl:text>'</xsl:text>;
            $('#addCount').submit();
            $.colorbox.close();
    });
&lt;/script>

ahhh...mess, rite?

The question is, am I on rite trail?... and if I'm not, where should I go?

(Not really an answer to your question, but...)

You could add the Increment Number Field to your section. The field provides a datasource mode to increment the value of the field each time a page with the DS is called. This way you don't have to post via JS.

Hey, thanks man! this is a life saver :)

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details