How to Count the Files in Attached(uploaded) - count

I need to count how many Attachments(UploadCollectionItem) I have uploaded by the UploadCollection.
Here is my code:
<IconTabFilter icon="sap-icon://attachment"
stretchContentHeight="true" text="Anexos"
count=""
>
<UploadCollection id="uploadCollection" items="{path: 'att>/d/results'}"
uploadComplete="onAttachmentUploadComplete" change="onAttachmentChange"
fileDeleted="onAttachmentDeleted" sameFilenameAllowed="true"
uploadUrl="/sap/opu/odata/sap/ZWEB_MM0007_SRV/FileProcessSet">
<items>
<UploadCollectionItem id="idUploadListItems"
documentId="{att>Id}" fileName="{att>FileName}" mimeType="{att>MimeType}"
uploadedDate=""
url="/sap/opu/odata/sap/ZWEB_MM0007_SRV/FileProcessSet(Id='{att>Id}',Filename='{att>FileName}',Requisicao='')/$value"
enableEdit="false" visibleEdit="false" visibleDelete="true" />
</items>
<parameters />
</UploadCollection>
</IconTabFilter>
I want to display the corresponding number of attachments on the Icon.

My suggestion would be:
<IconTabFilter icon="sap-icon://attachment"
stretchContentHeight="true" text="Anexos"
//here the count
count="{att>/d/results.length}"
>
<UploadCollection id="uploadCollection" items="{path: 'att>/d/results'}"
uploadComplete="onAttachmentUploadComplete" change="onAttachmentChange"
fileDeleted="onAttachmentDeleted" sameFilenameAllowed="true"
uploadUrl="/sap/opu/odata/sap/ZWEB_MM0007_SRV/FileProcessSet">
<items>
<UploadCollectionItem id="idUploadListItems"
documentId="{att>Id}" fileName="{att>FileName}" mimeType="{att>MimeType}"
uploadedDate=""
url="/sap/opu/odata/sap/ZWEB_MM0007_SRV/FileProcessSet(Id='{att>Id}',Filename='{att>FileName}',Requisicao='')/$value"
enableEdit="false" visibleEdit="false" visibleDelete="true" />
</items>
<parameters />
</UploadCollection>
</IconTabFilter>

Related

How to disable checkboxes 's option in dialog.xml in CQ5 AEM?

I have designed my CQ5 dialog as given in the following image. I have to disable my checkboxes options as highlighted in the image.
And dialog.xml is like
<stewartOwned jcr:primaryType="cq:Widget"
defaultValue="false" fieldLabel="Stewart Owned"
inputValue="false" name="./stewartOwned" type="checkbox"
xtype="selection" layout="hbox">
<options jcr:primaryType="cq:WidgetCollection">
<option1 jcr:primaryType="nt:unstructured" text=""
value="stewartOwned" />
<option2 jcr:primaryType="nt:unstructured" text=""
value="ShowInAdvanced" />
</options>
<optionsConfig jcr:primaryType="nt:unstructured"
width="150" />
</stewartOwned>
<independent jcr:primaryType="cq:Widget"
defaultValue="false" fieldLabel="Independent" inputValue="false"
name="./independent" type="checkbox" xtype="selection"
layout="hbox">
<options jcr:primaryType="cq:WidgetCollection">
<option1 jcr:primaryType="nt:unstructured" text=""
value="I" />
<option2 jcr:primaryType="nt:unstructured" text=""
value="ShowInAdvanced" />
</options>
<optionsConfig jcr:primaryType="nt:unstructured"
width="150" />
</independent>
I have tried following solution to disable through id but it is not viable as id is auto generate and you never know what id will be generated in the next session.
listeners jcr:primaryType="nt:unstructured"
loadcontent="function(dialog) {
CQ.Ext.getDom('ext-comp-1568').disabled = 'disabled';
CQ.Ext.getDom('ext-comp-1573').disabled = 'disabled';
}" />
Can someone please suggest how I disable highlighted checkboxes in dialog.xml ?
After a lot of research and reading CQ5 documentation, I managed to find out following solution.
var nameField =
dialog.getField('./name').getEl().child('input[value*=ShowInAdvanced]').id;
CQ.Ext.getDom(nameField).disabled = 'disabled';

AEM/CQ Multiple Image Component

I'm trying to create a component with two images and some information, i have created the dialog, managed to create the nodes and upload the image. Everything works fine but i can't find a way to get the image's path or render it.
This is what i have so far:
<%# page import="com.day.text.Text,
com.day.cq.wcm.foundation.Image,
com.day.cq.commons.Doctype" %>
<%#include file="/apps/platform/aem-core/global/global.jsp"%>
<%
Image image = new Image(resource, "image1");
out.println(image);
image.draw(out);
%>
<h2><%=image.getSrc()%></h2>
This gives me: /content/region-growth/brazil/brazil-poc/pt-br/home/jcr:content/leadmachine-new/image1/file.jpg/1456255696906.jpg and if i go to this folder there is a node called image1 > file. The image is there, if i try to download it using crxde i can open it so i believe my problem is with the path.
This is the dialog XML:
<dialog jcr:primaryType="cq:Dialog"
title="Lead Machine"
xtype="dialog">
<items jcr:primaryType="cq:TabPanel">
<items jcr:primaryType="cq:WidgetCollection">
<generalTab jcr:primaryType="cq:Panel"
title="Geral">
<items jcr:primaryType="cq:WidgetCollection">
<campanhaID jcr:primaryType="nt:unstructured"
allowBlank="false"
fieldLabel="Campanha ID"
name="./jcr:campanhaid"
xtype="textfield" />
<titulo jcr:primaryType="nt:unstructured"
allowBlank="false"
fieldLabel="Título"
name="./jcr:titulo"
xtype="textfield" />
<corFundo jcr:primaryType="nt:unstructured"
allowBlank="false"
fieldLabel="Cor de Fundo"
name="./jcr:corfundo"
xtype="colormenu" />
<corBotao jcr:primaryType="nt:unstructured"
allowBlank="false"
fieldLabel="Cor do Botão"
name="./jcr:corbotao"
xtype="colormenu" />
<txtBotao jcr:primaryType="nt:unstructured"
allowBlank="false"
fieldLabel="Texto do Botão"
ame="./jcr:txtBotao"
xtype="textfield" />
<texto jcr:primaryType="nt:unstructured"
allowBlank="true"
fieldLabel="Texto"
name="./jcr:texto"
xtype="richtext" />
<observacao jcr:primaryType="nt:unstructured"
allowBlank="true"
fieldLabel="Observação"
name="./jcr:observacao"
xtype="richtext" />
<layoutForm jcr:primaryType="cq:Widget"
fieldDescription="LM com formato simples"
fieldLabel="Layout Form"
inputValue="true"
name="./layoutForm"
type="checkbox"
xtype="selection" />
<agendamento jcr:primaryType="cq:Widget"
fieldDescription="LM com agendamento"
fieldLabel="Agendamento"
inputValue="true"
name="./agendamento"
type="checkbox"
xtype="selection" />
<ativo jcr:primaryType="cq:Widget"
fieldLabel="Ativo"
inputValue="true"
name="./ativo"
type="checkbox"
xtype="selection" />
</items>
</generalTab>
<tab1 jcr:primaryType="cq:Panel" title="Image Properties">
<image1ResType jcr:primaryType="cq:Widget" ignoreData="{Boolean}true" name="./image1/sling:resourceType" value="foundation/components/image" xtype="hidden"/>
<image2ResType jcr:primaryType="cq:Widget" ignoreData="{Boolean}true" name="./image2/sling:resourceType" value="foundation/components/image" xtype="hidden"/>
</tab1>
<tab2 jcr:primaryType="cq:Widget"
cropParameter="./imageCrop"
fileNameParameter="./fileName"
fileReferenceParameter="./fileReference"
mapParameter="./imageMap"
name="./file"
requestSuffix="/img.jpg"
rotateParameter="./imageRotate"
title="Image 1"
xtype="html5smartimage" />
<tab3 jcr:primaryType="cq:Widget"
cropParameter="./mdImageCrop"
fileNameParameter="./mdFileName"
fileReferenceParameter="./mdFileReference"
mapParameter="./mdImageMap"
name="./mdFile"
requestSuffix="/mdImage.img.jpg"
rotateParameter="./mdImageRotate"
title="Image 2"
xtype="html5smartimage" />
</items>
</items>
</dialog>
Node childNode = currentNode.getNode("file");
if (childNode != null) {
if (childNode.hasProperty("fileReferenceParameter")) {
return childNode.getProperty("fileReferenceParameter").getString();
}
}
And why do you use hidden imageResType in tab1?
Also you may use the following using image object:
<%
Image image = new Image(resource, "file");
%>
<img src='<%=image.getSrc()'/>

