Access contents of a fragment if its path is available to rendering container - fragment

I have a content fragment which hold the reference to a file under assets, on the page the fragment is rendered on a component
Example:
Content Fragment : /content/dam/fragment_name
File path under above fragment :
/content/dam/we-retail/en/activities/running/Image_name.jpg
Now I need to get the contents of the fragment to the component html, so that I can have full control of fragment elements programatically.
It should be achieved only through Sightly without using java sling model.

Related

AEM Content Fragment fields values does not sent for translation

I tried to translate the Content Fragment content but that content is not sent for translation.
Let's take an example, suppose, we have a Content fragment model, named "Press Release" and there are 2 fields "title" and "description". Once we create a content fragment based on the "Press Release" model and Create a Translation project then content fragment fields are not going for translation,
I am using AEM 6.5.12.0 version,
I tried to add some translation rules but that also does not help, I am sure there are some issues with writing a Translation rule for translating against the Content Fragment Model.
Can anyone please help me with this?
First did you create the target language folder in the assets? it is necessary for AEM to know where it needs to create the target.
Assets language structure
How do you add translation rules?
for title and description the properties in translation config UI should be: jcr:title and jcr:description
Translation config UI
Check this file in the CRXde /conf/global/settings/translation/rules/translation_rules.xml that:
is at after
you have those 2 properties under content/dam
hope it will help
Seb

ZK framework - no content in include

We have a tabbox whose tabpanels use include to include content:
<tabpanels height="100%">
<tabpanel>
<include src="#load(vm.myTabUrl)" />
</tabpanel>
...
</tabpanels>
Once in a while in production, the content of the include is not displayed. This behavior seems to be random and we don't know how to replicate it.
When it happens, the generated html contains a <div> for the include which only contains another empty <div> with class z-tmp:
ZK doesn't show any errors while rendering and neither does the javascript console. Also there are no failed http (zkau) requests. Any ideas?
ZK Client Engine is responsible for conversion of ZUL to HTML at client side.
ZK has a huge in-built component support compared to HTML. But the things that are displayed on Client side will be HTML itself.
We design a page in ZUL and it is converted into HTML in action. ZUL Components are larger than HTML components in number but in the end we get HTML components only with some changes in their structure.
How the ZUL page reconstructed to HTML page ?
ZUL page are converted to Div, input, anchor mostly.
ex: Groupbox
(ZUL) --> Multiple Div (HTML)
The ID of the DOM components are dynamically generated after conversion like z_p5,z_g3 and the ID
i.e given in ZUL page can be added at AID of the Component.
The DOM component can be allowed to have multiple styles separated
by spaces.
The Widget name is added to the component style as z-widget along
with our regular styles mentioned in ZUL page. The ZK Component name is added as z-widget in the style attribute of generated HTML DOM Component. As you have already seen that z-include is added in the style attribute of Div element in the above screenshot after generation
of page.
Coming to the Actual problem,
Open the AfterCompose method of the ViewModel of this page.
Assign myTabUrl directly with another ZUL page path and Notify it with
postNotifyChange method from below.
BindUtils.postNotifyChange(null, null, ClassName.this, "myTabUrl");
May be Variable is not properly assigned or Notifying the variable may be missed which caused this problem. If possible post the ZUL and VM code here if problem still not resolved after this trial.

How can we extend the foundation clientlib js scripts in AEM?

I want to extend the AEM foundation file fileuploadfield.js for making changes in custom image component dialog like want to display the image path and file size which author can be dragged into the dialog. It's really great-full if any body give an idea. Thanks in advance.enter image description here

AEM Page Image in Page Properties Doesn't Apply a sling:resourceType

