Including a content page inside an AEM component - aem

How to display a page which is inside /content/proj/en inside a component.Given that the page will be available in all the environments.

Simplest way, you can do a sling include.
If you are using JSP
<sling:include path="/content/proj/en/jcr:content" />
If you are using HTL
<sly data-sly-resource="${'/content/proj/en/jcr:content' # wcmmode=disabled}"></sly>
You can remove the wcmmode=disabled if you want the rendered resource to be editable.

Related

How to add Alt tag for the image in the Teaser component in AEM?

I would like to add the alt tag similar to the image component in the teaser component.
The OOTB teaser component uses data-sly-resource.
<sly data-sly-template.image="${# teaser}">
<div data-sly-test="${teaser.imageResource}" data-sly-resource="${teaser.imageResource}"></div>
</sly>
Can I pass attribute values on data-sly-resource?
<div data-sly-test="${teaser.imageResource}" data-sly-resource="${teaser.imageResource # alt = properties.alt}"></div>
Thanks in advance.
AEM 6.5
2.6.0
4.1.0
In the HTL Sling implementation you can pass parameters on data-sly-resource (using request attributes - see SLING-5812). However, this would require the rendering of the image to be aware of these and use them.
As you seem to be using AEM WCM Core Components, the image component will try to fetch the data for alt attribute from the alt property of the resource. You could wrap the resource and provide a custom alt property to get around to what you need.

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.

TYPO3 How to create a custom "infobox"?

I am trying to make an "Infobox" with TYPO3.
In my HTML Template i have the Infobox:
<div id="infobox">
<!-- ###infobox### start -->
CONTENT from the backend
<!-- ###infobox### start -->
</div>
...
Now in my Backend, i have a content element, that keeps the content for my Infobox in the Frontend:
What i want to do is: If i disable the content element via the "disable button" in the backend, i want to change the CSS of my #infobox (adding display:none) or if I re-enable it I want to remove the display:none.
I hope I could explain my issue and hope someone can help me.
As far as I understand, you want the disabled flag of the content element to only influence the rendered output, not switch off the rendering.
I fear that this is not easily possible. The disabled column is part of TYPO3’s so-called enable fields, for which checks are added all over the place by the TYPO3 API. Due to this, "hidden" records are usually not even selected from the database, so they are also never fed to the rendering engine.
An alternative would be to use a custom content type with a custom field for your purpose, hide the "hidden" field in the form for that type and put the custom field in its place. This can all be done with standard TYPO3 core mechanisms.
What you cannot avoid however is that somebody will be able to hide/disable the content element from the page or list module. This cannot be prevented as your content needs to live in the same table (tt_content) as the rest of the content—and the settings for enable fields are global per table.
You can use an custom fluid content element
see: http://www.creativeworkspace.de/blog/artikel/eigene-inhaltselemente-im-typo3-cms-62x-und-7x/
or: https://docs.typo3.org/typo3cms/extensions/fluid_styled_content/7.6/AddingYourOwnContentElements/Index.html
or you use a custom layout
TCEFORM.tt_content {
layout {
addItems {
item1 = Name of Layout
}
}
}
after this you can get it with {data.layout} in your template
{f:if(contition:'{data.layout} == item1',then:'display:none')}

CQ5.6.1 Text component in the footer to pass same content across all pages

I have a footer.jsp which is expected to appear same across all pages. I added a Text component in the footer.jsp. When the author adds content to this Text component in Home page, I want the content to reflect in the footer of all child pages. Here is how I use the text component in the footer.jsp, but this is not working as I want.
<div class="gelUpdateContent">
<cq:include path="text" resourceType="foundation/components/text" />
Get Live Great <span class="txtRed">updates </span>
</div>
I already tried iparsys component instead of text, which is useful, but then my requirement is to restrict it to text only.
Any help is highly appreciated. Thanks.
I agree with #rakhi's answer of providing absolute path. But there is another way to do this.
Try using iParsys. iParsys configuration is inherited by all child pages. if you include an iParsys and drag-n-drop your footer component in the root page of your site, then that footer component will start appearing in all your child pages.
Instead of providing relative path to the path property in cq:include i.e. (text), provide an absolute path, something like (/content/<project>/<homepage>/jcr:content/text).
Providing relative path creates the text node under each page, whereas absolute path ensures that all the pages read and write to the node present in the path provided always.
This is one way of achieving what you need.
More info on using cq:include can be found here
Well, We can design with following options:
It is depend on your requirement. If you want to have common footer across the site then Put some global path(i.e /content/rootSitePath/) as a cq:include path.
If you want to have footer information get updated on child pages only then use IParsys component.
I would prefer to use option 1, but make sure we are hard coding path. Bette to have utility to determine path.
Thanks,
Jitendra

Generic component in CQ5 page

My question is very basic . I am creating a new template and in that template, I will have a concrete structure using DIV elements. But in almost 7-8 if the DIV's, I need the data to be entered by the user.
What component/line of code I can use to have all those 7-8 DIV's editable and customizable by the page creator ?
I tried multiple paragraphs with :
<cq:include path="par" resourceType="foundation/components/parsys"/>
But only the top one appears on the page. !!
For having multiple paragraph just rename the path value in the cq:include tag. also check here