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

{function} doesn't work with {extend} in 3.1.28 #114

Closed
pikusov opened this issue Dec 8, 2015 · 1 comment
Closed

{function} doesn't work with {extend} in 3.1.28 #114

pikusov opened this issue Dec 8, 2015 · 1 comment

Comments

@pikusov
Copy link

pikusov commented Dec 8, 2015

Parent template file named index.tpl:

<html>
<head>
{block 'head'}
    <title>Example</title>
{/block}
</head>
<body>
    <div id="menu">
        {block 'menu'}{/block}
    </div>
    <div id="main">
        {block 'main'}{/block}
    </div>
</body>
</html>

Child template named page1.tpl:

{extends 'index.tpl'}
{block name='menu'}

    {function name=category_select level=0}
    <ul>
        {foreach $categories as $category}
        <li>
            {$category->name}
            {category_select categories=$category->subcategories level=$level+1} 
        </li>
        {/foreach}      
    </ul>
    {/function}
    {category_select categories=$categories}

{/block}

Another child template named page2.tpl:

{extends 'index.tpl'}

{block name='menu'}

    {function name=category_select2 level=0}
    <ul>
        {foreach $categories as $category}
        <li>
            {$category->name}
            {category_select2 categories=$category->subcategories level=$level+1} 
        </li>
        {/foreach}      
    </ul>
    {/function}
    {category_select2 categories=$categories}

{/block}
  1. Open page1.php (which $smarty->fetch('page1.tpl'))
    Page displayed ok
  2. Open page2.php (which $smarty->fetch('page2.tpl'))
    Get "Fatal error: Uncaught --> Smarty: Unable to find template function 'category_select2' <-- thrown in _**/smarty_internal_runtime_tplfunction.php on line 45"
  3. Clear all compiled templates files
  4. Open page2.php
    Page displayed ok
  5. Open page1.php
    Get Fatal error: Uncaught --> Smarty: Unable to find template function 'category_select' <-- thrown in *__/smarty_internal_runtime_tplfunction.php on line 45
  6. Clear all compiled templates files again
  7. Open page1.php
    Page displayed ok
  8. Do any change in page1.tpl
  9. Open page1.php
    Get Fatal error: Uncaught --> Smarty: Unable to find template function 'category_select' <-- thrown in _/smarty_internal_runtime_tplfunction.php on line 45
@pikusov pikusov changed the title {function} doesn't work width {extend} in 3.1.28 {function} doesn't work with {extend} in 3.1.28 Dec 8, 2015
@uwetews
Copy link
Contributor

uwetews commented Dec 8, 2015

The fix is now in the master branch.
Note:
The {function}...{/function} can and should better be placed outside {block)...{/block}

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

2 participants