Add paging in Content Query Web Part - xslt

I created a custom style in Content Editor Web Part by following this article: SharePoint 2010 XSLT date formatting and I achieved the desired result. But now I want to add paging to this new style. For adding paging I followed several articles but failed to achieve the result. I am a beginner in XSLT and cannot make out how exactly I can add paging in my custom style.
For paging I followed below articles but I don't have idea how can I combine the feature of paging with above custom calendar style. Any help is appreciated.
SharePoint 2010 Content Query Web Part with paging
Retro-fitting existing XSL Stylesheets with the Paging Controls
OOTB SharePoint CQWP Paging - CodePlex

Finally !! I did it myself. Following is what I executed:
I Opened SPD and copied ContentQueryMain.xsl and ItemStyle.xsl from XSL Stylesheet folder to a custom folder, while keeping both default xsl files unchanged.
I copied the xsl code and css code given in this article SharePoint 2010 XSLT date formatting to create the customized event calendar "Upcoming Events" (as shown in article) to my copied ItemStyle.xsl file. (Read the whole article and you will understand how you can perform this step).
Download: ImtechContentQueryWebPart.wsp custom web part from this link: http://imtech.codeplex.com/ [This web part is a custom Content Query Web Part through which you can apply your own xsl files).
Install the ImtechContentQueryWebpart to your SharePoint server and activate it through site collection features in Site Settings.
Now go step by step and make changes again to your copied ItemStyle.xsl and ContentQueryMain.xsl files as explained in this article: Retro-fitting existing XSL Stylesheets with the Paging Controls
The author in the article referenced in point 5 has pasted the code below
<xsl:template name="Default" match="*" mode="itemstyle"> Instead a I posted the code below this line
<xsl:template name="EventDisplay" match="Row[#Style='EventDisplay']" mode="itemstyle">
The above line having EventDisplay you will find in your copied & edited ItemStyle.xsl file. Simply search the term EventDisplay and you will get it.
Finally insert the Imtech Content Query Web Part to your page and copy the path of copied ItemStyle.xsl and ContentQueryMain.xsl files. Paste these paths as shown below in first image:
And the final result you get is: [*Please note the Leave Type and Click Here is appearing due to my own customized code in ItemStyle.xsl. Rest the output is same as shown in article referenced in point 2.]

Related

SharePoint 2013: Using StratusForms I deleted "NewForm.aspx", now only the new "NewForm" will not work

