【问题标题】:Typo3: display content from first sub-page using typoscriptTypo3:使用打字稿显示第一个子页面的内容
【发布时间】:2011-06-03 22:49:53
【问题描述】:

这就是我想要做的:在给定页面上,我想显示给定页面的第一个子页面的所有内容元素。我不能简单地使用快捷页面,因为我需要在子页面之后显示其他内容元素。我怎样才能做到这一点?

这是我认为我可以做到的sn-p,但我不知道如何构建选择。有没有更好的办法?

# save current content
tmp.pagecontent < page.10.subparts.main-content

# clear the content of the main column
page.10.subparts.main-content >

# build a new object for this column as content-object-array
page.10.subparts.main-content = COA
page.10.subparts.main-content {
  10 = CONTENT
  10.table = tt_content
  10.select {
    # what should I put here?
  }
# re-insert the normal pagecontent to the page  
20 < tmp.pagecontent

【问题讨论】:

  • 正在使用 Templavoila 吗?您可以参考这些项目。
  • 没有。我使用模板自动解析器。我不能简单地引用这些项目,因为我想要的是第一个子页面的内容,而当我添加新页面时,第一个子页面可以及时更改。因此,我想要显示的项目并不总是相同。
  • "select" 的行为类似于 SQL 查询。在此处查看带有 pidInList 的最后一个示例wiki.typo3.org/TSref/CONTENT 使用 RECORDS 而不是 CONTENT 可能更适合您的情况。 wiki.typo3.org/TSref/RECORDS

标签: typo3 typoscript


【解决方案1】:

只需添加其他人的答案。 First :指定当前页面的第一个子页面。 第二:获取您想要的该子页面的内容元素。

temp.content = COA
temp.content {
  10 = CONTENT
  10 {
    table = pages
    select {
      pidInList.field = uid
      orderBy = sorting ASC
      max = 1
      begin = 0
    }
    renderObj = COA
    renderObj {
      10 = CONTENT
      10 {
        table = tt_content
        select {
          languageField = sys_language_uid
          pidInList.field = uid
          orderBy = sorting
          #where = colPos = 10
        }
        stdWrap.wrap = |
      }
    }
  }
}

【讨论】:

    【解决方案2】:

    我终于成功了!不确定这是最好的方法。你怎么看待这件事?我也应该将第二个选择放入 userFunc 吗?

    fileadmin/userfunc/mailArchive.php

    <?php
    class user_mailArchive {
        function getFirstChild($content, $conf) {
            $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
                    'uid',                         // SELECT ...
                    'pages',                       // FROM ...
                    'pid='.intval($conf['pid']),   // WHERE...
                    '',                            // GROUP BY...
                    'sorting',                     // ORDER BY...
                    '1'                            // LIMIT ...
                );
            $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
            if ($row) {
                return $row['uid'];
            }
            else {
                return '';
            }
        }
    }
    

    TS 模板

    # fill the content of the main-column to a tmp.object
    tmp.pagecontent < page.10.subparts.main-content
    
    # clear the content of the main column
    page.10.subparts.main-content >
    
    includeLibs.mailArchive= fileadmin/userfunc/mailArchive.php
    
    # build a new object for this column as content-object-array
    page.10.subparts.main-content = COA
    page.10.subparts.main-content {
      10 = CONTENT
      10 {
        table = tt_content
        select {
          pidInList.cObject = USER
          pidInList.cObject {
            userFunc = user_mailArchive->getFirstChild
            # parent page ID
            pid = 139
          }
          orderBy = sorting
        }
      }
    
    # re-insert the normal pagecontent to the page  
      20 < tmp.pagecontent
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多