Search

Hi all,

I have been tinkering with the Data Source functionality and I am currently trying to see if I can limit groupings that are displayed (i.e. any groupings with less than 5 entries).

Specifically, I have my record collection online and I have it grouped by both Artist and Label to make it easier for people to locate tracks. Due to the sheer amount of Artists/Labels that are being displayed, I wanted to see how I can cut down the results.

After perusing the message board, I noticed that I am limited with operators when it comes to leveraging a Data Source. Does anyone have a workaround option for this? I would be very much appreciative! Thanks so much!

You can see my issue at: http://www.shrimp.dj/vinyl

Example of my XML:

        <artist handle="artificial-intelligence" value="Artificial Intelligence">
        <entry id="3156">
            <artist handle="artificial-intelligence">Artificial Intelligence</artist>
            <title handle="through-the-gate">Through The Gate</title>
        </entry>
        <entry id="3157">
            <artist handle="artificial-intelligence">Artificial Intelligence</artist>
            <title handle="uprising">Uprising</title>
        </entry>
        <entry id="777">
            <artist handle="artificial-intelligence">Artificial Intelligence</artist>
            <title handle="movin-up">Movin Up</title>
        </entry>
        <entry id="776">
            <artist handle="artificial-intelligence">Artificial Intelligence</artist>
            <title handle="desperado">Desperado</title>
        </entry>
    </artist>
    <artist handle="ashanti-vs-lomax" value="Ashanti vs Lomax">
        <entry id="551">
            <artist handle="ashanti-vs-lomax">Ashanti vs Lomax</artist>
            <title handle="make-up-boycee-rmx">Make Up [Boycee RMX]</title>
        </entry>
    </artist>
    <artist handle="atlantic-connection" value="Atlantic Connection">
        <entry id="3158">
            <artist handle="atlantic-connection">Atlantic Connection</artist>
            <title handle="wonderful-life">Wonderful Life</title>
        </entry>
        <entry id="3159">
            <artist handle="atlantic-connection">Atlantic Connection</artist>
            <title handle="echo-park">Echo Park</title>
        </entry>
        <entry id="3160">
            <artist handle="atlantic-connection">Atlantic Connection</artist>
            <title handle="rocksteady">Rocksteady</title>
        </entry>
        <entry id="3161">
            <artist handle="atlantic-connection">Atlantic Connection</artist>
            <title handle="burning-blue">Burning Blue</title>
        </entry>
    </artist>
    <artist handle="autumn" value="Autumn">
        <entry id="3162">
            <artist handle="autumn">Autumn</artist>
            <title handle="refuge">Refuge</title>
        </entry>
    </artist>
    <artist handle="axwell-vs-high-contrast" value="Axwell vs High Contrast">
        <entry id="3164">
            <artist handle="axwell-vs-high-contrast">Axwell vs High Contrast</artist>
            <title handle="high-contrast-berlin-after-dark-rmx">[High Contrast Berlin After Dark RMX]</title>
        </entry>
        <entry id="3163">
            <artist handle="axwell-vs-high-contrast">Axwell vs High Contrast</artist>
            <title handle="i-found-u-high-contrast-old-skool-revenge-rmx">I Found U [High Contrast Old Skool Revenge RMX]</title>
        </entry>
    </artist>

After perusing the message board, I noticed that I am limited with operators when it comes to leveraging a Data Source

Unfortunately this is the case. Some fields support special filters, for example text fields support regexp:... (to match content by string regular expressions), and file upload support mimetype:... (to match uploaded files of a specific type). So the eventual approach would be to add a new filter type to the Select Box Link field (if this is what you’re using to link entries together) like:

count:>3  // only get entries where the field has more than 3 linked entries
count:<10 // only get entries where the field has less than 10 linked entries

I haven’t thought through the complexities of implementing this, but I don’t think it’ll be at all trivial. It’d require extra SQL statements (probably a nested COUNT/GROUP BY) to evaluate the number of linked entries at runtime.

You might be better off performing this in your XSLT. If you are indeed using the Select Box Link field, then tick the checkbox in your Data Source (bottom right) to show the count of entries in related sections. This should give you a total number of tracks as an attribute on each artist <entry> element:

<entry id="123" tracks="5">

So while you can’t filter these out directly in your Data Source, you can write an XPath query in your XSLT to only show artists where the tracks attribute count is larger than 3 (for example):

<xsl:for-each select="/data/artists/entry[@tracks &gt; 3]">

Ah interesting - thanks, Nick! Unfortunately, I do not have them setup as Select Box, but I can reload all the data and add the artist/label as Select Boxes. Is it not possible to do a XPath query using the count function? I don’t see that being possible, but I thought I would ask.

You’d have to include all artists and tracks in your output XML, which would slow the page loading down considerably. Select Box Link is preferred over a select box as it links on ID and not the text value itself. So you can edit the title and they remain linked. And you get the be benefit of the counts added to the XML!

You are a prince, Nick.

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