开发者

TypoScript: get page title by page id

开发者 https://www.devze.com 2023-03-18 09:20 出处:网络
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

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


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.


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


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


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…


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 }


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!!

0

精彩评论

暂无评论...
验证码 换一张
取 消