TYPO3: How do I insert page content into template - typo3

I have some content that I want to appear on multiple pages of my TYPO3 site. I could just insert this into the template, but I also want that content to be editable in the Rich Text Editor.
So I had the idea of creating a hidden page, but I don't know how to insert this content into a template.
Does it require the select typoscript statement?
Also, as a follow-up question, can I add something to say, only include pages that have this page id as their immediate parent in the page hierarchy.

I didn't quite get the second question.
If you want to include some record only to pages under some other page, then this will obviously work:
[PIDinRootline = pages-uid, pages-uid, ...]
temp.foo = RECORDS
temp.foo {
tables = tt_content
source = ID # Enter the object's ID here
}
[end]
On the other hand, if you want to include all records from pages, being children of some other page, then try something like:
1 = CONTENT
1.table = tt_content
1.select {
pidInList = parent-uid
}
Don't know if I got you right though.
Dmitri.

From Include typo3 content elements on every page:
temp.foo = RECORDS
temp.foo {
tables = tt_content
source = ID # Enter the object's ID here
}
Note the ID is the content record ID, not the page ID.
But that doesn't answer the question of how to only include pages/records with a certain parent.

You can set up a hidden page and then "import" the content elements on a given page via typoscript on the pages (or the entire page tree below) as needed.
The "trick" is to use the colPos with the select-statement. With this you can even put multiple (different) content elements in one (hidden) page that show up on different pages (depending on the setting of the column they are "in".
Example:
Create a hidden (or system) page (here example-pageid = $PID_STATIC)
Create a content element on this page (text)
Edit this content element to be shown on the right column (right equals colPos=2)
Put the following typoscript into the template on which you want the content element to be shown. You can set the pid (pageId) in the constants via PID_STATIC or "hardcode" it into the typoscript.
.
lib.aditionalcontent = COA
lib.aditionalcontent {
10 = CONTENT
10 {
table = tt_content
select.where = colPos = 2
select.orderBy = sorting
select.pidInList = {$PID_STATIC}
}
Add the element lib.aditionalcontent into your template where the content should be shown. For example:
.
page.10 = TEMPLATE
page.10.template = FILE
page.10.template.file = fileadmin/maintemplate.htm
page.10.workOnSubpart = DOCUMENT_BODY
page.10.marks.ADITIONAL_CONTENT < lib.aditionalcontent
.
Watch out, that you set the colPos according to the column that you have set the content element into, otherwise it just will not show.
You can use different columns to do this for different content that has to show up/should not show up on a particular page.
This also works with sytemfolders and non-hidden pages.
If you use TemplaVoila, this should also work although you have to switch to the listview to see and set the colum for the content element (if not hidden for this non-admin user).
To find out which colPos-number is which position of the column go to the phpMyAdmin and search for the field "colPos" in the tt_content table.

Related

typo3 add content element to all pages that are direct child of a certain page using typoscript

I have defined a menu content element using typoscript:
lib.share = COA
lib.share {
wrap = <div class="shareLinkBlock">|</div>
1 = TEXT
1.data = page : title
...
I would like to add this menu to colPos 2 of every page, that is direct child of a certain page.
Is there any way to achieve that?
Thanks a lot!
A solution depends on the current realization of the page.
If you use only typoscript you can replace the colPos2 rendering with a COA where your typoscript is part one and the old rendering is a second part.
Using conditions can restrict the appearance to selected page trees.
In similar ways you can realize it with FLUID.
You can insert a fluid variable, filled with your typoscript in every page.
The restriction to special page trees can be realized with conditions in typoscript or in FLUID. Also you can use different page-layouts for pages with and without this menu.
another solution would be an additional backend column which gets inherited and where you fill in your menu for those pages where the menu starts being visible. (conditions like above)
EDIT:
if you want to enhance a given FLUID variable, defined in typoscript you can word with a COA:
:
10 = FLUIDTEMPLATE
10 {
:
variables {
enhancedColumn = COA
enhancedColumn {
10 = ..old definition ...
}
}
}
:
// make sure you use the correct conditions:
[PIDinRootline = 10]
...10.variables.20 < lib.footer
[global]

TYPO3: show user input in front-end

I have a little problem with TYPO3, i have a navbar (fluid) and want to show a number in there which the user should be able to fill in in the Backend.
I would like to use a typoscript variable to show this number but my question is:
Is there a easy way that a user can input a number which I am able to read in my typoscript without editing the CONSTANTS in the template editor? Like some way the user can input this number in the PAGE section.
You can create a text content element on a page and/or in a column that is not being shown on your webpage and then add it to Typoscript like this:
10 = CONTENT
10 {
table = tt_content
select.orderBy = sorting
select.pidInList = 58
select.where = colPos=3
}
Where 58 is the ID of the page your content element is on, and colPos=3 is the number of the column (in this case, 3 is the "Border"-column)

TYPO3 how duplicate content in severals page

I have a TYPO3 website.
I have 4 contents in my home page which I had created with TemplaVoila (flexible content).
I want to know if there is an easy way to duplicate these contents in all the others pages.
Yes, TemplaVoila allows you to reference ContentElements with special icon, which means that you insert it on some page and then you creates a references. If "first" CE changes, all references reflect it automatically.
Optionally, if all CE's are places in one TV's column you can use TV Content Slide extension by Bernhard Kraft.
Just map that content using typoscript using the below code and use it:
lib.leftcolumncontents = COA
lib.leftcolumncontents{
5 = RECORDS
5 {
tables = tt_content
source = 26 # content element id
}
15 = RECORDS
15 {
tables = tt_content
source = 36 # content element id
}
}

TT_NEWS Force Display of Latest News in Single/Latest implementatin (TYPO3)

Sirs,
I have a nice working implementation of SINGLE and Latest on same page. My realurl is working perfectly. Problem is, by default, single doesn't show anything until you click on one of the listed news (displayed by the list plugin). I would like the single plugin to show the latest news on landing.
Any ideas?
FIRST SOLUTION
The solution for the requested behavior is described in the tt_news manual:
Default news id
Insert the following lines to the setup field of an ext-template at
the page where you want to display the latest news item in SINGLE view
if no SINGLE view for another record was requested:
# hide the "no news id" message
plugin.tt_news._LOCAL_LANG.default.noNewsIdMsg =
# set the tt_news singlePid to the current page
plugin.tt_news.singlePid = 977
# fill the content of the main-column to a tmp.object
tmp.pagecontent < page.10.subparts.contentarea
# clear the content of the main column
page.10.subparts.contentarea >
# build a new object for this column as content-object-array
page.10.subparts.contentarea = COA
page.10.subparts.contentarea {
10 = CONTENT
10.table = tt_news
10.select {
# insert the pids of all pages from where you want to fetch news.
# the recursive-field has no influence on this selection
pidInList = 1078,1079,1080,1081,1082,1083,1084
orderBy = datetime desc
max = 1
}
# insert the object “10.” only if there is no SINGLE news selected
# ATTENTION, OUTDATED IN MANUAL, USE GP:... instead of GPvar:... !!!
#10.stdWrap.if.isFalse.data = GPvar:tx_ttnews|tt_news
10.stdWrap.if.isFalse.data = GP:tx_ttnews|tt_news
# re-insert the normal pagecontent to the page
20 < tmp.pagecontent
}
The page in this example contains 2 columns. The news LIST is located
in the left column. the main column (page.10.subparts.contentarea)
contains a SINGLE news content-element.
SECOND SOLUTION – MY FAVORITE
My personal favorite to solve the problem is a bit more slick. It makes use of the noNewsIdMsg (which is simply emptied in the above solution) and uses its stdWrap version to show the latest record exactly when there would normally be a "No news ID" message.
# use the "no news id" message position for the latest news record
plugin.tt_news.singlePid = 977
plugin.tt_news.noNewsIdMsg_stdWrap.cObject = COA
plugin.tt_news.noNewsIdMsg_stdWrap.cObject {
10 = CONTENT
10.table = tt_news
10.select {
# insert the pids of all pages from where you want to fetch news.
# the recursive-field has no influence on this selection
pidInList = 1078,1079,1080,1081,1082,1083,1084
orderBy = datetime desc
max = 1
}
}
Please be aware that in BOTH solutions the template subpart that is used for the inserted default record is NOT ###TEMPLATE_SINGLE### but ###TEMPLATE_SINGLE_RECORDINSERT###.
One solution is to change the text limit for latest view in that particular news plugin as given below:
plugin.tt_news.displayLatest.subheader_stdWrap.crop = 10000 | ... | 1
and also provide a separate template file without
<!--###LINK_ITEM###-->
markers in latest view section.
The Safe Single News extension
adds a new tt_news code: SAFE_SINGLE which ensures that a single news
article is shown even if none is specified. If a news article is
selected, it will simply show it. If none is selected, it will display
the latest news article for the configured category.
Maybe it could help you.
Why not have a "single/latest" view showing a single view (if submitted) and latest if no single view requested. In this plugin set news-limit for latest to "1".
Below add another latest (or list) with news limit set to 3 (or as wanted)

How can I insert the current page title automatically into a TYPO3 template?

actually the title is the whole question.
I just want to modify the template so that the current page title is automatically shown (i'm working with html templates so I just need the bit of typoscript to get the page title out of the database)
I hope that's possible
It is. It's pretty simple to do. I'll assume you're using TemplaVoilà, because if you're not, you should be :-D
Start off by putting some HTML in your template with a dummy page title. Give it an ID attribute so it's easy to map. Like:
<h1 id="page-title">Page Title Here</h1>
Next, go into TemplaVoilà and map that <h1> element to the content type "TypoScript Object Path". When it prompts you for the object path, you can put in anything you want -- convention is that dynamic content is added in the "lib" namespace, so let's call it lib.pagetitle. When it asks you if you want to map this to "INNER" or "OUTER", choose "INNER" -- that will mean you're just mapping the space BETWEEN the <h1>...</h1> tags. ("OUTER" means you're replacing the whole element, including the tags, which we don't want here because we want this to stay an H1.) Save your template mapping.
Now go into your site's TypoScript template. Here you're going to insert the logic that fills in that space we just mapped with actual content. To insert the page title is a matter of a couple of lines of TypoScript:
lib.pagetitle = TEXT
lib.pagetitle.data = page : title
What this says is "take the space in the template that I mapped to lib.pagetitle. Create a content object in that space of type TEXT. Then fill that content object with the title of the page."
Save your TypoScript template. Now you're done!
This probably sounds complicated at first glance, and it is, but the nice thing about this system is that it's amazingly flexible. Inserting text dynamically is just the beginning. The TypoScript Reference (a.k.a. the "TSRef") has all the details -- look up "getText" to get a flavor, that's the function that makes the "page : title" call in your TypoScript template drop in the page title.
TSRef is your friend. I keep a printed copy of it at my desk -- if you want to make TYPO3 sing, it is your songbook.
I prefer the vhs solution:
{v:page.info(field:'title')}
https://fluidtypo3.org/viewhelpers/vhs/master/Page/InfoViewHelper.html
lib.pagetitle = RECORDS
lib.pagetitle {
source.data = page:uid
tables = pages
conf.pages = TEXT
conf.pages.field = nav_title
}
To get current page title:
lib.pagetitle = TEXT
lib.pagetitle.field=title
For meta data :
Its very important to place meta after header tag when we are gone through mobile compatible website
In order to prevent quirks mode in IE9 I need to add this lines at the very top of every HTML page:
You can write the whole header by yourself, by adding disableAllHeaderCode = 1 to your typoscript or you can hack it by adding your meta tag directly to the head tag:
page.headTag = <head><meta http-equiv="X-UA-Compatible" content="IE=edge" />
Place this at your typoscript
meta.X-UA-Compatible = IE=edge,chrome=1
httpEquivalent: (Since TYPO3 4.7) If set to 1, the http-equiv attribute is used in the meta tag instead of the “name” attribute. Default: 0.
For more information about TYPO3 stuff you may visit my blog
https://jainishsenjaliya.wordpress.com/2013/10/10/put-meta-tag-on-top-of-header-section-in-typo3/
If you want to use this in a fluid page template, you can also simple use:
{data.title}
to access the page title.
You can current page title by following typoscript:
lib.pagetitle = TEXT
lib.pagetitle.data = page : title
and then use this object to your page using typoscriptObjectPath like following way:
<f:cObject typoscriptObjectPath="lib.pagetitle"/>
If you want to use a fluid only solution, install the VHS extension and you can output the page title without using any TypoScript at all like this:
Tag Example:
<v:page.header.title title="NULL" whitespaceString="' '" setIndexedDocTitle="1">
<!-- tag content - may be ignored! -->
</v:page.header.title>
Inline Example:
{v:page.header.title(title: 'NULL', whitespaceString: '' '', setIndexedDocTitle: 1)}
lib.page_title = CONTENT
lib.page_title {
table = pages
select {
where = uid = 2
}
renderObj = COA
renderObj {
10 = TEXT
10 {
field = title
wrap = <h1 class="page_title">|</h1>
}
20 = TEXT
20 {
field = subtitle
stdWrap.required = 1
stdWrap.wrap = <h5>|</h5>
}
}
}
call the lib.page_title where want to render typoscript with this lines
<f:cObject typoscriptObjectPath='lib.page_title' />
I hope this helps !!!
The question is quite old but I still want to add something I never read here.
TYPO3 offers many things concerning the header, and it's right that it's also possible to render it completely individual. Nevertheless all the nice options of TYPO3 are more or less disabled by the individual solution.
So first the direct answer on the question:
The default page title can be overridden like this
config.pageTitle.stdWrap.override.cObject < lib.pagetitle
If several page types are defined and the title shall be set individually for each type, the configuration can be noted inside the page-definitions:
page = PAGE
page {
typeNum = 0
config.pageTitle.stdWrap.override.cObject < lib.pagetitle_1
...
}
anotherPage = PAGE
anotherPage {
typeNum = 1
config.pageTitle.stdWrap.override.cObject < lib.pagetitle_2
...
}
Below still a lib.pagetitle which makes a little bit more than only using title or subtitle - it uses news-title if the extension is used on a page:
lib.pagetitle = COA
lib.pagetitle {
10 = TEXT
10 {
// subtitle: used as field for title tag
value.field = subtitle // title
if.isFalse.data = GP:tx_news_pi1|news
}
20 = RECORDS
20 {
if.isTrue.data = GP:tx_news_pi1|news
dontCheckPid = 1
tables = tx_news_domain_model_news
source.data = GP:tx_news_pi1|news
source.intval = 1
conf.tx_news_domain_model_news = TEXT
conf.tx_news_domain_model_news {
field = title
htmlSpecialChars = 1
}
}
}
Now still some background why I think some individual header might not be the best solution:
TYPO3 usually adds several details to the header, that are useful and it's not required to combine those things individually new.
Scripts and stylesheets are organized and can be even by TypoScript compressed and merged. If some syntax is followed it even takes care that a library like jquery is only included once.
TYPO3 has many functions in TypoScript where everything can be defined related to the header and also it can be decided if scripts shall be perhaps never be included at all in the header but instead in the bottom of the page-source.
Metatags can be defined (and overridden by extensions or sub-templates)
Implementing this whole logic manually again in an own template in my opinion is not useful and I think headers should be only disabled for special page-types like AJAX or dynamic PDF-files. This is the primary reason that I consider that option as useful.
Her still the current link for the most recent documentation about the config-options in TypoScript (anchor pagetitle):
https://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Config/Index.html#pagetitle