Worked like a charm. Thank you!

Fred King, MSLS, AHIP
Medical Librarian, MedStar Washington Hospital Center
fred.k...@medstar.net
202-877-6670
ORCID 0000-0001-5266-0279
MedStar Authors Catalog: http://medstarauthors.org

You know it's cold outside when you go outside and it's cold.
--NPS Twitter

-----Original Message-----
From: Andreas Roussos <a.rous...@dataly.gr> 
Sent: Tuesday, February 21, 2023 2:41 AM
To: King, Fred <fred.k...@medstar.net>; koha-US list <koha...@koha-us.org>; 
koha <koha@lists.katipo.co.nz>
Subject: [EXTERNAL] Re: [Koha] OPAC XSLT template: how to add text if the MARC 
field is not blank?



**ATTENTION: This email originated from outside the MedStar Health network.
 ** DO NOT CLICK links or attachments unless you recognize the sender and know 
the content is safe.

 

Hi Fred,

The snippet you posted already has some "if" logic at the top, where it checks 
for the presence of field 698.

You just need to wrap your <a> tags within a similar conditional block.

Inside your for-each loop, try changing

<a><xsl:attribute
name="href">/cgi-bin/koha/opac-search.pl?q=conference-name:"<xsl:value-of
select="marc:subfield[@code='c']"/>"</xsl:attribute><xsl:value-of
select="marc:subfield[@code='c']"/></a><xsl:text>, </xsl:text>

to

<xsl:if test="marc:subfield[@code='c']">
<a><xsl:attribute 
name="href">/cgi-bin/koha/opac-search.pl?q=conference-name:"<xsl:value-of 
select="marc:subfield[@code='c']"/>"</xsl:attribute><xsl:value-of 
select="marc:subfield[@code='c']"/></a><xsl:text>, </xsl:text>
</xsl:if>

Minimalistic online example: http://xsltransform.net/naZXVFT

Kind regards,
Andreas

On 2023-02-21 00:52, King, Fred wrote:
> Hi everyone,
>
> I'm editing the OPAC detail xslt file to display some extra fields. What I 
> have now is this:
>
>                                  <xsl:if test="marc:datafield[@tag=698]">
>             <span class="results_summary conference">
>                 <xsl:if test="marc:datafield[@tag=698]/@ind1=' '">
>                     <span class="label">Conference: </span>
>                 </xsl:if>
>                 <xsl:for-each select="marc:datafield[@tag=698]">
>                    <a><xsl:attribute 
> name="href">/cgi-bin/koha/opac-search.pl?q=conference-name:"<xsl:value-of 
> select="marc:subfield[@code='a']"/>"</xsl:attribute><xsl:value-of 
> select="marc:subfield[@code='a']"/></a>
>                      <a><xsl:attribute 
> name="href">/cgi-bin/koha/opac-search.pl?q=conference-name:"<xsl:value-of 
> select="marc:subfield[@code='c']"/>"</xsl:attribute><xsl:value-of 
> select="marc:subfield[@code='c']"/></a>
>                    <a><xsl:attribute 
> name="href">/cgi-bin/koha/opac-search.pl?q=conference-name:"<xsl:value-of 
> select="marc:subfield[@code='d']"/>"</xsl:attribute><xsl:value-of 
> select="marc:subfield[@code='d']"/></a>
>                    <a><xsl:attribute 
> name="href">/cgi-bin/koha/opac-search.pl?q=conference-name:"<xsl:value-of 
> select="marc:subfield[@code='e']"/>"</xsl:attribute><xsl:value-of 
> select="marc:subfield[@code='e']"/></a>
>                 <xsl:if test="position()!=last()"><span 
> class="separator"><xsl:text> | </xsl:text></span></xsl:if>
>                 </xsl:for-each>
>             </span>
>         </xsl:if>
>
> Right now it appears on the details page as fieldafieldcfielddfielde. I'd 
> like to add a comma between the fields.
>
> I tried adding <xsl:text>, </xsl:text>, but if there are fields a and e but 
> no c and d, for example, the OPAC display comes out as fielda, , , fielde.
>
> Is there xsl for "if there's something in field c, then add a comma and a 
> space, otherwise don't put anything there" so I can have fielda, fielde? It 
> seems as if there ought to be one, but I haven't found it yet.
>
> Cheers,
>
> Fred King, MSLS, AHIP
> Medical Librarian, MedStar Washington Hospital Center
> fred.k...@medstar.net
> 202-877-6670
> ORCID 0000-0001-5266-0279
> MedStar Authors Catalog: http://medstarauthors.org
>
> You know it's cold outside when you go outside and it's cold.
> --NPS Twitter
>
> ----------------------------------------------------------------------
> MedStar Health is a not-for-profit, integrated healthcare delivery system, 
> the largest in Maryland and the Washington, D.C., region. Nationally 
> recognized for clinical quality in heart, orthopedics, cancer and GI.
>
> IMPORTANT: This e-mail (including any attachments) may contain information 
> that is private, confidential, or protected by attorney-client or other 
> privilege. If you received this e-mail in error, please delete it from your 
> system without copying it and notify sender by reply e-mail, so that our 
> records can be corrected... Thank you.
>
> Help conserve valuable resources - only print this email if necessary.
>
>
> _______________________________________________
>
> Koha mailing list  http://koha-community.org
> Koha@lists.katipo.co.nz
> Unsubscribe: https://lists.katipo.co.nz/mailman/listinfo/koha
_______________________________________________

Koha mailing list  http://koha-community.org
Koha@lists.katipo.co.nz
Unsubscribe: https://lists.katipo.co.nz/mailman/listinfo/koha

Reply via email to