Get a link in a CQWP to edit an item

Hi everyone!

I hope this could be of some use for you¬†ūüôā

I want:

An audiense filtered list of links where by clicking the link, I should end up being able to edit the item, not open the page it points to. After I have finished editing I should return to the page with links targeted to me (or any other page for that matter).

Ok this is what we have:

A links list called OrgLinks where we have activated Audience targeting settings. This list also has a custom column called Box that is of the type Managed metadata which is connected to a Term store called Linkboxes.
So each item is tagged with which box it should belong to and which part of the organization that should see it.

I have a page that consists of a number of CQWP that is querying this links list. Audience targeting is activated on these web parts and they are filtered on the values of the Term store Linkboxes.

On the same page, I have added a couple of buttons (targeted to editors) to make it easier to create new¬†items in this list and navigate to a page where you could edit items already created. This is actually the list that this blog is all about ūüôā

The thing is that even if you enable Audience targeting for a list, you can’t OOTB filter a lists view on audiences.

This is where the template I came up with for ItemStyles.xsl comes in. It could be that I am crossing the brook for water in my template but it gives me the result I want ūüôā

It was actually this template from Marc’s blog that got me in the right direction.

What it does is that it concatenate the link to the edit form of the item, the Item-ID and the URL to the page the user should go to after he or she is finished.

<xsl:template name="LinkListEdit" match="Row[@Style='LinkListEdit']" mode="itemstyle">
     <xsl:variable name="SafeLinkUrl">
         <xsl:call-template name="OuterTemplate.GetSafeLink">
             <xsl:with-param name="UrlColumnName" select="@URL"/>
         </xsl:call-template>
     </xsl:variable>
     <xsl:variable name="DisplayTitle">
         <xsl:call-template name="OuterTemplate.GetTitle">
             <xsl:with-param name="Title" select="@URL"/>
             <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
         </xsl:call-template>
     </xsl:variable>
     <xsl:variable name="TheList">
     <xsl:text disable-output-escaping="yes"> /alltomoss/_layouts/listform.aspx?PageType=6&amp;ListId={675357B2-D33C-4626-A61B-0FC978C0C09C}&amp;ID=</xsl:text>
     </xsl:variable>
     <xsl:variable name="Source">
     <xsl:text disable-output-escaping="yes">&amp;Source=/alltomoss/sidor/aoolankar.aspx</xsl:text>
     </xsl:variable>
          <xsl:variable name="TheLink">
          <xsl:value-of select="concat($TheList, @ID, $Source)" />
          </xsl:variable>
     <div id="linkitem">
         <xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
         <a href="{$TheLink}" title="Redigera länken">
         <xsl:value-of select="substring-after($DisplayTitle,',')"/>
         </a>
     </div>
 </xsl:template>

Before we actually could use this template and use it it in our CQWP we need to export the webpart and add a couple of things to it. Change CommonViewFields to look like this:

 <property name="CommonViewFields" type="string">URL,Text; </property> 

Then as “usual” import it again and add it to the page.

CU!

/Niax

Advertisements