새로운 Typo3 설치에서 나는 이와 같은 템플릿을 가지고 있습니다.FLUIDTEMPLATE에 배열을 전달하는 방법은 무엇입니까?
page = PAGE
page {
10 = FLUIDTEMPLATE
10 {
file = fileadmin/default/templates/index.html
...
variables {
...
myPages = CONTENT
myPages {
table = pages
select {
pidInList = 76
orderBy = sorting
}
}
}
}
}
지금은이 같은 내 fluidtemplate의 페이지를 반복하고 싶습니다 :
<f:for each="{myPages}" as="page">
<f:format.raw>{page.title}</f:format.raw>
</f:for>
을 내가 <f:debug title="debugger">{myPages}</f:debug>
을 불행히도 경우이 빈 문자열임을 보여줍니다.
선택한 내용 객체의 결과 배열을 FLUIDTEMPLATE에 전달하려면 어떻게합니까?
UPDATE :
나는 그것이 주어진 parentId에 대한 페이지의 배열을 반환하는 사용자 지정 viewhelper을 만들어 해결했다. 결과는 유체 변수에 저장됩니다. 템플릿에
class Tx_Custom_ViewHelpers_Pages_GetViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
/**
* Gets subpages for a given page.
*
* @param int $parentId ID of the parentpage.
* @param string $target Target Variable
*/
public function render($parentId, $target='content') {
$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'pages', 'pid=' . $parentId);
if ($this->templateVariableContainer->exists($target) === TRUE) {
$this->templateVariableContainer->remove($target);
}
$this->templateVariableContainer->add($target, $rows);
}
}
사용법 :
{namespace cn=Tx_Custom_ViewHelpers}
<cn:pages.get parentId="{parentId}" target="pages"/>
<f:for each="{pages}" as="p">
page: {p.title}
</f:for>
남은 typoscript :
page = PAGE
page {
10 = FLUIDTEMPLATE
10{
file = fileadmin/default/templates/index.html
layoutRootPath = fileadmin/default/templates/layouts/
partialRootPath = fileadmin/default/templates/partials/
variables {
content < styles.content.get
parentId = TEXT
parentId.value = 76
}
}
}
콘텐츠 객체은 ... 배열이 아닌 그래서 대답 벤자민의 의견이 적용됩니다. – lorenz