Select to view content in your preferred language

Using HTML and Arcade Expressions

9368
15
Jump to solution
04-18-2023 04:27 PM
Paco
by
Frequent Contributor

Hello all!

Trying to use the HTML Source window within the Text popup to add a bunch of "href" URLs.

not exactly sure where to add my Arcade 'expression' within the HTML?  the URLs are NOT within the attribute table,  but I can query out which Features can be given those URLs(hardcoded).

Im just hoping to get a list of Text in the popup that individually have an href URL associated to them.

I have something as simple as this to subset the selected Features-

if($feature.STATE == "Alabama") {
return something something

and a hardcoded HTML test like this,  that works-

<p>
<strong>Geoheritage Examples:&nbsp;</strong>&nbsp;&nbsp;
<br>
<a target="_blank" rel="noopener noreferrer" href="https://www.gsa.state.al.us/gsa/geologic/opportunities/">Educational information</a>
</p>

..but I need to  use an expression statement somewhere in that HTML for the popup to work correctly and popup the correct URLs..  yes?

 

thanks!

 
 
0 Kudos
15 Replies
Paco
by
Frequent Contributor

Yep!   I never really understood the real difference between the 'Arcade' window and the 'Text HTML' window?  or when to use which?   I just started testing within the Text HTML window..

thanks!  this is a great example.  still unsure how to Return 'several' URL hyperlinks in the popup tho?  at this point with the logic I added I am now able to Return ONE of the links in the list.  but unsure how to add a stacked list of those returned hyperlinks..?

if(($feature.STATE == "Alabama")&&(Find('Educational information', $feature.Description, 0)) > -1) {
  return
"Educational information"
}
 
thx!
0 Kudos
lzk222
by
Regular Contributor

You could set different variables for the conditions for which the different links should appear and then display them as a new line <p></p> in the Arcade block. 

Sticking with the same example I showed earlier, it could look something like this (note that I have a single link hardcoded in the second line, but you could set it up as a var to suit your needs). 

lzk222_0-1682120117655.png

 

Paco
by
Frequent Contributor

Well,  I have to say thankyou!  a very 'simple' syntax that I noticed in your example scripts that I truly didn't know about? the Backtick.  how ive never known about this is beyond me.  but I kept getting errors using the standard single quote around my HTML.  i noticed your tics looked different,  i tried them, and no more errors!   " ` "   vs  " ' "

so,  here are a few example lines from my code(in the Arcade window) using those backticks.  I was also able to remove all the related expressions,  this is the simple code I was hoping to use,  but wasn't using the correct "ticks".  yikes.    Thanks again! @lzk222 

*p.s.  also using Break<br> instead of Paragraph<p>

* see screenshot output

 

if($feature.STATE == "Alabama")
return {
  type : 'text',
  text : `<a href="https://www.gsa.state.al.us/gsa/geologic/opportunities/"> Educational information</a>`
}

if($feature.STATE == "Alaska")
return {
  type : 'text',
  text : `<a href="https://dggs.alaska.gov/popular-geology/kids/index.html"> Kids Rock!</a><br>
          <a href="https://dggs.alaska.gov/outreach/education.html">Education Outreach</a><br>
          <a href="https://dggs.alaska.gov/popular-geology/roadside-geology.html">Roadside Geology</a>`
}
lzk222
by
Regular Contributor

Great! Looking good. Glad this was helpful. Yes, the backtick is a small thing I should have mentioned. It threw me off as well.

0 Kudos
loum
by
Occasional Contributor

Hi, I was following this thread and wondering about how do you use/pass the arcade expression value into HTML? I tried to use {expression/expr0}, I got both text and type fields. How do I get ONLY text field?

TIA.

0 Kudos
lzk222
by
Regular Contributor

Also, I found the Create Arcade content blocks section of this documentation helpful.

https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/pop-ups-arcade-essentials/#:~:text=A....