Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Eugene 2 posts 22 karma points
    Nov 25, 2010 @ 18:37
    Eugene
    0

    Tabular content data type

    I need to create an html table on my site that provides results and standings for sporting events for each athlete. This content needs to be changed weekly, thus I want to implement it in umbraco. Is there any way to create a custom data type that's basically a table of data? This table needs to be formated differently on each webpage. Some pages will only show selected columns from the table. What's the best approach for this?

  • John C Scott 473 posts 1183 karma points
    Nov 26, 2010 @ 16:54
    John C Scott
    0

    We developed tabular data in this template of this site:

    http://www.zman.co.uk/z-clients/chris-potter.aspx

    where you can see that the various songs by artists are presented as a table.

    In this case a column is not shown if there is no data entered in the whole set (for example not every page has chart position)

    This is implemented as a sub-document where all the possible columns are in the document type, and a macro gets all the sub documents of the current page.

    This is for the 4.04 (pre 4.5 schema) but would be simple to update to the new schema. In here we see that the second and third line check if there is an entry for the producer or the chart position and sets a variable that then control if the table heading and data cell are written out. All credit for this code goes to LauG who wrote this.

    <xsl:param name="currentPage"/>
    <xsl:variable name="testProducer" select="$currentPage/node/data [@alias = 'prodProducer'] != ''" />
    <xsl:variable name="testChartPosition" select="$currentPage/node/data [@alias = 'prodChartPosition'] != ''" />
    
    <xsl:template match="/">
    <xsl:if test="count($currentPage/node  [@nodeTypeAlias='prod']) &gt; 0">
    <h3>Productions and Mixes</h3>
    <table class="productions">
    <tr class="header">
    
    <th class="left">Artist</th>
    <xsl:if test="$testProducer = 'true'">
    <th>Producer</th>
    </xsl:if>
    <th>Title</th>
    <th>Credit</th>
    <xsl:if test="$testChartPosition">
    <th class="right">Chart</th>
    </xsl:if>
    
    </tr>
    <xsl:for-each select="$currentPage/node">
    <tr>
    <td class="left"><xsl:value-of select="data [@alias = 'prodArtist']"/></td>
    <xsl:if test="$testProducer = 'true'">
    <td><xsl:value-of select="data [@alias = 'prodProducer']"/></td>
    </xsl:if>
    <td><xsl:value-of select="data [@alias = 'prodTitle']"/></td>
    <td><xsl:value-of select="data [@alias = 'prodCredit']"/></td>
    <xsl:if test="$testChartPosition = 'true'">
    <td class="right"><xsl:value-of select="data [@alias = 'prodChartPosition']"/></td>
    </xsl:if>
    </tr>
    </xsl:for-each>
    </table>
    </xsl:if>
    
    </xsl:for-each>
    </xsl:template>
    

    I'd prefer to do this as an XML datatype and I am waiting with interest for the uComponents XML data type, and I also understand the next version of Umbraco will support this too. There is also a good nibble article about how to build your own that I had some success with when I tried it. http://www.nibble.be/?cat=14


  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Nov 26, 2010 @ 16:58
    Matt Brailsford
    0

    Hey,

    Have you tried the Dynamic Grid Data Type?

    http://our.umbraco.org/projects/backoffice-extensions/dynamic-grid-data-type

    Matt

  • John C Scott 473 posts 1183 karma points
    Nov 26, 2010 @ 17:02
    John C Scott
    0

    Shiny :) like that - i haven't seen that before - looks useful

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Nov 26, 2010 @ 17:05
    Matt Brailsford
    0

    Can't say I've tried it, but remember seeing it, and though it sounded like what Eugene was after.

    Let us know if you give it a try.

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft