TYPO3 fluid: Get all content IDs from page - typo3

is there an possibility to get all the content IDs from a page?
I tried something like this:
<v:resource.record
table="tt_content"
uid="1811"
field="pid"
as="item"
>
<f:debug>{item}</f:debug>
</v:resource.record>
But it only gives me the parent ID and i cant swap the attributes to make it work.
Thanks

get Page ID of content element with UID 312:
<v:resource.record
table="tt_content"
uid="312"
field="pid"
as="item"
><f:debug title="query 1: page of CE">{item}</f:debug></v:resource.record>
get UID of content elements in page with UID 123:
<f:cObject typoscriptObjectPath="lib.UidList" data="{pid:123}" />
typoscript:
lib.UidList = CONTENT
lib.UidList {
table = tt_content
select {
pidInList.field = pid
}
renderObj = TEXT
renderObj.field = uid
renderObj.wrap = |, |*| |, |*| |
}

Related

Fetch a record from tt_address

I'm not very familiar with data processing and I'm stuck. I created a new field customer_id in the table tt_content, in which the uid of a tt_address record is stored.
Now I need to read that customer_id from tt_content and fetch the associated record from tt_address to display name and company of it in the fluid template.
tt_content.customerdata =< lib.contentElement
tt_content.customerdata {
templateName = Kundeninfo
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
table = tt_content
uidInList.field = customer_uid
fieldName = customer_uid
???
as = customer
}
}
}
Update:
It woks with
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
if.isTrue.field = customer_uid
table = tt_content
selectFields = tt_address.*
join = tt_address ON tt_address.uid IN(tt_content.customer_uid)
where = tt_content.uid = 568
as = customer
}
One last problem
In tt_content only one customer_uid (related to the uid of tt_address) is saved for some elements. The above code selects all addresses whose uids are stored in tt_conent. Now i need to get only the matching address to the elements form tt_content. I tested it with one uid of a content element (568) in the code above, that works.
Now i don't know how to code the where condition to read the associated record from tt_address to every content element that has a customer_uid
Thanks

Typoscript: Link around Content Element

I want to use the field "header_link" for a link around a content element. This is my Typoscript:
temp.teaserblockContent = CONTENT
temp.teaserblockContent{
table = tt_content
select {
pidInList = this
orderBy = sorting
where = colPos = 4
}
renderObj < tt_content
renderObj.stdWrap.typolink {
parameter = {field:header_link}
parameter.insertData = 1
}
}
If I replace {field:header_link} with {tsfe:id} it works. But not with {field:header_link}, even {field:uid} is empty. In database, header_link is set correctly.
How can I access the field values?
tt_content uses gridelements, so a simple 20 = TEXT is not possible.
tt_content.gridelements_pi1.20.10.setup {
1 < lib.gridelements.defaultGridSetup
1 {
columns {
10 < .default
10.wrap = <div class="col-md-12">|</div>
}
}
2 < lib.gridelements.defaultGridSetup
2 {...}
}
Have you tried
parameter.field = header_link
or
parameter.data = field:header_link
EDIT: Try to add header_link to select.selectFields = header_link ... but I think by default if selectFields is not set, every field should be selected.
I tested your typoscript setup and it works. Maybe it would help if you tell us the used TYPO3 version and what all this has to do with gridelements.

TYPO3 6.2 output categories of a content element

