Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

escape out from eval: resource.

Post new topic   Reply to topic    Smarty Forum Index -> Feature Requests
View previous topic :: View next topic  
Author Message
Smarty n00b

Joined: 22 Feb 2013
Posts: 1

PostPosted: Fri Feb 22, 2013 1:59 am    Post subject: escape out from eval: resource. Reply with quote

Forgot extends: but it seems that extends:eval: doesn't work.
$smarty->fetch("extends:eval:{block name=\"table_data_body\"}{/block}|file:games_table_contents.tpl");

I actually found that I don't have to generate a separate template file in php for loading in smarty, but there is a problem:

$smarty->fetch("eval:{block name=\"table_data_body\"}{/block}|file:games_table_contents.tpl");
Doesn't work as fetch doesn't recognize the pipe and won't try to load the file.

Old post:

I want a possibility to get specific block from a template file in php.

Use case (written directly here so it won't work as is):

{include file="extends:list_table_container.tpl|games_table_contents.tpl" scope='global'} {* Yeah, "colliding beams" here but not real code. Unimportant anyway. *}

<table id="{block name="table_id"}{/block}">
  {block name="table_head"}{/block}
  {block name="table_body"}{/block}
<div id="reload_button">Reload</div>
 // reloads table contents
  $("#reload_button").click (function () {
     $.ajax ("{block name="table_reload_url"}{/block}", {
       success: function (data)
          $("#{block name="table_id"}{/block} tbody").html (data) ;


{block name="table_id"}games_table{/block}
{block name="table_head"}
{block name="table_body"}
{foreach from=$games_list item="game"}
{block name="table_reload_url"}games_reload.php{/block}

  $smarty->assign ('games_list', $games_list);
  $smarty->display ('games.tpl');

  $smarty->assign ('games_list', $games_list);
  $smarty->display_block ('games_table_contents.tpl', 'table_body'); // Doesn't work currently. How do I get output only one block?

Above code allows me to use same table template with different content and when reloading, requesting only the table data and not having any scripts re-run. All table content is in one template file. But that single template file backfires when I can't get a single block out from a template.

One way I can do this is by dynamically generating a template with only '{block name="table_body"}{/block}' inside php (and will do this meanwhile), but that's ugly and I'd really like to get this feature added or even just discussions on best ways to do this or suggestions on alternative approaches.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Feature Requests All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP