0

I have added an XsltListViewWebPart which refers to the Asset Library in the site. I have given reference of AssetPick.xslt for thumbnail view for that web part. I want to put the Title in place of Name of each image. How should I do that ? Please help.

  • Any updates on this? I have the similar issue. – Hatallia Makarevich Sep 26 '13 at 12:15
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. – Stu Pegg Sep 26 '13 at 12:45
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. – John Chapman Sep 26 '13 at 13:34
1

I did following steps to get the Image Title instead of Image Name.

First of all download the AssetPick.xslt and copy it to your local machine.

Edit file with any editor and locate to <!--do this directly rather than call below to cut out new file status image--> (Line 90)

Place following tags.

 <a onfocus="OnLink(this)" href="{$thisNode/@FileRef}" onclick="return DispEx(this,event,'TRUE','FALSE','{$thisNode/@File_x0020_Type.url}','{$thisNode/@File_x0020_Type.progid}','{$XmlDefinition/List/@DefaultItemOpen}','{$thisNode/@HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon}','{$thisNode/@HTML_x0020_File_x0020_Type}','{$thisNode/@serverurl.progid}','{$thisNode/@CheckoutUser.id}','{$Userid}','{$XmlDefinition/List/@ForceCheckout}','{$thisNode/@IsCheckedoutToLocal}','{$thisNode/@PermMask}')">
            <xsl:value-of select="$thisNode/@Title" />
          </a>

(See <xsl:value-of select="$thisNode/@Title" /> we placed @Title in place of @Name)

Save the file and upload it to the Style Library in new folder name "Custom View" and upload the modified file under that folder.

Now run the below console application which assigns the XsltListViewWebPart to the thumbnail view:

static void Main(string[] args)
    {
        SPSite site = new SPSite("http://.........");
        SPWeb web = site.RootWeb;
        SPList list = web.Lists["Images"];
        web.AllowUnsafeUpdates = true;

        SPLimitedWebPartManager webParts = web.GetLimitedWebPartManager(web.Url + "/SiteAssets/WebParts.aspx", System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
        XsltListViewWebPart webPart = new XsltListViewWebPart();
        webPart.ListId = list.ID;

        webPart.ViewGuid = list.DefaultView.ID.ToString();

        SPFile file = web.GetFile(web.Url+"/Style Library/Custom View/AssetPicker.xsl");
        StreamReader reader = new StreamReader(file.OpenBinaryStream());
        webPart.Xsl  = reader.ReadToEnd();
        webParts.AddWebPart(webPart,"Body",0);
        webParts.SaveChanges(webPart);
        web.Update();
        web.AllowUnsafeUpdates = false;
        Console.WriteLine("Web part added successfully");
        Console.ReadKey();
    }

The web part will be added to the Web Part Page.

This worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.