My idea is to build a content element with some inline elements. No big problem if the inline elements derive from an other table ... But i want to use other content elements - like news, where you can add content elements to the detail page as inline elements.
The problem is the colPos value - if it is the value of the current column the inline elements are shown twice: once as standalone element and once as inline (it works in news only because news eintries are normally on sysfolders). If i force other values for the colPos entry (like 999 oder -10) i get in the backend always INVALID VALUE ("-10")
Any idea? Is there a possibility?
It would be a nice solution for e.g. a accordion or tabs.
Thanks!
My solution:
There were too many arguements against content elements inline a content element. So i solved it with a content element with inline elements from an other table - the same way as mask would solve the problem. It works for me without the problems which mentioned in the answers. Many thanks!
IRRE tt_content to tt_content is notoriously error prone; there are concerns not only with the colPos column but also with recursion. I very strongly advise against it. It breaks translation ability, has problems with workspaces and it potentially treats file references of the children incorrectly.
That said: you can add virtual colPos values by modifying the TCA of tt_content.colPos to add selection values that match your chosen colPos value.
The extension Gridelements does this. Why dont you use it?
I am trying to implement something which I hope is relatively straight forward... I have one component (lets call it the wrapper component) which contains another component (lets call it the inner component) inside it via the data-sly-resource tag:
<div data-sly-resource="${ 'inner' # resourceType='/projectname/components/inner' }"></div>
I would like to pass in some additional parameters with this tag, specifically a parameter that can be picked up by sightly in the inner component template? I am trying to specify whether the inner templates outer html tag is unwrapped based on a parameter being passed in when the component is called via data-sly-resource.
After experimenting and perusing the sightly documentation, I can't find a way of achieving this.
Does anyone know if this is possible?
Many thanks,
Dave
You can use the Use-API to write and read request attributes if the alternatives proposed here don't work for you.
A quick example of two components where the outer component sets attributes that are then displayed by the inner component:
/apps/siteName/components/
outer/ [cq:Component]
outer.html
inner/ [cq:Component]
inner.html
utils/ [nt:folder]
setAttributes.js
getAttributes.js
/content/outer/ [sling:resourceType=siteName/components/outer]
inner [sling:resourceType=siteName/components/inner]
/apps/siteName/components/outer/outer.html:
<h1>Outer</h1>
<div data-sly-use="${'../utils/setAttributes.js' # foo = 1, bar = 2}"
data-sly-resource="inner"></div>
/apps/siteName/components/inner/inner.html:
<h1>Inner</h1>
<dl data-sly-use.attrs="${'../utils/getAttributes.js' # names = ['foo', 'bar']}"
data-sly-list="${attrs}">
<dt>${item}</dt> <dd>${attrs[item]}</dd>
</dl>
/apps/siteName/components/utils/setAttributes.js:
use(function () {
var i;
for (i in this) {
request.setAttribute(i, this[i]);
}
});
/apps/siteName/components/utils/getAttributes.js:
use(function () {
var o = {}, i, l, name;
for (i = 0, l = this.names.length; i < l; i += 1) {
name = this.names[i];
o[name] = request.getAttribute(name);
}
return o;
});
Resulting output when accessing /content/outer.html:
<h1>Outer</h1>
<div>
<h1>Inner</h1>
<dl>
<dt>bar</dt> <dd>2</dd>
<dt>foo</dt> <dd>1</dd>
</dl>
</div>
As commented by #AlasdairMcLeay, this proposed solution has an issue in case the inner component is included multiple times on the request: the subsequent instances of the component would still see the attributes set initially.
This could be solved by removing the attributes at the moment when they are accessed (in getAttributes.js). But this would then again be a problem in case the inner component is split into multiple Sightly (or JSP) files that all need access to these attributes, because the first file that accesses the request attributes would also remove them.
This could be further worked-around with a flag telling wether the attributes should be removed or not when accessing them... But it also shows why using request attributes is not a good pattern, as it basically consists in using global variables as a way to communicate among components. So consider this as a work-around if the other two solutions proposed here are not an option.
There is a newer feature that request-attributes can be set on data-sly-include and data-sly-resource :
<sly data-sly-include="${ 'something.html' # requestAttributes=amapofattributes}" />
Unfortunately it doesn't seem to be possible to construct a Map with HTL (=Sightly) expressions, and I don't see a way to read a request attribute from HTL, so you still need some Java/Js code for that.
unfortunately, no. there is no way to extend sightly functionality. you cannot add new data-sly attributes or modify existing ones. The best you can do is write your own helper using the USE API
If you just need to wrap or unwrap the html from your inner component in different situations, then you can just keep the html in the component unwrapped, and wrap it only when needed by using the syntax:
<div data-sly-resource="${ 'inner' # resourceType='/projectname/components/inner', decorationTagName='div', cssClassName='someClassName'}"></div>
If you need more complex logic, and you need to pass a value to your inner component template, you can use the selectors. The syntax for including the resource with selectors is:
<div data-sly-resource="${ 'inner' # resourceType='/projectname/components/inner', selectors='mySelectorName'}"></div>
The syntax to check the selectors in the inner component is:
${'mySelectorName' in request.requestPathInfo.selectorString}"
or
${'mySelectorName' == request.requestPathInfo.selectorString}"
When inspecting a cell element in XLSX file, I find the following formula element:
<f t="shared" si="0"/>
What is the meaning of such a formula element?
ECMA-376 Part 1 Section 18.3.1.40 says:
The possible values for the t attribute are defined by the simple type ST_CellFormulaType, and are as follows:
...
shared (Shared formula)
...
Shared formula. If a cell contains the same formula as another cell, the "shared" value
can be used for the t attribute and the si attribute can be used to refer to the cell
containing the formula. Two formulas are considered to be the same when their
respective representations in R1C1-reference notation, are the same.
Basically it is a space saving optimisation. One that is guaranteed to be a pain for anyone parsing/modifying the file.
so will something like this work using Hpple Xpath
//a[4]
The fourth tag in a html tree?
Or do i need to do it programmatically by counting in a for() loop?
The XPath for the fourth <a> in an HTML document is:
(//a)[4]
Your example //a[4] will produce a set of all <a>s that are the fourth <a> in their respective parent, and that is not what you want here.
See also: https://stackoverflow.com/a/14209492/1945651
I am using HTML::Template::Pro in my perl application. I am displaying HTML elements in a loop and I want to show something after the second element of the loop. I added the loop_context_vars in my HTML::Template::Pro initialization, getting access to variables inside the loop (like __counter__).
Now I am looking for a way to check for a specific iteration of this loop to insert my HTML element.
<TMPL_IF __counter__ == 2>
My new HTML element.
</TMPL_IF>
How can I access the __counter__ variable inside conditional statements in HTML::Template::Pro?
In HTML::Template::Pro, you can use expressions like in HTML::Template::Expr
<TMPL_IF EXPR="__counter__ == 2" >
My new HTML element.
</TMPL_IF>