Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smarty capture BC break since 3.1.28 #153

Closed
GodLesZ opened this issue Jan 5, 2016 · 10 comments
Closed

Smarty capture BC break since 3.1.28 #153

GodLesZ opened this issue Jan 5, 2016 · 10 comments

Comments

@GodLesZ
Copy link

GodLesZ commented Jan 5, 2016

Since 3.1.28 Smarty capture works different and breaks existing code, again.
Also happend with Smarty::getVariable(), which was marked as deprecated and damaged at the same time (fixed since 3.1.29 but anyways).

Example for capture problem

layout.tpl

{block "content"}{/block}

index.tpl

{block "content"}
    {include "test-plugin.tpl"}
    {$smarty.capture.plugin}
{/block}

test-plugin.tpl

{capture "plugin"}
    test
{/capture }

index.php

$smarty->display('extends:layout.tpl|index.tpl');

The captured content is not available in the index.tpl.
If I move the capture tags to the index.tpl, everything works fine. So it seems to have a local scope to the current template now but no scope parameter like the assign tag.

Any chance to get

  1. BC in the future? 3.1.28 is a patch/build number
  2. a scope parameter or some advice how to accomplish the capture usage across multiple templates?
@pvenakis
Copy link

+1, capture defined in included files is no longer visible in the main scope (3.1.26 works properly)

@catherinek
Copy link

+1, {capture} no longer works from included / fetched files in 3.1.29.

{capture assign="tpl_footer_text" name="tpl_footer_text"}
    Footer Text
{/capture}

{$tpl_footer_text} or {$smarty.capture.tpl_footer_text} is empty.

@redemption
Copy link

This still affects 3.1.29 for us. The capture is not useable in the main scope.

@GodLesZ - you mentioned this is fixed in 3.1.29? Because I can recreate this bug in 3.1.29

@GodLesZ
Copy link
Author

GodLesZ commented Jan 14, 2016

@redemption, I meant an Error which was introduced in 3.1.27 on $smarty->getVariable() usage, not the {capture} behavior. ;)
$smarty->getVariable() was marked as deprecated in 3.1.28, changed slightly and throwed an error until 3.1.29

@redemption
Copy link

I just want to add that before this bug, it was possible to use capture content from a separate fetch.

Eg in the @GodLesZ original post:

index.tpl

{block "content"}
   {$content}
    {$smarty.capture.plugin}
{/block}

test-plugin.tpl

Content
{capture "plugin"}
    test
{/capture }

index.php

$content = $smarty->fetch('test-plugin.tpl');
$smarty->assign('content',$content);
$smarty->display('index.tpl');

Output of above would be the following:

Content
test

@redemption
Copy link

I was wondering, is this something that can be fixed and is intended to be fixed? Should we rewrite all uses of capture and stop using it?

uwetews added a commit that referenced this issue Jan 27, 2016
@uwetews
Copy link
Contributor

uwetews commented Jan 27, 2016

The fix is now in the master branch and will late be included in 3.1.30
The capture content is now also cached in the Smarty object and so available across several Smarty::fetch() call.

Sorry that it took so long, I was longer time in hospital.

@uwetews uwetews closed this as completed Jan 27, 2016
@pvenakis
Copy link

Hey @uwetews we are very sorry to hear that you had health issues, we wish you a quick recovery! Take care of yourself!

@pnikolov
Copy link

I get the same problem in the latest master-dev version. The capture is not visible outside the template it is defined.

uwetews added a commit that referenced this issue Mar 27, 2016
…en seen in other templates with {$smarty.capture.name} #153
@uwetews
Copy link
Contributor

uwetews commented Mar 27, 2016

Sorry, original error was introduced by mistake again.
The fix is now in the master branch and will later be included in 3.1.30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants