TYPO3 Render content from subpages via typoscript - typo3

i am new to typoscript. I tried to render content from some subpages on an archive page.
I am not sure why my code is displaying nothing.
Firstly I am trying to iterate through my subpages
within that code
stdWrap.wrap = <div class="row"> | </div>
table = pages
select {
orderBy = sorting
# If this element is inserted as sitemap, consider the startingpoint
pidInList.field = uid
#max = 1
begin = 0
}
Secondly i am itarating through my tt_content table and trying to get the value of the column header and render that on my archive page.
The Code is working until
<div class="row"> | </div>
Full Code here:
lib.content = COA
lib.content {
stdWrap.wrap = <div class="row"> | </div>
table = pages
select {
orderBy = sorting
# If this element is inserted as sitemap, consider the startingpoint
pidInList.field = uid
#max = 1
begin = 0
}
renderObj = COA
renderObj {
stdWrap.wrap = <div class="testfestinner"> | </div>
10 = CONTENT
10.wrap = <h3>|</h3>
10 {
table = tt_content
select {
pidInList.field = uid
where = colPos = 212
orderBy = sorting
}
renderObj = COA
renderObj.10 = TEXT
renderObj.10.field = header
}
}
}
I am not sure where and how to debug that code.
Thanks in advance.

Something like table = pages can not be assigned to a COA directly.
You need a cObject of the type CONTENT for that purpose. Just like the one you assigned to the renderObj.

Related

HMENU: How to wrap page content into my menu?

