Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

How to get a variable from another template?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
flipmode85
Smarty n00b


Joined: 08 Sep 2018
Posts: 1

PostPosted: Sat Sep 08, 2018 8:17 pm    Post subject: How to get a variable from another template? Reply with quote

Hey guys!

i'm new to smarty and doing some learning stuff. Actually i'm stuck getting the needed data.

i need the following generated data, located in templates/common/company_data.tpl

Code:
{capture name="logo_`$obj_id`"}
    {if $show_logo}
        {if $show_links}<a href="{"companies.products?company_id=`$company.company_id`"|fn_url}">{/if}
        <span>
            {include file="common/image.tpl" images=$company.logos.theme.image image_width="120"}
        </span>           
        {if $show_links}</a>{/if}
    {/if}
{/capture}



in this location templates/blocks/product_templates/default_template.tpl

I've tried this...
Code:

{assign var="logo_data" value="logo_`$obj_id`"}
{$smarty.capture.$logo_data nofilter}


Anyone want push me in the right direction?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat Sep 08, 2018 11:51 pm    Post subject: Reply with quote

Again, don't use captures like that, they are simply not supposed to be used that way.
Use template functions, write proper plugin, use includes.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General 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