Andriy
Andriy

Reputation: 121

TypoScript: get page title by page id

Task1. In TypoScript I need to get a page title for a given page id {$my_page_uid} Task2. This page title should be recieved according to the current language

I need this title in the form like temp.pTitle, so I can make then page.10 < temp.pTitle

Upvotes: 12

Views: 19671

Answers (6)

gautamsinh mori
gautamsinh mori

Reputation: 323

May this will help you

In your fluid template

<f:cObject typoscriptObjectPath="lib.pagetitle" data='your page id'/>

In Typoscript

lib.pagetitle = HMENU
lib.pagetitle {
special = list
special.value.current = 1
    1 = TMENU
    1 {
    NO {
        doNotLinkIt = 1
    }
}
}

Let me know it this not working I have other ways!!

Upvotes: 1

Yurii P.
Yurii P.

Reputation: 61

I made such a script and work without VHS functions: v.page.info (on TYPO3 v9):

Examples:

<f:cObject typoscriptObjectPath="lib.pageInfo" data="{pageUid: '48', pageField: 'subtitle'}" />

lib.pageInfo = COA  
lib.pageInfo {
    5 = LOAD_REGISTER
    5 {
        ## Set the content's field (default: title):
        pageField.cObject = TEXT
        pageField.cObject {
            field = pageField
            ifEmpty.data = title
        }

        ## Allows to override the current page ID:
        pageUid.cObject = TEXT
        pageUid.cObject {
            field = pageUid
            ifEmpty.data = TSFE:id
        }
    }

    20 = RECORDS
    20 {
        source.data = register:pageUid
        tables = pages
        dontCheckPid = 1
        conf.pages = TEXT
        conf.pages.field.data = register:pageField
    }

    90 = RESTORE_REGISTER }

Upvotes: 0

pdu
pdu

Reputation: 10413

There's an even simpler solution..

10 = TYPOLINK
10.parameter = [your_page_id]

When you omit the .value or .field, it automatically takes the page title as value. This even works with multiple languages.

Important note: This answer was valid in 2011, TypoScript has obviously changed since…

Upvotes: 0

Mateng
Mateng

Reputation: 3734

At a first glance I thought: Haha! That's trivial... but actually it's not. Here is a clever solution for the first part I found in a german forum:

temp.pTitle = HMENU
temp.pTitle {
  special = list
  special.value = {$my_page_uid}
  1 = TMENU
  1 {
    NO {
      doNotLinkIt = 1
    }
  }
}

Don't know if this solves the language part, but it should.

Upvotes: 18

xian
xian

Reputation: 169

temp.pTitle = TEXT
temp.pTitle.data = DB:pages:{$my_page_uid}:title

Upvotes: 16

Sivakumar
Sivakumar

Reputation: 1119

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

Upvotes: 3

Related Questions