Due to enormous amounts of spam, the forum has been set to read-only mode.



Reply to topic  [ 90 posts ]  Go to page Previous  1 ... 5, 6, 7, 8, 9
Country Flags 
Author Message
User avatar

Joined: Fri Nov 14, 2003 6:15 pm
Posts: 1425
Post Re: Country Flags

seam-splitter wrote:
but the flag behind the artist in "AlbumBrowse" view is missing.

Not sure what is the problem, but attached below is a group of templates from v9.40 with the changes in them. Let me know if you have any problems with them.


You do not have the required permissions to view the files attached to this post.

_________________
Cheers,
Dave


Wed Aug 01, 2012 6:10 am
Profile WWW

Joined: Mon Aug 22, 2011 7:35 am
Posts: 15
Post Re: Country Flags

thanks so much Dave!
i forgot to insert the code into the "common.xsl" explorer template.
using your file solved the problem!
perfect!
thanks again,
timo


Wed Aug 01, 2012 6:22 am
Profile

Joined: Wed Sep 28, 2005 9:08 pm
Posts: 29
Location: Luxembourg
Post Re: Country Flags

:grin: Hello Dave,
many thanks dealing this templates, very helpful to make my Catraxx more perfect.

Jean-Paul

_________________
Current version: Catraxx 8.32


Wed Aug 01, 2012 6:47 pm
Profile

Joined: Sun Mar 30, 2003 3:49 pm
Posts: 175
Location: Carmel, Indiana, USA
Post Re: Country Flags

I'd still really, really, really love to see Fredrik implement a feature to allow country flags to be displayed in the standard browse display (just like the graphics for stars in the rating field).


Thu Aug 02, 2012 3:59 pm
Profile WWW
User avatar

Joined: Sat Nov 22, 2003 7:47 pm
Posts: 2547
Location: Denmark
Post Re: Country Flags

Hi Dave

In common.xsl / format-artist you have this test:

<xsl:if test="boolean(lookupdata)">

meaning that flags are only displayed if lookupdata is present.
That means no flag when using f.ex. album.xsl.

???

_________________
Kind regards
Thomas Hamstrup

