2 Posts
Das123
3 years ago
0
Topic

I have a project where I need to construct an HTML override for a List View using a Link element. Eg. (Line 2)

<div class="banner-container">
  <a href="/$cck->getLink('product_link')" class="grad-hover banner-base" target="_blank">
    <img src="/$cck->getValue('product_thumbnail')" class="img-fluid" />
    <div class="banner-text">
      <h4 class="text-white">$cck->getValue('art_title')</h4>
    </div>
  </a>
</div>

But I want the URL Target to be from the setting in the database.

The Link element has been setup to record the URL as well as the Target.

In the Typographies HTML $cck->getLink('product_link') gives me URL component. 

$cck->getValue('product_link') gives me a JSON string with elements for "Link" and "Target". Eg:

{"link":"https:\/\/www.google.com","target":"_blank"}

But how can I isolate the Target element separately so I can construct my HTML override?

I've tried the following:

$cck->getValue('product_link')[1]
$cck->getFields('product_link',1)
$cck->getTarget('product_link')

But these aren't allowable methods.

Hope someone can help. :)

Get a VIP membership