I use TypoScript to render content elements like that:
page.10 < styles.content.get
page.10.select.where = colPos=0
page.10.wrap = <section id="resources"><h1 class="section">Resources</h1><div class="accordion"> | </div></section>
page.10.renderObj.stdWrap.dataWrap = <div class="contentelement layout-{field:layout} type-{field:CType}"> | </div>
How can I output the categories associated with each content element? Ideally I would like to do it in the datawrap like {field:categories} but if that doesn't work I also wouldn't mind to append them in some separate HTML element.
I tried to implement a JOIN with the sys_category_record_mm table but didn't get anything working.
Any ideas?
EDIT:
Here is my latest try:
page.10.renderObj.stdWrap.postCObject = CONTENT
page.10.renderObj.stdWrap.postCObject {
wrap = <p class="categories">|</p>
if.isTrue.field = categories
table = tt_content
select {
uidInList.field = uid
join = sys_category_record_mm ON tt_content.uid = sys_category_record_mm.uid_foreign JOIN sys_category ON sys_category.uid = sys_category_record_mm.uid_local
orderBy = sys_category.sorting
}
renderObj = TEXT
renderObj {
field = title
wrap = |
}
}
This only outputs an empty <p class="categories"></p> if the content element has categories assigned. But the categories don't get listed.
page.10.renderObj.stdWrap.postCObject = CONTENT
page.10.renderObj.stdWrap.postCObject {
wrap = <p class="categories">|</p>
table = sys_category
select {
pidInList = 123 # Storage page/folder of your category records
selectFields = sys_category.*
join = sys_category_record_mm ON sys_category_record_mm.uid_local = sys_category.uid
where.data = field:_LOCALIZED_UID // field:uid
where.intval = 1
where.wrap = sys_category_record_mm.uid_foreign = |
andWhere = sys_category_record_mm.tablenames = 'tt_content'
orderBy = sys_category.sorting
languageField = 0
}
renderObj = TEXT
renderObj {
#DEMO INCL TRANSLATED CAT NAMES:
value = {field:uid}:{field:title} ---
insertData = 1
noTrimWrap = || |
}
}
Some details:
CONTENT.select implements multiple inherent defaults, if you don't tell otherwise. One of them is to use the current page only. So if your categories are not stored within the current page (which is likely), you have to overwrite the default using pidInList.
I don't know where you get your field:uid from. But if you use multiple languages you will have to provide the uid of the overlay record. This is done in the where.data clause. If you are calling this TS from a Fluid template, you will find the uid of the overlay record in data._LOCALIZED_UID. If you are in a single language system, you may stay with uid only.
You must also filter for tablenames = 'tt_content'. Otherwise you might get back categories that are assigned to other tables (like tx_news_domain_model_news from EXT News records).

uid of parent page or pid of current page for Typoscript db queries

I want a list of uids of the current active parent of my menu. I got a solution, which gives me exactly that, however, my solution is really static, as it doesn't take the current active "parent" menu but a fixed value i typed in. Here is my code:
lib.dbValues = CONTENT
lib.dbValues {
table = pages
select {
selectFields = uid
pidInList = 74
}
renderObj = TEXT
renderObj {
field = uid
wrap = |,
}
}
My question would be, can i get the Pid of the current page or the uid of the parent page dynamically? it really bothers me that i can get the current uid by typing "this" but nothing else.
This worked for me:
select.where = colPos = 4
select.orderBy = sorting
select.andWhere.wrap = pid=|
select.andWhere.data = page:uid
I have a workaround that i will use for now (untill i have a better grasp on how to typoscript). I just broke the query condition with a marker:
lib.dbValues = CONTENT
lib.dbValues {
table = pages
select {
selectFields = uid
#pidInList = pid
where = pid NOT IN (0) OR pid IN (SELECT pid FROM pages WHERE uid = ###THIS_UID###)
markers {
THIS_UID.data = TSFE:id
}
}
renderObj = TEXT
renderObj {
field = uid
wrap = |,
}
}
With the Where clause i will get something like
... WHERE pid in (0) and pid NOT IN (0) OR ...
Everything in front of the or is insicnificant. It seemed like typo is trying very hard to not get the current page id comfortably.

Typo3 extbase - HMENU with multiple records

I have a products extension with a "Details" view.
"Product" records are kept in a folder with ID 5.
When I am on a product I want to have a menu with links to all the products from that folder.
I this possible in Typoscript?
Thank you.
You can do everything using TypoScript :-).
lib.productList = CONTENT
lib.productList {
table = tx_myext_domain_model_product
select {
# sorting criterion
orderBy = tstamp DESC
# PID list
pidInList = 46,47
# Maybe restrict the number of results
max = 20
}
# Each result must be rendered like this
renderObj = COA
renderObj {
1 = TEXT
# Each field from your table can be used
1.field = title
1.wrap = <h1>|</h1>
2 = TEXT
2.field = description
# If one field contains rich text, you can apply RTE parsing to it
2.parseFunc < lib.parseFunc_RTE
}
}
Now you can use the cObject ViewHelper to display your list in the Fluid template:
<f:cObject typoscriptObjectPath="lib.productList"></f:cObject>