HAP Software (http://www.hamstrup.dk)

Using Windows 8 PRO 64-bit and CATraxx 9.44


Mon Aug 06, 2012 12:59 pm
Profile WWW
User avatar

Joined: Fri Nov 14, 2003 6:15 pm
Posts: 1425
Post Re: Country Flags

Thomas,

When the country flag code was originally written in 2008 the XML from Album.xsl did not include the artist's country. Thus the requirement to add datalookup to Album.xsl (see the templates a few posts up on July 31, 2012). This has worked fine for me and others over the years and it still does.

Somewhere along the line the artist's country got added to the XML from Album.xsl. So now it is possible for country flags to work in Album.xsl without using datalookup. Try this Common.xsl file. It should work when lookupdata is required and when it is not. Let me know if you encounter any problems.


You do not have the required permissions to view the files attached to this post.

_________________
Cheers,
Dave


Mon Aug 06, 2012 3:34 pm
Profile WWW
User avatar

Joined: Sat Nov 22, 2003 7:47 pm
Posts: 2547
Location: Denmark
Post Re: Country Flags

Yes, I just realized that.
I didn't see you had added lookupdata to album.xsl.

_________________
Kind regards
Thomas Hamstrup

HAP Software (http://www.hamstrup.dk)

Using Windows 8 PRO 64-bit and CATraxx 9.44


Mon Aug 06, 2012 4:38 pm
Profile WWW
User avatar

Joined: Sat Nov 22, 2003 7:47 pm
Posts: 2547
Location: Denmark
Post Re: Country Flags

LotsOCds wrote:
Thomas,

When the country flag code was originally written in 2008 the XML from Album.xsl did not include the artist's country. Thus the requirement to add datalookup to Album.xsl (see the templates a few posts up on July 31, 2012). This has worked fine for me and others over the years and it still does.

Somewhere along the line the artist's country got added to the XML from Album.xsl. So now it is possible for country flags to work in Album.xsl without using datalookup. Try this Common.xsl file. It should work when lookupdata is required and when it is not. Let me know if you encounter any problems.


Hi Dave
I have a different setup of countryflags.
Mainly to avoid duplicating code.

The template that displays the flag:
Code:
<xsl:template name="showcountryflag">
  <xsl:param name="country"/>
  <xsl:param name="fieldvalue" select="''"/>
  <xsl:param name="showflag" select="'left'"/>
  <xsl:param name="_border" select="'False'"/>
  <xsl:variable name="_country">
    <xsl:value-of select="$country"/>
  </xsl:variable>
  <xsl:variable name="_flag">
    <xsl:value-of select="document('flagicons/flags.xml')/data/country[@name=$_country]/ISO_3166-1_alpha-2"/>
  </xsl:variable>
  <xsl:choose>
    <xsl:when test="$_flag!='' and $showflag!='none'">
      <xsl:if test="$_border='True' and $showflag = 'right'">
        <xsl:value-of select="$fieldvalue"/>
        <IMG style="vertical-align:text-buttom;border-style:solid;border-width:1px;border-color:grey;margin:0px 0px 0px 3px" SRC="flagicons/{$_flag}.gif"/>
      </xsl:if>
      <xsl:if test="$_border='True' and $showflag = 'left'">
        <IMG style="vertical-align:text-buttom;border-style:solid;border-width:1px;border-color:grey;margin:0px 3px 0px 0px" SRC="flagicons/{$_flag}.gif"/>
        <xsl:value-of select="$fieldvalue"/>
      </xsl:if>
      <xsl:if test="$_border='False' and $showflag = 'right'">
        <xsl:value-of select="$fieldvalue"/>
        <IMG style="vertical-align:text-buttom;border:0px none;margin:0px 0px 0px 3px" SRC="flagicons/{$_flag}.gif"/>
      </xsl:if>
      <xsl:if test="$_border='False' and $showflag = 'left'">
        <IMG style="vertical-align:text-buttom;border:0px none;margin:0px 3px 0px 0px" SRC="flagicons/{$_flag}.gif"/>
        <xsl:value-of select="$fieldvalue"/>
      </xsl:if>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$fieldvalue"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


You can select on which side to display the flag.
You can decide whether a border is present or not.
You can also pass a fieldvalue to display along the flag (f.ex. from country.xsl).
Unfortunately I can't find a solution if the fieldvalue is HREF'ed.

The template "format-artist" looks like this:
Code:
<xsl:template name="format-artist">
  <xsl:param name="artists"/>
  <xsl:param name="showflag" select="'left'"/>
  <xsl:param name="hyperlink" select="'True'"/>
  <xsl:param name="newwindow" select="'False'"/>
  <xsl:param name="separator1" select="', '"/>
  <xsl:param name="separator2" select="' &amp; '"/>
  <xsl:param name="showsortby" select="'False'"/>
  <xsl:param name="templatefile" select="'ArtistPerson.xsl'"/>
  <xsl:param name="favoriteplaylink" select="'False'"/>
  <xsl:param name="favoriteplaylink_ratingvalue" select="'5'"/>
  <xsl:for-each select="$artists/artist">
    <xsl:if test="position() > 1">
      <xsl:choose>
        <xsl:when test="count(role) > 0">
          <!-- add role -->
          <xsl:text> </xsl:text><xsl:value-of select="role"/><xsl:text> </xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <!-- no role, add separator -->
          <xsl:if test="position() &lt; last() ">
            <xsl:value-of select="$separator1"/>
          </xsl:if>
          <xsl:if test="position() = last() ">
            <xsl:value-of select="$separator2"/>
          </xsl:if>
        </xsl:otherwise>
      </xsl:choose>     
    </xsl:if>   
    <xsl:variable name="fieldvalue">
      <xsl:choose>
        <xsl:when test="$showsortby='True'">
          <xsl:value-of select="sortby"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="name"/>
        </xsl:otherwise>
      </xsl:choose>         
    </xsl:variable>
    <xsl:if test="$showflag='left'">
      <xsl:call-template name="showcountryflag">
        <xsl:with-param name="country" select="country"/>
        <xsl:with-param name="showflag" select="$showflag"/>
      </xsl:call-template>
    </xsl:if>   
    <xsl:choose>
      <xsl:when test="$hyperlink='True'">
        <xsl:choose>
          <xsl:when test="$templatefile='IMAGECAROUSEL'">
            <a href="CMD:IMAGECAROUSEL:Album,Image1,-1,{/data/record/albumdata/albumid/@unformatted},True,True,0,1,Play Album,&quot;{name}&quot;,Album.Artist={name}"><xsl:value-of select="$fieldvalue"/></a>
          </xsl:when>
          <xsl:when test="$newwindow='True'">
            <a href="{$templatefile}?ID={@id}" target="_blank"><xsl:value-of select="$fieldvalue"/></a>
            <xsl:if test="lookupdata/birthname!=''">
              <xsl:text> (</xsl:text>
              <xsl:apply-templates select="lookupdata/birthname"/>
              <xsl:text>)</xsl:text>
            </xsl:if>
          </xsl:when>
          <xsl:otherwise>
            <a href="{$templatefile}?ID={@id}"><xsl:value-of select="$fieldvalue"/></a>
            <xsl:if test="lookupdata/birthname!=''">
              <xsl:text> (</xsl:text>
              <xsl:apply-templates select="lookupdata/birthname"/>
              <xsl:text>)</xsl:text>
            </xsl:if>
          </xsl:otherwise>
        </xsl:choose>
        <xsl:if test="$favoriteplaylink='True'">
          <xsl:text> </xsl:text>
          <a href="PLAYFILTER:Track.PersonalRating={$favoriteplaylink_ratingvalue}@Track.Artist={name}@orderby=Album.Released, Album.Title, Track.Position@validate=yes,1,1@xslparam:doctitle={name} Favorites"><img src="favorites.gif" border="0"/></a>
        </xsl:if>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$fieldvalue"/>
        <xsl:if test="lookupdata/birthname!=''">
          <xsl:text> (</xsl:text>
          <xsl:apply-templates select="lookupdata/birthname"/>
          <xsl:text>)</xsl:text>
        </xsl:if>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:if test="$showflag='right'">
      <xsl:call-template name="showcountryflag">
        <xsl:with-param name="country" select="country"/>
        <xsl:with-param name="showflag" select="$showflag"/>
      </xsl:call-template>
    </xsl:if>   
  </xsl:for-each>
</xsl:template>


The call from album.xsl:
Code:
<xsl:call-template name="format-artist">
  <xsl:with-param name="artists" select="artists"/>
   <xsl:with-param name="showflag" select="'left'"/>
</xsl:call-template>   


The call from country.xsl:
Code:
           <td class="record_table_fieldvalue">
              <xsl:call-template name="showcountryflag">
                <xsl:with-param name="country" select="country"/>
                <xsl:with-param name="fieldvalue" select="country"/>
                <xsl:with-param name="showflag" select="'right'"/>
              </xsl:call-template>
            </td>


I would like your comments on this setup.

_________________
Kind regards
Thomas Hamstrup

HAP Software (http://www.hamstrup.dk)

Using Windows 8 PRO 64-bit and CATraxx 9.44


Last edited by hamsen on Sun Aug 12, 2012 6:40 pm, edited 1 time in total.



Fri Aug 10, 2012 7:22 am
Profile WWW
User avatar

Joined: Fri Nov 14, 2003 6:15 pm
Posts: 1425
Post Re: Country Flags

hamsen wrote:
I have a different setup of countryflags.
Mainly to avoid duplicating code.

Creating a separate template makes sense for what you want to do here.

Quote:
You can also pass a fieldvalue to display along the flag (f.ex. from country.xsl).
Unfortunately I can't find a solution if the fieldvalue is HREF'ed.

Sorry but I don't understand. Do you want to pass a link as the fieldvalue or create a link from the fieldvalue?

Quote:
I would like your comments on this setup.

This should work fine. Since you pass the country explicitly to showcountryflags there is no concern with the XML structure. I did notice a typo in the IMG styles in the template.

_________________
Cheers,
Dave


Fri Aug 10, 2012 8:13 am
Profile WWW
User avatar

Joined: Sat Nov 22, 2003 7:47 pm
Posts: 2547
Location: Denmark
Post Re: Country Flags

LotsOCds wrote:
Sorry but I don't understand. Do you want to pass a link as the fieldvalue or create a link from the fieldvalue?

In format-artist I wanted to get rid of the test for left/right.
You got me thinking, and the solution was right in front of me.
Code:
<xsl:template name="format-artist-X">
  <xsl:param name="artists"/>
  <xsl:param name="showflag" select="'left'"/>
  <xsl:param name="hyperlink" select="'True'"/>
  <xsl:param name="newwindow" select="'False'"/>
  <xsl:param name="separator1" select="', '"/>
  <xsl:param name="separator2" select="' &amp; '"/>
  <xsl:param name="showsortby" select="'False'"/>
  <xsl:param name="templatefile" select="'ArtistPerson.xsl'"/>
  <xsl:param name="favoriteplaylink" select="'False'"/>
  <xsl:param name="favoriteplaylink_ratingvalue" select="'5'"/>
  <xsl:for-each select="$artists/artist">
    <xsl:if test="position() > 1">
      <xsl:choose>
        <xsl:when test="count(role) > 0">
          <!-- add role -->
          <xsl:text> </xsl:text><xsl:value-of select="role"/><xsl:text> </xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <!-- no role, add separator -->
          <xsl:if test="position() &lt; last() ">
            <xsl:value-of select="$separator1"/>
          </xsl:if>
          <xsl:if test="position() = last() ">
            <xsl:value-of select="$separator2"/>
          </xsl:if>
        </xsl:otherwise>
      </xsl:choose>     
    </xsl:if>   
    <xsl:variable name="fieldvalue">
      <xsl:choose>
        <xsl:when test="$showsortby='True'">
          <xsl:value-of select="sortby"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="name"/>
        </xsl:otherwise>
      </xsl:choose>         
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="$hyperlink='True'">
        <xsl:choose>
          <xsl:when test="$templatefile='IMAGECAROUSEL'">
            <a href="CMD:IMAGECAROUSEL:Album,Image1,-1,{/data/record/albumdata/albumid/@unformatted},True,True,0,1,Play Album,&quot;{name}&quot;,Album.Artist={name}"><xsl:value-of select="$fieldvalue"/></a>
          </xsl:when>
          <xsl:when test="$newwindow='True'">
            <a href="{$templatefile}?ID={@id}" target="_blank">
              <xsl:call-template name="showcountryflag">
                <xsl:with-param name="country" select="country"/>
                <xsl:with-param name="fieldvalue" select="$fieldvalue"/>
                <xsl:with-param name="showflag" select="$showflag"/>
              </xsl:call-template>
            </a>
            <xsl:if test="lookupdata/birthname!=''">
              <xsl:text> (</xsl:text>
              <xsl:apply-templates select="lookupdata/birthname"/>
              <xsl:text>)</xsl:text>
            </xsl:if>
          </xsl:when>
          <xsl:otherwise>
            <a href="{$templatefile}?ID={@id}">
              <xsl:call-template name="showcountryflag">
                <xsl:with-param name="country" select="country"/>
                <xsl:with-param name="fieldvalue" select="$fieldvalue"/>
                <xsl:with-param name="showflag" select="$showflag"/>
              </xsl:call-template>
            </a>
            <xsl:if test="lookupdata/birthname!=''">
              <xsl:text> (</xsl:text>
              <xsl:apply-templates select="lookupdata/birthname"/>
              <xsl:text>)</xsl:text>
            </xsl:if>
          </xsl:otherwise>
        </xsl:choose>
        <xsl:if test="$favoriteplaylink='True'">
          <xsl:text> </xsl:text>
          <a href="PLAYFILTER:Track.PersonalRating={$favoriteplaylink_ratingvalue}@Track.Artist={name}@orderby=Album.Released, Album.Title, Track.Position@validate=yes,1,1@xslparam:doctitle={name} Favorites"><img src="favorites.gif" border="0"/></a>
        </xsl:if>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="showcountryflag">
          <xsl:with-param name="country" select="country"/>
          <xsl:with-param name="fieldvalue" select="$fieldvalue"/>
          <xsl:with-param name="showflag" select="$showflag"/>
        </xsl:call-template>
        <xsl:if test="lookupdata/birthname!=''">
          <xsl:text> (</xsl:text>
          <xsl:apply-templates select="lookupdata/birthname"/>
          <xsl:text>)</xsl:text>
        </xsl:if>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:for-each>
</xsl:template>


LotsOCds wrote:
I did notice a typo in the IMG styles in the template.


Thanks Dave. It's nice to get to the buttom of this subject!

_________________
Kind regards
Thomas Hamstrup

HAP Software (http://www.hamstrup.dk)

Using Windows 8 PRO 64-bit and CATraxx 9.44


Fri Aug 10, 2012 9:07 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 90 posts ]  Go to page Previous  1 ... 5, 6, 7, 8, 9

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.