Sign in

E-mail *, (xx@domain.com)
Password *

Register | Forgot password

Recent blogs

Found me on LinkedIn?

My profile on LinkedIn

This little project is based on a blog post by Aza Raskin. I'm not going to repeat what he wrote, but this thing basically works by creating a hidden link to my LinkedIn profile and than using JavaScript to read the color of this link. Because the webbrowser displays links to already visited sites in a different color than new or unknown URLs, this is a perfect way to find out this information. All I did was connecting this piece of JavaScript to the WebManager personalization module:

Screenshot of the WebManager personalization panel

Client-side personalization

There is only one problem: WebManager personalizations are XSLT expressions that are evaluated on the server. However, the server cannot execute the JavaScript that is involved in this excersice, so I had to find a way around this. I must make sure my XSLT is valid, otherwise the entire site might break, and it must still include the URL of the page I want to check. I managed to do this by creating a specific XSLT expression, that will always evaluate to true, but contains some important information that can be used by a presentation JSP:

Screenshot of the personalization panel, displaying the used XSLT expression

Next I modify the pagepart/content.jspf file. By default, there is a loop that will render any element on the element holder (like a page or media item). I place an additional div around the wm:render tag and append the required JavaScript that will either hide or display the element:

<%-- Let's see whether this element is dependent on a site visit --%>
<c:set var="personalization" value="${element.personalization}" />
<c:set var="siteOff"><xsl:when test="0=0 or '' = </c:set>
<c:set var="siteOn"><xsl:when test="1=1 or '' = </c:set>
<c:set var="elementDivClose" />
<c:if test="${not empty personalization}">
        <c:set var="xsl" value="${personalization.xslTemplate}" />
        <c:choose>
                <c:when test="${fn:contains(xsl, siteOff)}">
                        <c:set var="testUrl" value="${fn:substringAfter(xsl, siteOff)}" />
                        <c:set var="testUrl" value="${fn:substringBefore(testUrl, '&quot;')}" />
                        <c:set var="display0" value="none" />
                        <c:set var="display1" value="inline" />
                </c:when>
                <c:when test="${fn:contains(xsl, siteOn)}">
                        <c:set var="testUrl" value="${fn:substringAfter(xsl, siteOn)}" />
                        <c:set var="testUrl" value="${fn:substringBefore(testUrl, '&quot;')}" />
                        <c:set var="display0" value="inline" />
                        <c:set var="display1" value="none" />
                </c:when>
                <c:otherwise>
                        <c:set var="testUrl" />
                </c:otherwise>
        </c:choose>
        <c:if test="${not empty testUrl}">
                <div id="element${element.id}">
                <c:set var="elementDivClose">
                        </div>
                        <script>
                                document.getElementById('element${element.id}').style.display =
                                SocialHistory({'mycheck': ${testUrl}}).doesVisit('mycheck')
                                ? '${display0}' : '${display1}';
                        </script>
                </c:set>
        </c:if>
</c:if>
<%-- Now render the element --%>
<wm:render object="${element}" />
${elementDivClose}

Now I can add two elements: an image that displays a LinkedIn image to everybody that hasn't visited my LinkedIn profile yet and a paragraph that thanks the blessed soul that already reached that end of the net:

-- this script is currently disabled --

About the Author

Return to all blogs


Mark is software engineer with a special interest in Security and Digital WebTV. Mark writes about daily engineering with GX WebManager

Read all Marks blog entries

Other blog entries:

July 29, 2008
WCB Sharing FTW!


Share:

del.icio.us
digg
Technorati
Slashdot
Reddit
YahooMyWeb
NewsVine
ekudos

© 2008 GX creative online development B.V.

Disclaimer

This website (GXdeveloperweb.com) may discuss or contain opinions, (sample) coding, software or other information that does not include GX official interfaces, instructions or guidelines and therefore is not supported by GX. Changes made based on this information are not supported.  GX will not be held liable for any damages caused by using or misusing the information, software, instructions, code or methods suggested on this website, and anyone using these methods does so at his/her own risk. GX offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this website, including any liability resulting from incompatibility between the content of this website and the materials and services offered by GX. By using this website you will not hold, or seek to hold, GX responsible or liable with respect to the content of this website.