i often use conditions with [PIDinRootline = {$any-id}] which checks if the given ID is inside the current rootline.
Now i need something similar for a given PID.
I thought about a ViewHelper that accepts a PID and an ID as arguments and builds a rootline for PID and checks against ID. Is there anything already available or did anybody do something like that in the past?
best regards,
simon
Using EXT:vhs, it this should work:
<f:if condition="{v:page.rootline(pageUid: X.uid) -> v:iterator.filter(propertyName: 'uid', filter: Y.uid)}">
<f:then>X is child page of Y</f:then>
<f:else>X is not a child page of Y</f:else>
</f:if>
It calculates the root line of the child page X (which is an array of page records), then filters out all elements having an uid that is different from the uid of Y, and checks whether the result is empty.
<v:condition.page.isChildPage then="[mixed]" else="[mixed]" pageUid="123" respectSiteRoot="1">
<!-- tag content - may be ignored! -->
</v:condition.page.isChildPage>
https://fluidtypo3.org/viewhelpers/vhs/master/Condition/Page/IsChildPageViewHelper.html
Related
I want to display some contentlement on every page with fluid templates. My solution was to create a typoscript element like:
lib.my.myelement= CONTENT
lib.my.myelement {
table = tt_content
select {
pidInList = 15
where = uid=99
}
}
and then use it in the fluid template with:
<f:cObject typoscriptObjectPath="lib.my.myelement" />
Another way is to create them directly in fluid with v:content.render or v:content.get. In this example I get all content elements on one page and save them in an array:
<v:variable.set name="contentElements" value="{v:content.get(column:'0', limit:'3', pageUid:'9', render:'FALSE')}" />
I can not use the first solution, cause on this page there will be much different languages ( I could use it, but every time a new language is added I would have work to declare all new uids of the new elements in typoscript).
The second solution would work better, cause when you translate a page the element uids change, but the pageUid does not change. But here I have the problem that I don't just need all elements, I also have to identify each element.
Here is how I use the second solution:
<v:variable.set name="contentElements" value="{v:content.get(column:'0', limit:'3', pageUid:'9', render:'FALSE')}" />
<f:for each="{contentElements}" as="contentElement" iteration="footerIteration">
<div class="column{v:math.sum(a: footerIteration.index, b: 1)}">
<v:content.render contentUids="{0:contentElement.uid}" />
</div>
</f:for>
As you can see, I use every element the same way.
lets create a simple case:
I have a page with the pageUid = 10 (this page will have translations). On every of this translations will be 3 elements. Lets say 1 element got the "id" (with id I mean something how I can identify this element) title1 and the other two elements have the id list1 and list2.
And my question now is How could I access for example list1?
I hope its understandable, if something is not clear please leave a comment.
Edit: I could use the same order on every translation for the elements and then check the iteration in the for-loop (see the second solution) to identify them. But I wonder if there a better, cleaner way.
I am running tt_news in an older TYPO3 instance.
Now I have the situation I would like to use a different template for each list item depending on the pid where the rendered news item is found.
As there is no logic in the classic tt_news templates, and - I think - TS doesn't look at each record, that doesn't seem to be possible at all. Or is it?
Would it be possible with tx_news and a fluid template? Maybe there is a "if pid of record equals n" condition?
You can do this with tx_news. In the fluid template, inside the f:for, where the News items are iterated, you can check the pid.
The partial is partials/List/Item.html and a simple
<f:if condition="{newsItem.pid} == 123">
<f:then></f:then>
<f:else></f:else>
<f:/if>
will do the job.
I'm currently building a TYPO3 PageTemplate with Flux and Fluidpages (both GitHub Master-Branch).
I'd like to have the possibility to select a number of ContentElements from the PageTree and store the UIDs in a variable for later rendering.
My first approach combining a Flux TreeField with a RelationField:
<flux:form.sheet name="content" label="content settings">
<flux:field.tree
name="treetest"
label="treetest"
table="pages"
parentField="pid"
foreignLabel="title"
multiple="true"
minItems="0"
maxItems="1000"
size="8"
expandAll="false"
/>
<flux:field.relation
name="relationtest"
label="relationtest"
table="tt_content"
condition="AND tt_content.pid IN ({treetest})"
multiple="true"
size="8"
minItems="0"
maxItems="3"
/>
</flux:form.sheet>
This sadly results in a SQL-Error because the last condition is inserted as:
AND tt_content.pid IN (60|foo)
Where 'foo' is the title of a SysFolder with the UID 60.
Debug-Output in the frontend prints the field 'treetest' as:
treetest => '60' (2 chars)
and the condition for the field 'relationtest' as:
condition => 'AND tt_content.pid IN (60)' (26 chars)
Questions:
As a matter of fact, I'm missing something here and I'd appreciate any hint, where the crux is here?
Is there maybe a different solution to select a ContentElement from the PageTree?
1) It is possible that you have either a default value, an inherited value or somehow disconnected XML which contains the other value. To be 100% sure none of these are your cause, try the same on a completely new page. The expected result of your code and selecting a page UID, is exactly the value 60 - nothing more, nothing less.
2) You may find it easier to use a ###STORAGE_PID### marker in your foreign_table_where and selecting the page(s) allowed for content selection, as values in the Behavior tab when editing your content element or page. This value has the added benefit of being possible to allow only for certain users or usergroups, or admins only.
TYPO3 adds these links at the start of almost every element:
<a id="c1427"></a>
where number is, I guess, UID of the element.
How TYPO3 render this link and is it possible to disable it for a specific FCE?
It depends on your TYPO3 Version. In 4.5 it is defined via:
tt_content.stdWrap.innerWrap.cObject.default.10.value = <div id="c{field:uid}"
If you use the TS-Objectbrowser, you should find it somewhere in tt_content.stdWrap.*
Depending on the rendering you are using, you could be able to add an if statement like:
tt_content.stdWrap.innerWrap.cObject.default.10 {
# check the uid of the content element which is rendered
if.isInList.field = uid
# do not render if content element uid is 1,2 or 44
if.value = 1,2,44
}
For sure, it depends on your configuration, so you cannot copy & paste. And i did not test this code! But it should show the way to go:)
I think your problem is in tt_content.stdWrap.prepend that is different for any languages different from default language.
Try to put this typoscript in your template:
tt_content.stdWrap.prepend >
tt_content.stdWrap.wrap = <div class="content-element">|</div>
Why is the following code NOT working without id or name attribute specified for the anchor element?
<html>
<body>
First link
<p>innerHTML of the first anchor:
<script>document.write(document.anchors[0].innerHTML);</script>
</p>
</body>
</html>
But if I add an id (or name) attribute, like that:
<a id="first" href="#">First link</a>
It starts to work.
Why is id or name attribute so important? I don't refer to it in my javascript code. I don't use "getElementById" or anything, but it still wants an id to be specified.
P.S. I tested only in IE7 (not the best browser, but I don't have access to anything better at the moment, and it can't stop me from learning :)
UPDATE:
Thanks to Raynos who gave me an idea of HTMLCollection in his answer, I've gotten a deeper understanding of what's going on here, by searching the web.
When we use document.anchors collection, we're actually referring to a collection of a elements with the name attribute that makes an a element behave as an anchor, and not (only) as a link.
We don't have to specify the name attribute if we want to refer to a elements as links. In this case we just need to use a different instance of HTMLCollection object which is document.links.
So the original code will work without name attribute if we modify it to:
document.write(document.links[0].innerHTML);
What a nice feeling of enlightenment! :)
WHATWG says:
The anchors attribute must return an HTMLCollection rooted at the Document node, whose filter matches only a elements with name attributes.
the document.anchors collection needs <a> elements with a name attribute.
IE is known to have bugs where it treats id's and name's as the "same" thing. So that would probably explain why it works for <a> elements with an id attribute.
As an aside, document.write and .innerHTML are evil.
Why don't you use this:
document.getElementsByTagName('a')[0].innerHTML