Sharepoint:ListFieldIterator - ExcludeFields property does not work - sharepoint

I've written a completely new page that uses Sharepoint's ListFieldIterator. I would like to exclude few fields from the view and I've found a solution using ExcludeFields but it simply doesn't work. The control always displays all fields, nevermind what's in ExcludeFields property. I couldn't find anyone complaining about such a problem on the internet.
There's the code (nothing fancy):
<Sharepoint:ListFieldIterator ID="lfiItemDetails" ControlMode="Display" runat="server" ExcludeFields="TestId" />
ListId and ItemId are set programmatically in OnInit.

Try it with a hash. So for the column I want to hide called "PrintOrder" I changed it from:
<SharePoint:ListFieldIterator ControlMode="Display" TemplateName="WideFieldListIterator" ExcludeFields="FileLeafRef;#WikiField" runat="server"/>
to
<SharePoint:ListFieldIterator ControlMode="Display" TemplateName="WideFieldListIterator" ExcludeFields="FileLeafRef;#WikiField;#PrintOrder" runat="server"/>
That worked for me.

Incase anyone else hits this. ExcludeFields dow not work if ControlMode is Display(at least on my version of. You need to either hide the field with Javascript or set ShowInDisplayform=False

Related

Hide Sign Out Link in Liferay 6.2 Dockbar

In Liferay 6.1, we created a hook to hide the sign out link in the dockbar. However, when I look at the code for 6.2, I see the following:
<c:if test="<%= themeDisplay.isShowSignOutIcon() %>">
<aui:nav-item cssClass="sign-out" href="<%= themeDisplay.getURLSignOut() %>" iconCssClass="icon-off" label="sign-out" />
</c:if>
No matter how much I google, I can't find any reference to themeDisplay.isShowSignOutIcon(), aside from the API reference, which does me no good, as it is not commented at all. I did find the page that discusses the native LR theme properties and apparently determining whether to show/hide a sign out linkn is not one of the native theme properties.
Does anyone know if you can set the theme itself to show/hide the sign out link and how you would go about doing it?
I too analyzed ServicePreAction code, and found that all this code does is:
checks if the user is logged in or not
if yes, shows 'sign out' link, not otherwise
You can simply create a hook to override html/portlet/dockbar/view_user_account.jspf to either remove that code snippet from this jsp to hide it for all scenarios OR modify the condition to show/hide as per your requirements.
The only place that I've found where ThemeDisplay.setShowSignOutIcon is called is in ServicePreAction (linking master branch here). That being said, it looks like it's not configurable, but you can easily create another ServicePreAction in a hook. Please see an example in this plugin (referencing portal.properties and liferay-hook.xml, but naturally there's also code that I'm sure you'll find. It's not big)
Another option - if you just want to unconditionally get rid of the link: Use CSS to hide it. Yes, it will still be there, but any way you choose to hide the link, the actopm at /c/portal/logout will still be available...

LifeRay form validation using Alloy UI

I use LifeRay 6.1.2. And it have built-in Alloy UI 1.5. framework. So I try to reproduce this form validation example (I copied all code), but it don't work as expected (error labels in DOM, but they are don't visible in form (see EDIT1)):
Expected result is (you can try yourself live example using link provided above):
Where is problem? How to solve it? Thanks.
EDIT1:
After some research, I realized that if I delete aui-form-validator-message CSS class from error message's DIV tag (it generated by LifeRay, I'm not adding it), then error message become visible. Strange..
You should post your own code, or it's difficult to answer.
Anyway if you want you could try the aui validator tag for example:
<aui:input name="name" value="${name}" label="name">
<aui:validator name="required" errorMessage="your-message-here"></aui:validator>
</aui:input>
learn more # http://drewblessing.com/blog/-/blogs/34509
Hope it helps!
I think you have not used the tag in your code.
<script src="http://cdn.alloyui.com/2.0.0/aui/aui-min.js"></script>
Paste this and check.