Is it possible to remove the "Upload MM Component" button from the SDL Tridion 2011 Ribbon

This button causes a lot of problems for my client, as it always uses a predefined Schema. I can't find a way to remove this button with my Editor config. I have done this with other buttons, but these buttons are implemented in some sort of sub-group.
On my personal sandbox machine, I tried removing the commented out control in the extract of the ../WebUI/Editors/CME/Controls/Toolbars/Tabs/CreateRibbonPage.ascx file shown below:
<c:RibbonSplitButton runat="server" CommandName="NewComponent"
Title="<%$ Resources: Tridion.Web.UI.Strings, NewComponent %>"
Label="<%$ Resources: Tridion.Web.UI.Strings, NewComponent %>"
ID="NewComponentBtn1">
<c:RibbonContextMenuItem runat="server" ID="NewComponentCMI2"
Command="NewComponent"
Title="<%$ Resources: Tridion.Web.UI.Strings, NewComponent %>"
Label="<%$ Resources: Tridion.Web.UI.Strings, NewComponent %>" />
<c:RibbonContextMenuItem runat="server" ID="NewMultimediaComponentCMI2"
Command="NewMultimediaComponent"
Title="<%$ Resources: Tridion.Web.UI.Strings, NewMultimediaComponent %>"
Label="<%$ Resources: Tridion.Web.UI.Strings, NewMultimediaComponent %>" />
<!--
<c:RibbonUploadContextMenuItem runat="server"
ID="NewBasicMultimediaComponentCMI2" Command="NewBasicMultimediaComponent"
Title="<%$ Resources: Tridion.Web.UI.Strings, NewBasicMultimediaComponent %>"
Label="<%$ Resources: Tridion.Web.UI.Strings, NewBasicMultimediaComponent %>" />
-->
</c:RibbonSplitButton>
This seems to have the desired result, but I imagine that this will probably invalidate our support agreement if I did this in a customer environment. Is this possible to do in a supported way, or do I have to hack the UI files like this to achieve my goal?
One of the solutions is to create extension for the NewBasicMultimediaComponent command, which extends isAvailable and isEnabled methods and returns false for them. In this case "Upload MM Component" still will be present as an option for "New Component" button, but it will be disabled.
I've used css to hide the display of ribbon items before. Purely because I couldn't find the appropriate solution.
I'm adding this answer because I needed to do something similar with a complete ribbon toolbar.
I needed to remove the complete ribbon toolbar "Create" in order to add a simpler version of it and it seems you can do the removal part by creating a new extension and use this in your extensions config:
<?xml version="1.0"?>
<Configuration xmlns="http://www.sdltridion.com/2009/GUI/Configuration/Merge" xmlns:cfg="http://www.sdltridion.com/2009/GUI/Configuration" xmlns:ext="http://www.sdltridion.com/2009/GUI/extensions" xmlns:cmenu="http://www.sdltridion.com/2009/GUI/extensions/ContextMenu" xmlns:edt="http://www.sdltridion.com/2009/GUI/Configuration/Merge">
<resources>
<cfg:groups />
</resources>
<definitionfiles />
<extensions>
<ext:editorextensions>
<ext:editorextension target="CME">
<ext:editurls />
<ext:listdefinitions />
<ext:itemicons />
<ext:taskbars />
<ext:commands />
<ext:commandextensions />
<ext:contextmenus />
<ext:lists />
<ext:tabpages>
</ext:tabpages>
<ext:toolbars>
</ext:toolbars>
<ext:ribbontoolbars>
<ext:remove>
<ext:extension id="CreatePage">
<ext:apply>
<ext:view name="DashboardView">
<ext:control id="DashboardToolbar" />
</ext:view>
</ext:apply>
</ext:extension>
</ext:remove>
</ext:ribbontoolbars>
<ext:extendedareas />
</ext:editorextension>
</ext:editorextensions>
<ext:dataextenders />
</extensions>
<commands />
<contextmenus />
<localization />
<settings>
<dependencies />
<defaultpage />
<editurls />
<listdefinitions />
<theme>
<path>/Themes/</path>
</theme>
<customconfiguration />
</settings>
</Configuration>
To make this work for buttons you probably can do the same thing (haven't tested this), by providing the button id in the ext:extension id attribute.

asp:menu Remove inline styles and div

I have a have an asp:Menu and i am using css classes to format this menu.
<asp:Menu ID="MenuMain" runat="server" DataSourceID="SiteMapDataSource"
Orientation="Horizontal" RenderingMode="List" SkinID="None"
IncludeStyleBlock="false" StaticDisplayLevels="1">
<StaticMenuStyle CssClass="nav" />
<StaticSelectedStyle CssClass="active" />
<LevelSubMenuStyles>
<asp:SubMenuStyle CssClass="level1" />
<asp:SubMenuStyle CssClass="level2" />
</LevelSubMenuStyles>
However asp.net dynamically adds the inline styles and divs that are generated by javascript associated to the menu.
Is there anyway to prevent this ?
Add your own css class with different names and associate them with this in CssClass
<StaticMenuStyle CssClass="nav" />
<StaticSelectedStyle CssClass="active" />
<LevelSubMenuStyles>
<asp:SubMenuStyle CssClass="level1" />
<asp:SubMenuStyle CssClass="level2" />
</LevelSubMenuStyles>
Hope it helps.
Don't forget to upvote it if it solves you problem.
Thanks.. :)

How to add new line character in following code?

When i inserting the data in database then there is facility to the user that in multiline textbox he can write sentence in multiple line.
So when i am populating the same data the database it populate the data like this : fffffffffffffffffffffffffffffff<br /> f<br /> f<br /> f<br /> f<br /> f<br /> f<br /> f<br /> f<br /> <br /> ff<br /> f<br /> f<br /> <br /> <br /> <br /> fff
but i want to remove &lt, &gt ,br. For this i have used following code but my purpose is not solved. So how to do that:
txtEditorOpportunity.Text = dbReader["DESCRIPTION"].ToString().Replace("<br/>", "\n");
There is a space in the <br /> tag in your question, so while using Replace method. Try it like
.Replace("<br />", "\n");
Note the space character between br and / which makes it <br /> and NOT <br/>
You are doing it correctly. Just observe the tags that you are getting, they contain a space between "". So make sure that you put a space in your replace command accordingly.
Something like this.
.Replace("<br />", "\n");
Some browsers treat <br /> as just <br>, so to be sure that nothing goes wrong, you can replace the above code with the following code.
.Replace("<br />", "\n").Replace("<br>", "\n");

Resources