Search

I have this weird glitch. I created some custom fields called “Author Plug,” “Author Plug Photo,” and “Author Plug Link.”

The idea was that IF something was in the “Author Plug” field, it should display the text, link and image… and if there was nothing in the Author Plug field, the whole box, styles, link, image, and all, should disappear.

So I wrote this code:

<xsl:if test="author-plug/.">
<div id="author-plug">
<xsl:if test="author-plug-photo/."><a href="{author-plug-link/.}"><img src="{$root}/image/2/100/0/5/images/{author-plug-photo/.}" /></a></xsl:if>
<xsl:value-of select="author-plug"/>  
<span class="plug-read-more"><a href="{author-plug-link/.}">Read More</a></span>
</div>
</xsl:if>

It works perfectly. However, if I put something in one of these fields and then take it out, the “if test=author-plug” gets ignored… it acts as though something is in there, when there no longer is anything in it… it displays the div with NOTHING in it, “Read more” text, and link (back to the article, even though I didnt tell if to do this cause there is NOTHING in the “Author Plug Link” field).

This is really weird. Is this a glitch in symphony? Once you put info into a field and take it out, it leaves some kind of trace that can then not be taken out?

Wait a minute.. I am starting to realize.. Do I need some kind of “Otherwise” code? To tell it what to do when nothing is in there?

Try this…

<xsl:if test="author-plug!=''">
<div id="author-plug">
<xsl:if test="author-plug-photo/."><a href="{author-plug-link/.}"><img src="{$root}/image/2/100/0/5/images/{author-plug-photo/.}" /></a></xsl:if>
<xsl:value-of select="author-plug"/>  
<span class="plug-read-more"><a href="{author-plug-link/.}">Read More</a></span>
</div>
</xsl:if>

Does that help? Would you mind posting the XML?

That worked PERFECTLY. What was my code doing?

I think you were testing to see if your element “author-plug” was there. The code I changed is saying if author-plug element is not empty then show this code.

I’m glad that helped.

YES.. thank you so much!!

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