Tools: SharePoint 2013, SharePoint 2013 Designer, StratusForms
What I was doing: StratusForms - Modify SharePoint's Default Forms with HTML Templates (https://www.youtube.com/watch?v=oai-m_KyzMc)
Status: DispForm and EditForm currently work, NewForm did work until the incident.
Incident: I deleted the main webpart on NewForm and the form was hosed, so I deleted NewForm.aspx. I recreated the NewForm.aspx and also added it to forms library (https://sharepoint.stackexchange.com/questions/108467/accidentally-deleted-default-editform-aspx). Like before when it worked, I added a Content Editor webpart and pointed it to my StratusForms template, but it did not work . The controls/boxes did not show up. It worked before on the old NewForm, and it currently works on DispForm & EditForm.
Question: Given the above information does anyone know why, or better yet have a solution, to get NewForm.aspx working with StratusForms again?
Thank You!
So the underlying issue was SharePoints internal linkage of it's 3 forms (DispForm, EditForm, NewForm) to the data sources.
So those out-of-the-box forms are not like the ones we create. Even though you create a new "NewForm" and it may look like the old default NewForm, but it is not. There is metadata like Microsoft.SharePoint.PAGETYPE, which tells if it is a custom form or new, display, or edit form.
The resolution was found in this article (http://www.sharepointblogs.be/blogs/vandest/archive/2011/03/11/troubleshooting-issues-with-dispform-editform-and-newform.aspx).
In case the link breaks I have also included the manual method here:
Manually
It's easiest if you take a corresponding form from another SharePoint List in the site and export it (SharePoint Designer) or just copy it to a text editor. This way, most of the settings of the List Form Web Part are already correct
Generate a new GUID and fill that in for the __WebPartId [uppercase & just change a few chars/numbers] and properties [lowercase, same as WebPartID & has a g_ prefix] of the List Form Web Part markup. It has to be the same GUID but the formatting is different. See the above screens for samples
Update the property with the List ID you're targeting
Verify all other properties of the List Form Web Part and save the file as either DispForm.aspx, EditForm.aspx or NewForm.aspx
Import (SharePoint Designer) the page (or paste contents from the text editor)

Wagtail 2.0 Internal Link Not Working

I'm building a site with the new version of Wagtail (2.0) and when I try to add an internal link (a link to another page in my website) in a blog post using the Rich Text Editor, the hyperlink tags are stripped out and just the link text is showing. The code that gets rendered is <a id="5" linktype="page">sample page</a>.
If I add an external link, and set it to /sample-page/ then the hyperlink works as expected.
Does anyone know why this is happening?
When you output a rich text field on your template, you need to run it through the |richtext template filter:
http://docs.wagtail.io/en/v2.0.1/topics/writing_templates.html#rich-text-filter
This is because rich text is stored as a 'symbolic' variation of HTML, where items such as page links and images are represented as IDs rather than full URLs - this ensures that they won't break if a page is moved or renamed, for example. The |richtext filter is necessary to translate that symbolic HTML back to real HTML.

Clear Sitecore XSLT Cache

Question: Can anybody let me know on how to clear a sitecore xslt cache?
Problem : We have implemented Main Navigation and Footer Navigation from the same items in Sitecore.We had a urgent requirement to remove an item from Main Navigation and Footer.
We removed the item from Main Navigation by unpublishing the item in sitecore.However footer is implemented using XSLT as below :
<sc:xslfile visible="true" runat="server" id="xslFooter" cacheable="true" varybydata="true" />
Now even though the item is unpublished,it is still visible in the footer of the site and my guess is, it is because of XSLT cache.So can you please tell me on how this can be done.
Note:I can't write any code for this now as I need to remove immediately from live site.Also I can't clear using admin tool as it clears cache for all users?
So any solution for this?
Thanks,
Suhas
If you go to /sitecore/admin/cache.aspx you will be able to clear the cache, but I assume this is the admin tool you don't want to use.
You say that you don't want to clear the cache for all users, but I can't see a way around this because the cache is not user/visitor specific.
If acceptable, you can also clear the XSL cache by renaming/updaing/adding a file in the XSL folder.
The issue has been discussed here:
Sitecore XSL cache

SharePoint 2013 Can't edit the Content Editor snippet

In SharePoint 2013 it is possible to create master pages and page layouts using the new Design Manager. After converting a HTML file to a masterpage, or after creating a new page layout, one can add SharePoint functionality by using the Snippet Manager. I have used this approach to convert a static HTML/CSS file into an SharePoint masterpage with accompanying page layouts. I'm able to use all the snippets from the Snippet Manager, except for the "Content Editor" snippet. I was able to add top navigation, the quick launch bar, page properties and even "Web Part Zone" snippets.
The usecase:
I want to have a editable footer. The footer consists of four parts, so I added four Content Editor snippets, by pasting the snippet code into the HTML masterpage. When generating a snippet, it's possible to set custom properties. I noticed that it's not possible to set the WebPartID over here. In the snippet, the following WebPartID is always used: 00000000-0000-0000-0000-000000000000. The "Web Part Zone" snippet however will generate a (random?) WebPartID (and works).
The problem:
Adding the snippet works fine, but when I publish the master page or page layout it's not possible to edit the CEWP. When I edit a page which uses either the master page or the page layout, the CEWP should transform to an editable region, but it doesn't. There is no error shown. The webpart renders itself correctly.
What I tried:
I tried filling in a random WebPartID, but that doesn't work. Searching on Google and on StackOverflow didn't gave me any clues, I can't find anyone facing the same problem.
The code:
The following snippet is generated:
<!--CS: Start Content Editor Snippet--><!--SPM:<%#Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>--><!--MS:<WebPartPages:ContentEditorWebPart xmlns:WebPartPages="namespace" runat="server" webpart="true">--><!--PS: Start of READ-ONLY PREVIEW (do not modify)--><div class="ms-webpart-chrome ms-webpart-chrome-fullWidth "><div WebPartID="00000000-0000-0000-0000-000000000000" HasPers="true" id="WebPart" width="100%" class="ms-WPBody noindex " OnlyForMePart="true" allowMinimize="false" allowRemove="false" allowDelete="false" style=""><div class="ms-rtestate-field"></div><div class="ms-clear"></div></div></div><!--PE: End of READ-ONLY PREVIEW--><!--MS:<WebPart xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/WebPart/v2">--><!--MS:<Title>--><!--SPM:$Resources:core,ContentEditorWebPartTitle;--><!--ME:</Title>--><!--MS:<FrameType>--><!--SPM:None--><!--ME:</FrameType>--><!--MS:<Description>--><!--SPM:$Resources:core,ContentEditorWebPartDescription;--><!--ME:</Description>--><!--MS:<IsIncluded>--><!--SPM:true--><!--ME:</IsIncluded>--><!--MS:<ZoneID>--><!--SPM:ImportedPartZone--><!--ME:</ZoneID>--><!--MS:<PartOrder>--><!--SPM:0--><!--ME:</PartOrder>--><!--MS:<FrameState>--><!--SPM:Normal--><!--ME:</FrameState>--><!--MS:<Height>--><!--ME:</Height>--><!--MS:<Width>--><!--ME:</Width>--><!--MS:<AllowRemove>--><!--SPM:false--><!--ME:</AllowRemove>--><!--MS:<AllowZoneChange>--><!--SPM:false--><!--ME:</AllowZoneChange>--><!--MS:<AllowMinimize>--><!--SPM:false--><!--ME:</AllowMinimize>--><!--MS:<AllowConnect>--><!--SPM:true--><!--ME:</AllowConnect>--><!--MS:<AllowEdit>--><!--SPM:true--><!--ME:</AllowEdit>--><!--MS:<AllowHide>--><!--SPM:false--><!--ME:</AllowHide>--><!--MS:<IsVisible>--><!--SPM:true--><!--ME:</IsVisible>--><!--MS:<DetailLink>--><!--ME:</DetailLink>--><!--MS:<HelpLink>--><!--ME:</HelpLink>--><!--MS:<HelpMode>--><!--SPM:Modeless--><!--ME:</HelpMode>--><!--MS:<Dir>--><!--SPM:Default--><!--ME:</Dir>--><!--MS:<PartImageSmall>--><!--ME:</PartImageSmall>--><!--MS:<MissingAssembly>--><!--SPM:Cannot import this Web Part.--><!--ME:</MissingAssembly>--><!--MS:<PartImageLarge>--><!--SPM:/_layouts/15/images/mscontl.gif--><!--ME:</PartImageLarge>--><!--MS:<IsIncludedFilter>--><!--ME:</IsIncludedFilter>--><!--MS:<ExportControlledProperties>--><!--SPM:true--><!--ME:</ExportControlledProperties>--><!--MS:<ConnectionID>--><!--SPM:00000000-0000-0000-0000-000000000000--><!--ME:</ConnectionID>--><!--MS:<ID>--><!--SPM:g_2bfa6a66_54d1_45e6_84e7_ebbb461f2911--><!--ME:</ID>--><!--MS:<ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">--><!--ME:</ContentLink>--><!--MS:<Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">--><!--ME:</Content>--><!--MS:<PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">--><!--ME:</PartStorage>--><!--MS:<ID>--><!--SPM:g_a4deccb6_9661_415d_99c8_51f528cf7428--><!--ME:</ID>--><!--ME:</WebPart>--><!--ME:</WebPartPages:ContentEditorWebPart>--><!--CE: End Content Editor Snippet-->
This generates the following code in the .master file:
<WebPartPages:ContentEditorWebPart runat="server" webpart="true" __WebPartId="{B2063517-7C26-4084-AA28-36434C760CDB}"><WebPart xmlns="http://schemas.microsoft.com/WebPart/v2"><Title>$Resources:core,ContentEditorWebPartTitle;</Title><FrameType>None</FrameType><Description>$Resources:core,ContentEditorWebPartDescription;</Description><IsIncluded>true</IsIncluded><PartOrder>0</PartOrder><FrameState>Normal</FrameState><Height /><Width /><AllowRemove>false</AllowRemove><AllowZoneChange>false</AllowZoneChange><AllowMinimize>false</AllowMinimize><AllowConnect>true</AllowConnect><AllowEdit>true</AllowEdit><AllowHide>false</AllowHide><IsVisible>true</IsVisible><DetailLink /><HelpLink /><HelpMode>Modeless</HelpMode><Dir>Default</Dir><PartImageSmall /><MissingAssembly>Cannot import this Web Part.</MissingAssembly><PartImageLarge>/_layouts/15/images/mscontl.gif</PartImageLarge><IsIncludedFilter /><ExportControlledProperties>true</ExportControlledProperties><ConnectionID>00000000-0000-0000-0000-000000000000</ConnectionID><ID>g_2bfa6a66_54d1_45e6_84e7_ebbb461f2911</ID><ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
<Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor"><![CDATA[]]></Content>
<PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" /><ID>g_a4deccb6_9661_415d_99c8_51f528cf7428</ID></WebPart></WebPartPages:ContentEditorWebPart>
Some more information:
I'm pasting the snippets in the HTML file, as indicated. When I add a Web Part Zone snippet, I'm able to add working "Content Editor" WebParts in it. "Web Part Zone" snippets are only available in the Page Layout Snippet Manager though, so I can't use that as a workaround to get the footer in the masterpage to work.
My questions:
How can I add a Content Editor WebPart through the Snippet Manager?
Are there others facing the same problem?
Is it okay to leave the WebPartID 00000000-0000-0000-0000-000000000000?
Having fought a bit with SharePoint on this, this is what I found:
There are two different ways the Snippets created by the Snippet Manager work. If they are put anywhere within the html code of your Masterpage or Page Layouts, they will have the exact same configurations as the ones you select on the Snippet Editor, and you won't be able to edit them afterwards.
However, if you put them inside a Webpart Container Snippet code, you will be able to edit the webparts when accessing the Edit Page feature on SharePoint. As you probably figured out, this only works on page layouts and not on masterpages.
I believe a way to have a dynamic footer, is to use a Content By Search Web part and point it to a specific List (Footer List) and on that list you can have a column with a Rich Text Editor type, and then you can create a specific Display Template that will render the list content as desired.
Hope it makes some sense.

How to select only published items in XSLT-Umbraco?

i have a photo slider,there is next and prev buttons ,and when you click on a button,a pop-up window appears and show the big size of photos.Im using Umbraco,the xslt macro shows the nodes within the Gallery folder.xslt selects "Gallery/Photo" nodes.When i upload a photo,if i dont publish it,the sliders's next/prev buttons dont seem and pop-up dont work.How can i select only published items in Xslt ? Thanks in advance
I see this debate has sprung up again. It's not a direct answer to the problem, but should you understand Umbraco a little better ...
Umbraco & XSLT
Although Umbraco runs all it's data predominantly from a MS SQL database, it does however cache this data everytime a page is published/unpublished within a "hidden" XML file. It frees up the developer of any direct XML editing and leaves it to Umbraco. However, this makes it easy for a developer to forget or not even know it's there.
The file can be found in either of the following locations, dependant on which version you are using:
~/App_Data/umbraco.config
~/config/umbraco.config
The Problem
The XSLTs run using the umbraco.config file as it's XML source. However, this file will only contain published nodes. Unpublished nodes will be removed from the XML completely, so the XSLTs shouldn't be able to access unpublished nodes at all.
I suspect the problem may have to do with something other than unpublished nodes.
Without seeing your XSLT its difficult to guess what you're doing. However as #Goran states, XSLT in Umbraco can only access published nodes. This is because the data the XSLT has access to is the cached XML structure found in umbraco.config.
So, what is probably happening is that you actually want to exclude nodes that don't yet have an image assigned (even though the node itself is published).
You can do this using something like:
$currentPage//GalleryNode [image != '']
This will select all the GalleryNode elements under the current page that have an image property assigned.
If this is the case, you may want to consider making the image property mandatory to prevent any nodes from being published without an image.