RenderPattern headache with WSS 3.0 Document Library

I'm trying to define the DisplayPattern of a custom field to do as follow. It's a simple text field used in document libraries, but i want the text entered to be displayed as a link to the document in the list view.
<URL Cmd="Display"> gives me the display form, but I want the link to actually download/open the document...
I can't for the life of me figure this one out...
Thanks for your help!
The answer lied in <LookupColumn Name="FileLeafRef" /> used along with <ListUrlDir />...

Is it possible to format a NumberField in a page layout?

I'm developing a SharePoint publishing site and setting up its content types and page layouts. I need to display the value for a Year field with type Number. The markup currently is:
<SharePointWebControls:NumberField FieldName="Year" runat="server" id="Year" />
The problem with the default behaviour is that it shows each number with a comma, e.g. "2,009" instead of "2009". Is there a way I can set some sort of String.Format syntax on the field to make it display correctly?
I tried creating a new rendering template which looks like this:
<SharePoint:RenderingTemplate ID="YearNumberField" runat="server">
<Template>
<SharePoint:FormField ID="TextField" runat="server"/>
</Template>
</SharePoint:RenderingTemplate>
... but there doesn't appear to be any 'Format' property on the FormField object.
Thanks for any help.
Update:
I tried wrapping the SharePoint:FormField tag inside SharePoint:FormattedString. Unfortunately the field was not formatted, same results as this question.
The issue is that the rendering template must use FormField. This always renders the value in the format: 1,989 . To resolve this the rendered text needs to be trapped and altered to get the desired output. Here are two approaches to resolving this:
1. Write a custom control inherited from NumberField
The RenderFieldForDisplay and RenderFieldForInput methods can be overridden to provide the desired output. Additional properties can be added to the control to describe additional behaviour.
Pros: No changes to rendering templates required.
2. Write a custom control for use in the rendering template
A control that (for example) uses regular expressions to alter text can wrap around the FormField control.
<SharePoint:RenderingTemplate ID="YearField" runat="server">
<Template>
<RX:RegexManipulatorControl runat="server"
Mode="Replace"
Expression=","
Replacement="">
<SharePoint:FormField runat="server"/>
</RX:RegexManipulatorControl>
</Template>
</SharePoint:RenderingTemplate>
Pros: Generic solution can be used for any type of field.
from Just Another SharePoint Blog
Open the list view in SharePoint
Designer.
Right click on the data view web part.
(the list)
Select Convert to XSLT Data View
Click on the number field you would
like to format
A > will appear showing Data Field,
Format As
Click on the link below Format As -
Number formatting options
Under Options deselect Use 1000
separator
Click OK
Save your changes and hit F12 to
preview

SharePoint - Custom Dataview - Link Rendering Issues

I have a custom SharePoint page with several dataviews. The dataviews essentially filter documents matching a certain criteria from a document library and display a link to the document along with some other meta data.
The problem I have is that when a document has a single quote in it's title, the character is being rendered as ' and invalidating the link. This is the code within my custom page that is displaying the invalid link.
<A onfocus="OnLink(this)" HREF="{#FileRef}" onclick="return DispEx(this,event,'','','','','{ddwrt:ListProperty("DefaultItemOpen")}','{ddwrt:MapToControl("", string())}','{#HTML_x0020_File_x0020_Type}','','{ddwrt:GetUserID('CheckoutUser')}','{$Userid}','{ddwrt:ListProperty("ForceCheckout")}','{$FieldIDA5KNTB}','{ddwrt:CurrentRights()}')"><xsl:value-of select="ddwrt:UrlBaseName(string(#LinkFilename))" /></A>
Does anyone have any thoughts on how I can ensure the #FileRef variable is encoded correctly before being rendered?
Many thanks in advance :)
you need to use the ServerURL or EncodedAbsUrl properties, this guys written it out already:
Itay Shakury's blog

Resources