My TYPO3 4.7.17 extension has the following code: (Controller)
public function listJobPublicAction(Tx_Htmjob10_Domain_Model_JobDemand $jobDemand = NULL) {
$nrAllJobs = $this->jobRepository->countAll();
...
$this->view->assign('jobs', $jobs);
}
and my extension view:
<f:cObject typoscriptObjectPath="lib.count2">{nrAllJobs}</f:cObject>
my TYPOScript:
lib.count2= HTML
lib.count2{
value.current = 1
value.wrap = <strong>|</strong>
}
This is working fine with Fluid template in TYPO3 extension
I want to use nrAllJobs in Fluid partial , but is not working. This is an empty line.
<f:layout name="Default" />
<f:cObject typoscriptObjectPath="lib.count2">{nrAllJobs}</f:cObject>
How to access PHP variable from Fluid partial (not Fluid template in TYPO3 extension )?
To pass a value to a TyposcriptObject for, you did it right:
<f:cObject typoscriptObjectPath="lib.count2">{nrAllJobs}</f:cObject>
As you mentioned this is working in Fluidtemplate but not in Partial. One quick guess: Did you pass your variable from your template to your partial? Like this:
<f:render partial="MyPartial" arguments="{_all}" />
Notice that arguments
needs to be an array or the keyword _all
, wich simply passes all varibales to the partial. If you just want to pass your variable, use {nrAllJobs:nrAllJobs}
If you pass yout variable to your partial, there is no difference whether you use the f:cObject ViewHelper in a template or a partial.
But, as mentioned by others here, you can display the value of your variable without the detour over a TypoScript object. Just do {nrAllJobs}
but still make sure you passed your variable to your patial.
I dont think the cObject function works like that. It is:
<f:cObject typoscriptObjectPath="lib.myObject"></f:cObject>
so your variable is the lib.myObject here.
Maybe you try:
<strong>{nrAllJobs}</strong>
Within the fluid template.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.