cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

website template area map set title

veldew
Super Contributor

Hi,

 

Any idea how i can set the title attribute of an area map generated for a diagram object ?

Now it is by default "-", but i would like it to have the name of the linked object

 

ex : 

<area title="-" href="fc2a058056a61e20.htm" shape="rect" coords="3007, 380, 3253, 453" target="_top">

should be

<area title="Name of the object" href="fc2a058056a61e20.htm" shape="rect" coords="3007, 380, 3253, 453" target="_top">

 

Thanks or your reply

 

Kind regards,

Wim VdV

 

2 Replies

veldew
Super Contributor

Hi Victor,

 

Many thanks for your clear answer and all the effort you made !

I think i will go for the first solution with the hardcoded string and put something like "Click here for more detail.." 

 

Kind regards,

Wim VdV

 

vtm
Retired

Hi veldew,

I believe you are using the [DRAW] tag to create your diagram and the associated maps in your descriptors.

In my experience, you can't really easily change what's automatically written with this tag, but as a workaround you can modify the text after it was created.
You can do it either directly with the descriptor's functions, or using javascript. But in the first case I couldn't succeed to make it change to a variable (for instance the diagram name), only a hard string.

Using descriptor's functions:
The entire diagram ans it's map is created using the tag [DRAW]. If you know what is written (and you know it), you can surround the tag with the tag [Stringfunction]:

[Stringfunction=SearchReplaceRegularExpression RegularExpression='title="-"' String='title="myname"']
  [Draw link=InOut Target="_self"/]
[/StringFunction]


Use simple quote for the tag's parameters (RegularExpression and String) so that you can use double quote for your html tag. The result is :

 

Screen Shot 02-01-16 at 10.56 AM.PNG

But as said earlier I could not find a solution for "myname" to be a variable (using [Buffer] tag did not work). You can use this solution if your title can always be a hard string.

Using Javascript;
When using javascript, the page is generated with the title="-" thing, but after that you can dynamically change it to what you want (ie your diagram name).
You do that by adding a bit of JS in the descriptor juste below the [DRAW] tag:

[Draw link=InOut Target="_self"/]
<script type="text/javascript">
    var maplist = document.getElementsByName("[CP="_HexaIdAbs"/]"); \c The map containing the areas has the property name set to the diagram _hexaIdAbs
    for (var i = 0; i < maplist.length; ++i) \c With this loop you can draw more than once the diagram on this page and it will be still treated
    {
        var map = maplist\[i\]; \c there are backslashes because you're in a descriptor and then if you don't escape them the descriptor will think it's a tag. When rendered in html it becomes [i]
        if (map.tagName == "MAP")    { \c  in case other tags were named after the diagram's _hexaIdAbs
            map.innerHTML = map.innerHTML.replace(/title=\\"-\\"/g, "title=\"[CP="Short name"/]\""); \c We use a regularExpression to get the original title="-", mixed with some descriptor escapes. Thus the double backslashes. When rendered in html it becomes map.innerHTML.replace(/title=\"-\"/g, "title=\"myname\""); with myname being the diagram's short name.
        }
    }
</script>


The bad thing is as it's changed dynamically after the page rendering, when you look to the source you can't see the changes.

 

Screen Shot 02-01-16 at 10.53 AM.PNG


You can still verify it worked by using the explorer's debugger (F12 in IE or Firefox and expand the nodes in the explorer tabs)

 

Screen Shot 02-01-16 at 11.57 AM.PNG

 

Screen Shot 02-01-16 at 11.31 AM.PNG

 

Victor