How to call php functions inside smarty template directly
we can use {insert} tag for calling php functions inside smarty templates directly to display the output of the php function. it is similar to {include} tag except that {insert} tags are NOT cached when template caching is enabled. They will be executed on every invocation of the template. Remember all {insert} function names in your application must be prepended with “insert_” to remedy possible function name-space conflicts.so simply if your function is named as insert_getBanner, then call it inside {insert} tag as {insert name=”getBanner”} {* example of fetching a banner with agruments*} {insert name=”getBanner” lid=#banner_location_id# sid=#site_id#} Here we call a php function named as insert_getBanner with arguments lid and site_id so the php function must as like function insert_getBanner( $lid, $site_id) { ….. } we can use assign and script attributes to assign the output of insert tag to a variable and including a php script. more details can be found on http
Comments