We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37042
    • 384 Posts
    Hi guys

    Using getResources, I have a grid of company logos on a page.

    Some of the logos link a company website while some link to a MODX resource.
    The link address itself is determined by a TV. This TV has its Input Type set to URL.

    What I'm trying to do is create an output modifier which makes the logo automatically link to a MODX resource if no URL is manually input into the URL TV.

    The code in my chunk is as follows:

    [[+tv.URL:empty=`<a href="[[~[[+id]]]]"><img src="[[+tv.Picture:phpthumbof=`w=180`]]"></a>`:else=`<a href="[[+tv.URL]]"><img src="[[+tv.Picture:phpthumbof=`w=180`]]"></a>`]]


    It works apart from the URL address. You can see below that if I don't specify a URL, the HREF remains blank.
    What I want is the logo to link to the MODX resource connected to the thumbnail.

    <a href="http://"><img src="/assets/logo-partner-virgin.png"></a>
    




      ...
      • 42602
      • 81 Posts
      I've had similar issues if I recall right and the solution was pretty much close to yours:

      [[+tv.URL:empty:then=`<a href="[[~[[+id]]]]"><img src="[[+tv.Picture:phpthumbof=`w=180`]]"></a>`:else=`<a href="[[+tv.URL]]"><img src="[[+tv.Picture:phpthumbof=`w=180`]]"></a>`]]


      Having conditional like empty, I've used the :then=`` and :else=`` always. Some output modifiers seems to need that kind of formatting. Or I could be completely wrong about that but it is worth the shot.

      Also you could simplify that quite a lot, move the conditional inside the href="" so you save loads of space at least.

      <a href="[[+tv.URL:empty:then=`[[~[[+id]]]]`:else=`[[+tv.URL]]`]]"><img src="[[+tv.Picture:phpthumbof=`w=180`]]"></a></a>
        • 42602
        • 81 Posts
        Would edit the unnecessary </a> tag from the post but firehost is blocking my edit posts
          • 37042
          • 384 Posts
          Thanks Dunnock.
          You're right that the second example greatly simplifies the code.

          Still getting a blank http:// when no URL is specified. Do you have an example in use that you could root out for me?
            ...
            • 37042
            • 384 Posts
            Quote from: dunnock at May 27, 2013, 01:34 PM
            Would edit the unnecessary tag from the post but firehost is blocking my edit posts
            Yep. Saw that, thanks.
              ...
              • 42602
              • 81 Posts
              Cant find any, all databases lost couple of times with computer crashes

              You could also try [[+tv.URL:default=`[[~[[+id]]]]`]]

              The id is default if the URL is empty.

              Sorry, am in rust. Spend my freetime with xpdo stuff and profession is far away from computer screens smiley