Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

My Second Hack at CAML - New URL format: ImageLink

88 views
Skip to first unread message

Jim Duncan

unread,
May 30, 2002, 2:16:51 PM5/30/02
to
(please excuse the HTML posting, trying to preserve format and stop some line breaks)
 
I've managed to create a new Format for the 'Hyperlink or Picture' field data type. When defining/editing a column of type 'Hyperlink or Picture', a new option is given in the 'Format URL as' dropdown. The new format is ImageLink and if selected, the field will be rendered as an image (using the Web Address specified) linking to a URL typed in the description box.
 
Here's the hack:
 
In the files _layouts/FLDNEW.HTM and _layouts/FLDEDIT.HTM, scroll down and find the <Case> entry for URL:
<Case ExpandXML="TRUE" Value="URL">
<HTML><![CDATA[
    <!-- URL -->
Here is where the 'Format URL as' dropdown is created and the format is (somehow) set. You will see two webbots that make the entries in the dropdown. Add a third webbot by copying the second one and changing every instance of the word Image to ImageLink and the word Picture to ImageLink. Here is the complete webbot (my formatting, it's one line in the file):
<!--webbot bot="ListMiscXML" ID="webbot10" clientside PREVIEW="List XML - Do not remove" tag="TBODY" startspan --> 
<ows:IfEqual>
    <Expr1><GetVar Name="vFormat"/></Expr1>
    <Expr2>ImageLink</Expr2>
<Then>
    <HTML>
        <![CDATA[
            <OPTION value="ImageLink" id="onetidImageLink" SELECTED>
                <LocID value="ImageLink" id="onetidImageLink">ImageLink</LocID>
            </OPTION>
        ]]>
     </HTML>
</Then>
<Else>
    <HTML>
        <![CDATA[
            <OPTION value="ImageLink" id="onetidImageLink">
                <LocID value="ImageLink" id="onetidImageLink">ImageLink</LocID>
            </OPTION>
        ]]>
    </HTML>
</Else>
</ows:IfEqual>
<!--webbot bot="ListMiscXML" endspan -->
Remember to make these changes to BOTH _layouts/FLDNEW.HTM and _layouts/FLDEDIT.HTM. Make these changes in any (sub) web to make this format available in existing webs. If you make these changes to the SharePoint Templates, any new webs will have this new format option.
 
The next step is to modify the DisplayPattern for the URL field type to check for the ImageLink Format. In the SharePoint Templates XML folder, open FLDTYPES.XML in NotePad and scroll down to the field definition for the URL data type:
<Row>
  <Field Name="TypeName" DisplayName="TypeName">URL</Field>
Find the <RenderPattern> tag for "DisplayPattern" and add a new <Case> statement for the Format switch (my changes in blue):
<Switch><Expr><Property Select="Format"/></Expr>
        <Case Value="Image">
            <HTML><![CDATA[<IMG SRC="]]></HTML><Column HTMLEncode="TRUE"/><HTML>" ALT="</HTML><Column2 HTMLEncode="TRUE"/><HTML><![CDATA[">]]></HTML>
        </Case>
        <Case Value="ImageLink">
            <HTML><![CDATA[<A HREF="]]></HTML><Column2 HTMLEncode="TRUE"/><HTML><![CDATA[">]]></HTML>
            <HTML><![CDATA[<IMG SRC="]]></HTML><Column HTMLEncode="TRUE"/><HTML>" ALT="</HTML><Column2 HTMLEncode="TRUE"/><HTML><![CDATA[">]]></HTML>
        </Case>
        <Default>
            <HTML><![CDATA[<A HREF="]]></HTML><Column HTMLEncode="TRUE"/><HTML><![CDATA[">]]></HTML>
            <Switch>
                <Expr><Column2/></Expr>
                    <Case Value=""><Column HTMLEncode="TRUE"/></Case>
                    <Default><Column2 HTMLEncode="TRUE"/></Default>
            </Switch>
            <HTML><![CDATA[</A>]]></HTML>
        </Default>
</Switch>
Be sure to restart IIS after making these changes so the cache is cleared and it uses your new FLDTYPES.XML.
 
How to Use:
 
In any web that incorporates the canges to FLDNEW.HTM and FLDEDIT.HTM, add or modify a list column of type Hyperlink or Picture and select ImageLink in the 'Format URL as' dropdown.
 
Type the URL of the image in the 'Web Address' box and type the URL to link to in the description box. The column will be rendered as the specified image, but clicking on it will navigate to the URL specified in the description box.
 
Modifications:
    You might want to add BORDER="0" to the ImageLink IMG tag in the DisplayPattern
    <HTML><![CDATA[<IMG BORDER="0" SRC="]]></HTML>
 
Possible Uses:
    Thumbnails:
        Web Address = URL to small image
       Description = URL to full image
    Banner Ads:
       Web Address = URL to banner image (likely off site)
       Description = URL to advertised web site (with referral parameters)
 
As usual, be sure to make back-up copies of any files before you modify them.


--
Jim Duncan
jim[at]collutions[dot]com
http://www.collutions.com
_____________________________________
I consider the above to be Intellectual Property
If you use it, please give a dollar to the next
homeless person you see :-)

Dustin Miller

unread,
May 30, 2002, 4:03:54 PM5/30/02
to
Another excellent contribution, Jim.  Keep 'em coming!  I'll be putting up a repository of code soon on a new SharePoint site, mind if I include this?  In a few weeks, the SharePoint code repository will be integrated with the custom provisioning tool I told you about earlier, but the repository should go online within a few days.

--
Dustin Miller, President
FuseWerx LTD
http://www.fusewerx.com/
ColdFusion, ASP, .NET and SharePoint Consulting
 
"Jim Duncan" <nu...@bizness.com> wrote in message news:uPkOLXACCHA.1576@tkmsftngp04...

Jim Duncan

unread,
May 30, 2002, 5:46:36 PM5/30/02
to
By all means, please include it...

The homeless and I get royalties, right? ;-)

<wink wink><nudge nudge>


Dustin Miller

unread,
May 30, 2002, 6:21:22 PM5/30/02
to
When I start charging for the code snippets in the repository, you'll get a
cut. <grin>

Seriously, though, the repository will be free, and I'll be putting out a
call for contributors some time next week when I announce our new web site.

--
Dustin Miller, President
FuseWerx LTD
http://www.fusewerx.com/

Coming Soon: SharePoint Experts, a division of FuseWerx LTD

"Jim Duncan" <nu...@bizness.com> wrote in message

news:ewGLYMCCCHA.580@tkmsftngp02...

Jim Duncan

unread,
May 30, 2002, 8:11:26 PM5/30/02
to
If it's SharePoint based, just be sure to give me Advanced Author membership
:-D

"Dustin Miller" <nos...@dev.null> wrote in message
news:uu1B7gCCCHA.1828@tkmsftngp05...

Dustin Miller

unread,
May 30, 2002, 9:47:10 PM5/30/02
to
Bah-ha-ha-ha-ha! :)

--
Dustin Miller, President
www.sharepointexperts.com -- coming online soon!

"Jim Duncan" <nu...@bizness.com> wrote in message

news:Ob1vTdDCCHA.2580@tkmsftngp05...

Dustin Miller

unread,
May 30, 2002, 10:20:42 PM5/30/02
to
Almost forgot to add that it will /not/ be SharePoint based, it will be
ColdFusion based. Sometimes you have to go with what works best, and with
what I'll be doing, ColdFusion MX works best. Well, .NET would work better,
but .NET hosting is too expensive right now for what I need. As soon as the
webhost installs ColdFusion MX, I'll be launching the site (it's essentially
done on our staging server here!). It's pretty cool!

--
Dustin Miller, President
FuseWerx LTD

SharePoint Experts -- It's done in ColdFusion, but it's got the heart of a
CAML.

"Jim Duncan" <nu...@bizness.com> wrote in message

news:Ob1vTdDCCHA.2580@tkmsftngp05...

Jim Duncan

unread,
May 31, 2002, 1:41:14 AM5/31/02
to
ok, now you've done it...you've found my weakness...
I know nothing about ColdFusion...

So I'll just continue posting my discoveries to the news group and you can
copy/paste onto your site...

btw, is your staging server publicly available for special engagement,
invitation only (hint), sneak preview access?
if so, I can rev up the feedback engine early... :-p

"Dustin Miller" <nos...@dev.null> wrote in message

news:ezxtqmECCHA.1880@tkmsftngp04...

Dustin Miller

unread,
May 31, 2002, 8:41:38 AM5/31/02
to
No, but you can (sorta) see the logo at http://www.sharepointexperts.com/ :)

It will be an IE 5.0+ only site.

--
Dustin Miller, President
FuseWerx LTD
http://www.fusewerx.com/

ColdFusion, ASP, .NET and SharePoint Consulting

"Jim Duncan" <j...@fcidesign.com> wrote in message
news:OH8VzWGCCHA.1732@tkmsftngp02...

Jim Duncan

unread,
Jun 1, 2002, 3:45:28 AM6/1/02
to
Dibs...I get to be the green guy :-)

"Dustin Miller" <nos...@dev.null> wrote in message

news:OLUzoBKCCHA.2024@tkmsftngp04...

0 new messages