Discussion:
[TYPO3-english] Display page title in page
armin otto
2014-07-08 14:19:38 UTC
Permalink
Hi,

I have installed typo3 6.19 with the bootstrap package and I'm now modifying it to my needs.

It was ages ago when I first had to wrestle with typo3, so forgive me for not being quite up to date on how typo3 seems to work right now. :)

Anyway, what I am trying to do right now should be simple: I want the header partial template in typo3conf/ext/speciality/Resources/Private/Partials/header.html to render the page title as defined in the typo3 backend

right now the header.html file looks like this:
[code]
{namespace v=Tx_Vhs_ViewHelpers}
<f:layout name="Page"/>
<div
...

<f:section name="Header">
<!-- Default header -->
<header class="jumbotron" role="banner">
<f:render section="NavigationSpecial" partial="NavigationSpecial" optional="TRUE" arguments="{_all}"/>

<h1> Something something </h1>

<p class="lead">
<f:translate key="lead-text" extensionName="speciality"/>
</p>
</header>
</f:section>
</div>
[/code]

I was kinda hoping of having only to insert one line like
[code]
<h1> <v:page.title /> </h1>
[/code]
and be done with it, but no such luck.

So: What is the best way to do it?

Thanks!
Christian Futterlieb
2014-07-08 14:44:07 UTC
Permalink
Hi armin

You can use f:cObject view helper [1].

Put something like that in your typoscript template:

lib.pageTitle = TEXT
lib.pageTitle.data = page:title

and in the fluid template:

<h1><f:cObject typoscriptObjectPath="lib.pageTitle" /></h1>

Regards, Christian


[1]
http://docs.typo3.org/typo3cms/ExtbaseGuide/Fluid/ViewHelper/CObject.html
Post by armin otto
Hi,
I have installed typo3 6.19 with the bootstrap package and I'm now
modifying it to my needs.
It was ages ago when I first had to wrestle with typo3, so forgive me
for not being quite up to date on how typo3 seems to work right now. :)
Anyway, what I am trying to do right now should be simple: I want the
header partial template in
typo3conf/ext/speciality/Resources/Private/Partials/header.html to
render the page title as defined in the typo3 backend
[code]
{namespace v=Tx_Vhs_ViewHelpers}
<f:layout name="Page"/>
<div ...
<f:section name="Header">
<!-- Default header -->
<header class="jumbotron" role="banner">
<f:render section="NavigationSpecial"
partial="NavigationSpecial" optional="TRUE" arguments="{_all}"/>
<h1> Something something </h1>
<p class="lead">
<f:translate key="lead-text"
extensionName="speciality"/>
</p>
</header>
</f:section>
</div>
[/code]
I was kinda hoping of having only to insert one line like [code]
<h1> <v:page.title /> </h1>
[/code]
and be done with it, but no such luck.
So: What is the best way to do it?
Thanks!
bernd wilke
2014-07-08 14:48:51 UTC
Permalink
Post by armin otto
Hi,
I have installed typo3 6.19 with the bootstrap package and I'm now
modifying it to my needs.
It was ages ago when I first had to wrestle with typo3, so forgive me
for not being quite up to date on how typo3 seems to work right now. :)
Anyway, what I am trying to do right now should be simple: I want the
header partial template in
typo3conf/ext/speciality/Resources/Private/Partials/header.html to
render the page title as defined in the typo3 backend
[...]
Post by armin otto
I was kinda hoping of having only to insert one line like [code]
<h1> <v:page.title /> </h1>
[/code]
and be done with it, but no such luck.
So: What is the best way to do it?
you need to learn a little bit of fluid-templating.
http://wiki.typo3.org/Fluid
http://www.typovision.de/fileadmin/slides/ExtbaseFluidCheatSheetTypofaktum.pdf
(page 3)


as there is no viewhelper for the page-title you can set a variable in TS
page.10.variables.page_title = TEXT
page.10.variables.page_title.field = title

and use it in your Fluid-Template:
{page_title}

bernd
--
http://www.pi-phi.de/cheatsheet.html
Jigal van Hemert
2014-07-08 20:32:06 UTC
Permalink
Hi,
Post by armin otto
Anyway, what I am trying to do right now should be simple: I want the
header partial template in
typo3conf/ext/speciality/Resources/Private/Partials/header.html to
render the page title as defined in the typo3 backend
[...]
Post by armin otto
I was kinda hoping of having only to insert one line like [code]
<h1> <v:page.title /> </h1>
[/code]
and be done with it, but no such luck.
An important part of the MVC concept implemented in extbase and fluid is
the separation of different responsibilities. Fluid is responsible for
the 'view' part. So, generating data in a fluid template is against this
concept IMO.

