Check value of anchor for page in list

118 views
Skip to first unread message

Joel Kinzel

unread,
Dec 5, 2012, 10:10:51 AM12/5/12
to reddot-c...@googlegroups.com
All,

I have a list with several followings pages that have an anchor element on them, sometimes it has a page connected/referenced, and other times not: 

List
   Page A (anchor has page connected/referenced)
   Page B (anchor does not have page connected/referenced) 
   Page ...
   Page N

I have the following code for my list: 
        <li><!IoRangeNoRedDotMode><!IoRangeRedDotMode><!--<%lst_banners%>--><!/IoRangeRedDotMode><!/IoRangeNoRedDotMode>
        <reddot:cms>
            <if>
                <query valuea="Context:Pages.GetPage(<%info_guid%>).Elements.GetElement(anc_link).Value[Int:0].Id" operator="!=" valueb="">
                    <htmltext><a href="<%anc_link%>"><%img_photo%></a></htmltext>
                </query>
                <query type="else">
                    <htmltext><%img_photo%></htmltext>
                </query>
            </if>
        </reddot:cms></li>

I've also tried several other iterations of this (like so):

        <li><!IoRangeNoRedDotMode><!IoRangeRedDotMode><!--<%lst_banners%>--><!/IoRangeRedDotMode><!/IoRangeNoRedDotMode>
        <reddot:cms>
            <if>
                <query valuea="<%anc_link%>" operator="!=" valueb="">
                    <htmltext><a href="<%anc_link%>"><%img_photo%></a></htmltext>
                </query>
                <query type="else">
                    <htmltext><%img_photo%></htmltext>
                </query>
            </if>
        </reddot:cms></li>

Whenever I do either of these, one image shows up and the other doesn't. Depending upon what value I test, either the image that should be linked shows up, or the one that is not linked shows up, but I can't seem to get them both to show up (meaning something always fails). Any ideas on what I'm doing wrong here?

Jian Huang

unread,
Dec 5, 2012, 4:50:08 PM12/5/12
to reddot-c...@googlegroups.com
Hi Joel,

Regarding the first method:
GetElement(anc_link).Value[Int:0].Id fails if anc_link references a link instead of a page.  Plus, you will run into cache issue with this method.

Second method: getting really close, but <%anc_link%> cannot be inside a if statement because the & generated as part of the link breaks the rendertag.

However, you are just sooooooo close!

Solution:
<!IoRangeConditional><a href="<%anc_link%>"><!/IoRangeConditional><%img_photo%><!IoRangeConditional></a><!-- <%anc_link%> --><!/IoRangeConditional>

Joel Kinzel

unread,
Dec 6, 2012, 10:28:38 AM12/6/12
to reddot-c...@googlegroups.com
Awesome Jian! 

I've always avoided the conditionals because I wasn't quite sure how to get the trailing tag to disappear, but I guess I didn't think far enough outside the box! 

Joel
Reply all
Reply to author
Forward
0 new messages