I would like to build a full with dropdown menu based on page content defined into a folder.
The idea is to have:
MENU (folder)
- menu 1 (page)
- menu 2 (page)
My goal is to get the following output:
menu 1 content in menu 1 page
menu 2 content in menu 2 page
There is only one content bloc in the pages.
No problem to get the li with menu 1 / 2 but I cannotfind the way to get and wrap the page content.
My code looks like
menu.nav = HMENU
menu.nav {
special = directory
special.value = 214
entryLevel = 1
1 = TMENU
1.wrap = <ul>|</ul>
1.expAll = 1
1.NO = 1
1.NO.wrapItemAndSub.cObject = TEXT
1.NO.wrapItemAndSub.cObject.value = <li>|</ul></li>
1.NO.after.cObject = COA
1.NO.after.cObject {
10 = TEXT
10.value = <div class="dropdown">
20 = CONTENT
20 {
table = tt_content
select {
....
but I cannot figure out what is required here to get the content of the pages.
Does someone can help me with this issue?
Thanks in advance.
Regards
Joël
I'll try a solution here, hoping that I'm not simplifying too much your code,at least you could take it as a starting point:
menu.nav = HMENU
menu.nav {
special = directory
special.value = 214
1 = TMENU
1.wrap = <ul>|</ul>
1.NO {
wrapItemAndSub = <li>|</li>
after.cObject = CONTENT
after.cObject {
table = tt_content
select {
pidInList.field = uid
where = {#colPos} = 0
}
renderObj = < tt_content
wrap = <div class="dropdown">|</div>
}
}
}
I took this one as starting point.
I had a similar problem sometime ago, came upwith this code to make a menu containing database information.
It is not an answer, but it is a similar piece of code. Hopefully it gives you an idea.
It generates a list of links to pages which have "no_search" = 0 or another condition. There is also a database join made to get the pagepath or url of pages in the site.
Think you can do the same thing with your page content, output it as html.
lib.sitemap = CONTENT
lib.sitemap {
table = pages
select {
orderBy = pages.sorting
selectFields = pages.uid, pages.title, tx_realurl_pathcache.pagepath
join = tx_realurl_pathcache ON tx_realurl_pathcache.page_id=pages.uid
pidInList = 44
recursive = 7
where = (no_search="0") or (nav_hide=1 and no_search=0)
groupBy = tx_realurl_pathcache.page_id
}
renderObj = COA
renderObj.wrap = <li>|</li>
renderObj.10 = TEXT
renderObj.10 {
field = pagepath
wrap = <a href="|">
}
renderObj.20 = TEXT
renderObj.20.field = title
renderObj.30 = TEXT
renderObj.30.value = </a>
}
lib.sitemap.wrap = <ul> | </ul>
You have to do this
lib.navbar2 = COA
lib.navbar2.wrap = <nav>|</nav>
lib.navbar2 {
20 = HMENU
20.wrap = <ul>|</ul>
20 {
#entryLevel = 0
#excludeUidList = 11,12
1 = TMENU
1 {
wrap = |
expAll = 1
NO = 1
NO.allWrap >
NO.wrapItemAndSub = <li>|</li>
NO.after.cObject = COA
NO.after.cObject{
stdWrap.wrap = <div class="megamenu-wrapper">|</div>
20 = CONTENT
20 {
table = tt_content
select {
pidInList.field = uid
orderBy = sorting
where = colPos=4
languageField=sys_language_uid
}
}
20.wrap = |
}
ACT = 1
ACT < .NO
ACT.wrapItemAndSub = <li class="active">|</li>
CUR = 1
CUR < .NO
CUR.wrapItemAndSub = <li class="active">|</li>
}
}
}

TYPO3 Menu Double up

I have this custom menu setup based on the default section menu. When testing on one content element, it looks good... When I add a second content element to the page both get added to each menu item.
Anyone know what's going on here?
tt_content.menu.20.3.1.sectionIndex.useColPos = -1
tt_content.menu.20.101 < tt_content.menu.20.3
tt_content.menu.20.101 {
1.NO {
stdWrap.cObject = CONTENT
stdWrap.cObject {
table = tt_content
select {
pidInList.field = uid
}
renderObj = COA
renderObj {
10 = FILES
10 {
stdWrap.wrap = <div class="menu-img">|</div>
references {
table = tt_content
fieldName = image
}
renderObj = IMAGE
renderObj {
file {
import.data = file:current:uid
treatIdAsReference = 1
width = 100c
height = 100c
}
altText.data = file:current:alternative
titleText.data = file:current:title
stdWrap.typolink.parameter.data = file:current:link
}
maxItems = 1
}
20 = TEXT
20.field = header
30 = TEXT
30.field = rowDescription
}
}
}
}
This is currently outputting:
<ul>
<li><img/>Heading1Desc1<img2/>Heading2Desc2</li>
<li><img/>Heading1Desc1<img2/>Heading2Desc2</li>
<ul>
What it should be:
<ul>
<li><img/>Heading1Desc1</li>
<li><img2/>Heading2Desc2</li>
</ul>
It is about your CONTENT object.
your selection is strange:
select {
pidInList.field = uid
}
you select all tt_content elements which are in the page with the uid of the current content element.
And your rendering is executed for each record found.
Do you really need to select the contentelement with a cObject again? I think in the menu it should be the current context.
add on:
I would try something like this to render the image before the text (which should be available by default):
before just for the image instead of stdWrap with a full query of all CEs and with a COA for all fields.
have a look to the correct fieldname!
1.NO {
before.cObject = FILES
before.cObject {
stdWrap.wrap = <div class="pic">|</div>
references {
table = tt_content
uid.data = uid
// 'image' or 'media' or ... ???
fieldName = image
}
renderObj = IMAGE
renderObj {
stdWrap.wrap = <div class="pic">|</div>
file {
import.data = file:current:uid
treatIdAsReference = 1
width = 150c
height = 150c
}
altText.data = file:current:alternative
titleText.data = file:current:title
#params = class="menu-img"
// don't do a link inside a link =:-O
#stdWrap.typolink.parameter.data = file:current:link
}
maxItems = 1
}
}
I have tried this many different ways and cannot get it working with the image and fields. So instead I have simply patched my original code using by adding: tt_content.menu.20.101.maxItems = 1 and adding a wrap to the renderObj.
I know this is not how it should be done, but it works for now. But if anyone knows the correct way of doing it let me know!

typo3 add image resource as background

I'm totally new to typo3, I need to make a div with background from a specific page. For example on home page, I would like to use a media resource from page id 20.
I got something like that
page.20 = TEMPLATE
page.20.template = FILE
page.20.template.file = fileadmin/refood/layouts/home.html
page.20.workOnSubpart = DOCUMENT
page.20.subparts{
BOX1 < styles.content.get
BOX1.select.where = colPos=1
BOX1.wrap = <div class="offers"><div class="home-box-desc"></div><div class="home-box-desc">|</div><div class="meta-square-green"></div></div>
BOX1.stdWrap.typolink.parameter = 14 _self home-box }
I tried to use something like that
references {
table = pages
uid.data = 20
fieldName = media
}
renderObj = IMAGE
renderObj {
file.import.data = file:current:publicUrl
altText.data = file:current:title
wrap = <div class="offers">|</div>
}
BOX1.wrap = <div class="home-box-desc" style="background:url(|)"></div>
Into a subpart part, but nothing happens. How should I make it ?

TYPO3 TypoScript: Display a list of subpages with content on parent page

I am trying to create an archive page that displays a list of subpages, similar to WordPress but display the parent's subpages instead of posts. I want the archive page to include the following from the subpage:
Title
First image
First 150 words of regular text element
At the moment I can display a page title, but that's where I got stuck. I am placing the code in a sub template. Here is the code.
lib.portfoliolist = CONTENT
lib.portfoliolist.table = pages
lib.portfoliolist.select {
pidInList = this
}
lib.portfoliolist.renderObj = COA
lib.portfoliolist.renderObj {
stdWrap.wrap = <div class="project">|</div><hr />
10 = TEXT
10 {
field = title
wrap = <h2>|</h2>
10.typolink.parameter.field = uid
}
}
If it helps, all of the images are within the fileadmin/user_upload/ directory, and this is my page structure:
Root
Home
About
Project Portfolio
Project 1
Project 2
Blog
Contact Us
Seems like I figured it out myself, all I had to do was call for content in a separate query. For those that are looking to achieve something similar, here is the code I used to help you out.
lib.portfoliolist = CONTENT
lib.portfoliolist.table = pages
lib.portfoliolist.select {
orderBy = sorting ASC
}
lib.portfoliolist.renderObj = COA
lib.portfoliolist.renderObj {
stdWrap.allWrap = <div class="row">|</div>
stdWrap.wrap = <div class="project col-lg-6 col-md-6 col-sm-12 col-xs-12">|</div>
10 = TEXT
10 {
field = title
wrap = <h2>|</h2>
typolink.parameter.field = pages.uid
}
20 = CONTENT
20 {
table = tt_content
select {
pidInList.field = uid
selectFields = header, bodytext
orderBy = sorting ASC
}
renderObj = COA
renderObj {
30 = TEXT
30.value {
field = bodytext
wrap = <div>|</div>
}
}
}
}

Typoscript: Wrap Content element

I would like to display content of subsites and wrap them in specific divs. Here is my code:
lib.content = CONTENT
lib.content {
stdWrap.wrap = <div id="sub-content-scroll">|</div>
renderObj.stdWrap.wrap = <div class="page">|</div>
table = tt_content
select {
pidInList.cObject < lib.allPid
where = colPos = 0
orderBy = pid
}
}
My question is: How can I wrap the only per pid. Now it wraps all content element with the page div. But I want to achieve the wrap by site. PS: lib.allPid is a kommaseparated list with ids.
Can someone help me?
Thank you very much
Coreblade
Thanks for the answer
I solved my Problem. The solution was to implement both (lib.content and lib.allPid) in one:
lib.content = HMENU
lib.content {
stdWrap.wrap = <div id="sub-content-scroll">|</div>
special = directory
special.value = 7
1 = TMENU
1.NO {
doNotLinkIt = 1
field = uid
stdWrap.cObject = CONTENT
stdWrap.cObject {
wrap = <div class="page">|</div>
table = tt_content
select {
pidInList.field = uid
where = colPos = 0
orderBy = pid
}
}
}
}
Ragards Coreblade