Using Adobe Experience Manager 5.6.1 (AEM) (Formerly CQ5) I am trying to create a new tab similar to the Image tab in Page Properties. It would be titled "Logo".
I basically just copied the Image tab to create a logo tab and renamed the paths to reflect the logo purpose. For instance, I set the fileReferenceParamater to ./logo/fileReference and requestSuffix to /logo.img.png.
When I edit the properties, I can drag an image into the tab just as I can with the "Image" tab, however, the image never appears there. I am guessing this is because the default image handler is not picking up the request. The error is:
Cannot serve request to
/content/my-site/home-page/en_us/jcr:content/logo.img.png in
org.apache.sling.servlets.get.DefaultGetServlet
When I looked at the content node there was no sling:resourceType. When I added a resource type of foundation/components/adaptiveimage then it worked. However, I noticed that the "Image" node didn't have a sling:resourceType. I guess the img.png.java servlet in the foundation page is handling that request.
I tried creating a logo.img.png.jsp file in my page component to handle the request, but that didn't seem to work.
How can I get AEM to either add the sling:resourceType or to handle the request?
I was facing the similar problem and I found a simpler way to resolve. All you need to do is to add a hidden xtype under the your logo image as below:
<yourlogo
jcr:primaryType="cq:Widget"
<-- other properties -->
xtype="html5smartimage">
<items jcr:primaryType="cq:WidgetCollection">
<resType
jcr:primaryType="cq:Widget"
ignoreData="{Boolean}true"
name="./logo/sling:resourceType"
value="foundation/components/image"
xtype="hidden"/>
</items>
</yourlogo>
Well, after some time experimenting, this is what I ended up doing to get this to work. If there is an easier way, I would be happy to know it.
First, I copied the /libs/foundation/components/page/img.png.java file and added it to my compiled package with some modifications.
#SlingServlet(
resourceTypes = "sling/servlet/default",
selectors = "imgnode",
extensions = {"png","jpg","jpeg","gif"},
methods = "GET"
)
public class SimpleImageServlet extends AbstractImageServlet {
Where img.png.java had the following line:
Image image = new Image(c.resource, "image");
I changed it to:
Image image = new Image(c.resource);
This relies on SCR annotations to generate the OSGi configuration so that this servlet will handle image requests having the imgnode selector. Instead of looking for a child image node it just expects the current resource to be an image.
Second, I added a component to the body.jsp overlay of the page component, like so.
<cq:include path="logo" resourceType="/apps/my-site/components/logo" />
This maps the logo path to a component for rendering.
Third, within the logo.jsp on the component I set the selector to imgnode rather than img.
Image img = new Image(resourcePage, "logo");
img.setSelector("imgnode");
I believe this step would be similar if the adaptiveimage were overlayed. You just need to render out URLs that include the imgnode selector.
Fourth, I setup the logo image dialog tab in page properties to use the expected requestSuffix and set the other properties to point to the logo sub-node.
Examples:
requestSuffix = "/logo.imgnode.png"
fileReferenceParameter = "./logo/fileReference"
Fifth, I made sure that the image dialog tab for the /apps/my-site/components/logo component pointed to itself.
Examples:
requestSuffix = ".imgnode.png"
fileReferenceParameter = "./fileReference"
Now whether it is in page properties, component editing, or final rendering, the image is handled appropriately.
this is a bit of a nuisance with using the image widget controls--only the image component nicely handles the data, and the servlet that handles ".img" is tied to the image component resourceType.
the easiest thing is to just use the value of the fileReference property instead of referencing the image as part of the page. since you're using assets from DAM, this is a reasonable approach.
this doesn't address the issue with a user uploading an image directly. i wanted to suggest having a hidden field like "./logo/sling:resourceType", but testing that locally resulted in an error when trying to save the dialog.
another approach is the following:
<sling:include resourceType="foundation/components/adaptiveimage" resource="${resource.path}/logo" />
(assuming resource is jcr:content). this is effectively the same as adding a sling:resourceType, but there are at least 2 downsides:
the image becomes authorable at that point as opposed to in the dialog
this method only works for rendering a normal tag. it won't work for any sort of background image

resolving paths in aspx user control

I am building an asp.net website and wish to create a user control that includes a reference to a graphic file in a different directory. Specifically my directory structure looks like:
c:\mywebsite\
c:\mywebsite\images\
c:\mywebsite\usercontrols
The user control will be used in c:\mywebsite\default.aspx
The image is c:\mywebsite\images\logo.jpg
The user control is c:\mywebsite\usercontrols\mycontrol.ascx
If in my ascx file I have:
<img src="../images/logo.jpg" />
Then this renders just fine in the Visual Studio 2010 design view, but not at run time since at run time the control is included in \default.aspx and the path relative to \default.aspx is different from the relative path from \usercontrols\mycontrol.ascx.
How should I reference the graphic from the ascx file so that it will render properly both in design preview as well as at runtime? Also I would like it to render properly in design preview for default.aspx where it is used.
You can use <asp:Image>... control and use the image path as relative path from the web root
<asp:Image ImageUrl='~/Images/logo.jpg" runat="server" />
view html output generated in browser, find there the image file path placed by your usercontrol and make change in path in your usercontrol