Select to view content in your preferred language

HTML Popup definition

2739
5
09-25-2013 01:05 PM
CamKenny
Emerging Contributor
I am curious to know whether or not it is possible to copy the HTML popup customizations I have made for one layer to many layers that represent the same geography.

I have a cadastral dataset where I have "customized" the HTML popup to the way I like it.  It was a bit of an arduous process - and now that I am happy with it, I would like to apply the customized HTML popup to other cadastral datasets that have the similar attribute definitions as the original.

thanks
0 Kudos
5 Replies
MattSayler
Frequent Contributor
Possibly. Depends how it's set up. If it's looking for specific things that don't exist in the other layers, it might not work, or at least not as expected. Can you post up the code please (wrapped in bb code tags, '#' button)?

Also, are you talking ArcMap HTML Popups or web API HTML Popups?
0 Kudos
CamKenny
Emerging Contributor
Well, there really is no "code" specifically.  I am using the HTML popup option with attachments created for the feature class (PGDB).

Essentially, consider the dataset as a seamless coverage of cadastral data, but I have had to clip out areas that represent municipalities - so the data structure (column names) are identical for every municipality.

I have gone into the layer properties and specified alias names for the fields and that's about it.  I'd like to keep the alias names that I have created in one dataset so when I use the HTML popup query for other datasets, the aliases stay the same.

Attached is a screen capture of what my HTML popup looks like.
0 Kudos
MattSayler
Frequent Contributor
Ok, so you're using one of the out of the box pop up options. You could probably make a custom one that does what you want, but you'll have to brave working with XSLT.

XSLT is used to transform xml from one schema to another, often xml to html. It's composed of an xsl file which contains instructions for performing the transformation from the source xml to the output xml.

The way html popups work, in a nutshell, is ArcMap produces an xml document based on the layer settings (i.e only the fields checked on the 'fields' tab show up). That xml is converted to html using an xsl. That's what you see when you get the popup. ArcGIS has a few out of the box xsl files, and that's what those default options make use of.

I'm definitely no expert, but I've learned some basics. w3schools.com has some decent tutorials to lay down some foundation concepts. If you're not already familiar with xml or html, the whole prospect can be intimidating though.
0 Kudos
CamKenny
Emerging Contributor
Thanks for the info.  It looks as though you can do quite a bit with XSL Templates.

What it does appear though, and based on my situation, is that I need a way to set the alias for the field names I want to show up in the HTML popup.  Not sure if this can/is done through the XSL template, but rather through some other process?
0 Kudos
MattSayler
Frequent Contributor
I THINK it can be done. You'd set it up to look for fields with certain names and then display the alias you want to use.

This is code I added to a modified version of the default popup xsl. It checks if the field name matches one of two names, checks if the field value is a number, and finally will display alternate text for the field name and format a link to a file path (it's not able to check if the file actually exists though). Actually, I make it display two entries instead of one, since the file could exist in a couple different locations.

    <xsl:template match="Field[FieldName = 'Original WO' or FieldName = 'Last WO']">
        <xsl:choose>
            <xsl:when test="number(FieldValue) = FieldValue and number(FieldValue) != 0">
                <tr>
                    <th>Original WO DWG (if exists)</th> <!-- This is what I'm telling it to display for the field name if it meets the above criteria -->
                    <td><a target="_blank">
                        <xsl:attribute name="href">file:\\Engineering\Drawings\Const Drawings\<xsl:value-of select="FieldValue"/>.dwg</xsl:attribute>
                        <xsl:value-of select="FieldValue"/>
                        </a>
                    </td>
                </tr>
                <tr> <!-- Here is the second entry, just another table row -->
                    <th>As-Built PDF (if exists)</th> 
                    <td><a target="_blank">
                        <xsl:attribute name="href">file:\\Engineering\Drawings\Const Drawings\ASBUILTS\<xsl:value-of select="FieldValue"/>.pdf</xsl:attribute>
                        <xsl:value-of select="FieldValue"/>
                        </a>
                    </td>
                </tr>
            </xsl:when>
            <xsl:otherwise> <!-- If the field name matches, but the field value isn't a number, it displays things like normal. Just one table row, unmodified name & value -->
                <tr>
                    <th><xsl:value-of select="FieldName"/></th> <!-- This line is an example of how the field name is displayed normally -->
                    <td><xsl:value-of select="FieldValue"/></td>
                </tr>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


I've applied the xsl to several of our feature classes as many have the 'Original WO' and 'Last WO'. If a feature class doesn't have either of those fields, it just ignores that section of the code. You could do a similar sort of thing. Look for fieldName = 'x', and then display the name you want instead of 'x'.

It's ultimately html, so you might even be able to invoke some javascript. I haven't done much of that though and am not certain what would work and what wouldn't. The popups run in an embedded browser that seems to have some limitations in my experience. I messed around with using jQuery instead of CSS to format stuff; some things worked ok, some things didn't.
0 Kudos