21287 Posts in 5733 Topics by 2602 members
| Go to End | ||
| Author | Topic: | 2215 Views |
-
Re: can i execute function with variable in template ?

11 December 2009 at 5:39am
new problem : )
my funtion
function showPDF($id) {
$record = DataObject::get_by_id("File", $id);
return $record;
}in template
<% if PDFID %>
<% control showPDF() %>
<a href="$Filename"><img src="themes/tutorial/images/pdf_ikon.gif" width="32" height="32" /></a>
<% end_control %>
<% end_if %>and everything works great when i execute showPDF like this: <% control showPDF(204) %>
but when i have: <% control showPDF($PDFID) %> i got an error:Parse error: syntax error, unexpected '}' in C:\Windows\Temp\silverstripe-cacheC--serwer-strony-ernesto\.cacheC..serwer.strony.ernesto.themes.tutorial.templates.Layout.EnPielgrzymkaPage.ss on line ....
$PDFID is variable form database
-
Re: can i execute function with variable in template ?

11 December 2009 at 8:37am
As it says on the documentation page for templates - passing dynamic variables into functions is not supported yet.
ok it works now but i cant use it in other <% control %>
If you want to use the $replace_str on other page controllers other then the OkolicaMapaPage_Controller then it has to be in the model - OkolicaMapaPage class. Controllers aren't passed along when doing controls of other pages.
| 2215 Views | ||
| Go to Top |


