Archive for Coding Tips

How to Add a Hyperlink to a Pretty Photo Image Description

I really wanted to write this blog because I keep forgetting how to create a hyperlink in a Pretty Photo Gallery description. I always forget that I can’t use regular syntax.  To get a hyperlink in the description in a gallery you have to use HTML entity names.

Here is a screen shot of using the hyperlink in the title of the hyperlink to the image.

Hyper Link Sample

In the following code snip you will see how I was able to pull this off.

  
  <a class="viewDetail lightbox" title="To find out more &lt;a href=&quot;http://www.chrislail.net&quot; target=&quot;_blank&quot; &gt;click here&lt;/&gt;" href="/img/Screenshots/Viewer.jpg"> 
    <img class="imgFrame" style="opacity: 1;" src="/img/Screenshots/Viewer.jpg" alt="Pretty Photo is well..Pretty Awesome." width="321px" />
  </a>

Using the “Replace” Function in Sql Server/T-SQL

I ran into an issue today where I needed to strip two characters out of a field while in a stored procedure.  The string looked something like this:

@UserID = {abcdefghi}

I needed the middle text (abcdefgi) only so I used the replace function.  The replace function only allows you to replace one thing at a time so I had to use it twice.  This is what the end result looks like:

replace(replace(@UserID,'{‘,”),’}’,”)

Ugly, yes, but it gets the job done.

 

How to count xml nodes using Freemarker

I looked all over the web today for a working example of how to count xml branches in the xml dom using Freemarker.  I finally came across the answer and thought I would share in case anyone else is looking for it.

Here is a sample from the XML:

  
  <asn>
    <Packages>
      <Package>
        <PackageID/>
      </Package>
      <Package>
        <PackageID/>
      </Package>
    </Packages>
  </asn>

Freemarker code:  ${asn.Packages.Package?size}

Output: 2