3

I'm attempting to make QGIS maptips display a hyperlink as the text from another field in the attribute table. Below are 3 attempts of HTML and the different results.

When "title documents" is not NULL

enter image description here

When "title documents" is NULL

enter image description here

1

[%case when "title documents" is not NULL then '<a href='||"title documents"||'>' end %]
[%case when "title documents" is not NULL then ' "title no" </a>' else 'Not available' end %]

2

<a href=[%CASE WHEN "title documents" is not null then "title documents"%] > [%"title no"%]</a>
[%CASE WHEN  "title documents" is null then 'Not Available' END%]

3

[%case when "title documents" is not '' then '<a href='||"title documents"||'>' else '' end %]
[%case when "title documents" is not NULL then 'Click Me</a>' else 'Not available' end %]

I'm trying to get result 3 but rather than 'Click Me', make it display "title no" which I would have thought code line 1 would achieve but obviously not.

1

You have to insert only one QGIS Expression under [% %] brackets and play with the ELSE clause from CASE.

Try the following layer maptips expression :

[% CASE
  WHEN "title documents" IS NOT NULL
    THEN '<a href="' || "title documents" || '">' || "title no" || '</a>'
  ELSE 'Not available'
END %]

Explanation :

Case statement :

CASE
  WHEN condition_1 THEN result_1
  WHEN condition_2 THEN result_2
  [ ELSE result_else ]
END

The only one condition I set is when the field "title documents" IS NOT NULL then display "title no" value as a text for a html link with "title documents" value as link.

Else, (if "title documents" IS NULL) display the text Not available.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.