In the TypoScript that defines the FLUIDTEMPLATE object [1] to render
the page you can set up a variable section. All these variables are
available in the template.
By default the current record is available in {data}. If you're
rendering a page the fields of the page are supposed to be in this variable.

So, if {data.title} doesn't work you can set a variable in TS and render
that.

[1]
http://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Fluidtemplate/Index.html
--
Jigal van Hemert
TYPO3 CMS Active Contributor

TYPO3 .... inspiring people to share!
Get involved: typo3.org
armin otto
2014-07-09 12:59:03 UTC
Permalink
thanks for the pointers.

I tried to set a variable in TS and render it. And it works ... up to a point.

in page.ts I have a lines like

page.variables.p1.value = Some Text
lib.variables.l1 = TEXT
lib.variables.l1.value = Some other Text

and in the header.html I have

<p> {v:var.typoscript(path: 'page.variables.p1.value')} </p>
<p> <f:cObject typoscriptObjectPath="lib.variables.l1"/> </p>

Both methods work to put out the specified text on the screen, but I am not able to fill the p1 or l1 variables with something as mundane as a page title. If I try something like page.variables.p1.value = page.title , all I get rendered is the string "page.title".

And I know that the page title is available somehow in header.html, because of this line:
<f:debug>{_all}</f:debug>

It shows me the page object right at the top and it contains everything I want.

So how do I convince Typo3 to render the page title ?

Thanks
Jigal van Hemert
2014-07-09 13:57:08 UTC
Permalink
Hi,

Simplest solution in this specific case:

Put in your page template {data.title}

In 'data' the current record is included, so the field 'title' of the
current page can be accessed.

General solution for all kinds of data:

Look in TypoScript how the page template is defined. It could be
something like:

page = PAGE
page {
[...]
10 = FLUIDTEMPLATE
10 {
file = .....
variables {
pageTitle = TEXT
pageTitle.data = page:title
}
}

Now you can use it in the page template as {pageTitle}. In a partial you
can use it too, assuming that the partial is included with something like:
<f:render partial="[....]" arguments="{_all}"/>

(the arguments attribute transfers all variables from the main template
to the partial)
--
Jigal van Hemert
TYPO3 CMS Active Contributor

TYPO3 .... inspiring people to share!
Get involved: typo3.org
bernd wilke
2014-07-09 14:59:51 UTC
Permalink
Post by armin otto
thanks for the pointers.
I tried to set a variable in TS and render it. And it works ... up to a point.
in page.ts I have a lines like
page.variables.p1.value = Some Text lib.variables.l1 = TEXT
lib.variables.l1.value = Some other Text
and in the header.html I have
<p> {v:var.typoscript(path: 'page.variables.p1.value')} </p>
<p> <f:cObject typoscriptObjectPath="lib.variables.l1"/> </p>
Both methods work to put out the specified text on the screen, but I am
not able to fill the p1 or l1 variables with something as mundane as a
page title. If I try something like page.variables.p1.value = page.title
, all I get rendered is the string "page.title".
don't hamper with additional viewhelpers if you have the data in a variable!
And the last line shows your lacks in understanding typoscript.

So:
you need to learn a little bit more of typoscript.
Post by armin otto
<f:debug>{_all}</f:debug>
It shows me the page object right at the top and it contains everything I want.
So how do I convince Typo3 to render the page title ?
||: you need to learn a little bit of fluid-templating. :||

all you can see with
<f:debug>{_all}</f:debug>
are fluid-variables you can use at once.
you just need to decipher the correct path from the output which
sometimes is complicated but mostly very easy.

if you can see the value in the debug-output just build up a full
qualified variable like
{data.title}
Variables are enclosed in curly brackets.
without namespace.
and viewhelpers are needed just in case the format of the data has to be
changed.



bernd
--
http://www.pi-phi.de/cheatsheet.html
armin otto
2014-07-11 07:25:17 UTC
Permalink
thanks.

yeah, i obviously need to read up - TS is quite the opposite of intuitive. horrible stuff.

{page.title} works fine without a fuss - no having to declare anything anywhere, which is all I wanted.

I could have sworn that this was one of the first attempts I tried, though.
oh well ...

thanks for the help! :)

Loading...