[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

smarty engine use variable outside section

Hi,

I'm still learning some smarty templating but got stuck for now.
My problem is as follow:

I have an query array which I succesfully displayed on a page using the {section} method

-------------------------------------------------------------------
{section name=portfolio loop=$getlistportfolio_elec}
-------------------------------------------------------------------

Now I have a hidden div (which includes a page) which will be displayed upon clicking the edit button.

-------------------------------------------------------------------
<div id = "form_editportfolio_electricity" class="addmenue" style = "display:none;">
      {include file="editportfolio.tpl" myprojects="1"}
</div>
-------------------------------------------------------------------

Now on the form which is located on editportfolio.tpl
I would like to set an if clausule with a row of the displayed query (which is the column category).

So let me explain this more in detail.
I have two categories in my portfolio (electricity and websites). So I made two different {sections} one with loop $getlistportfolio_elec and the other $getlistportfolio_website.

Now when I click on the edit button (which is located in the section for each different value)

-------------------------------------------------------------------
<a class="tool_edit" href="javascript:blindtoggle('form_editportfolio_electricity')" title="{#edit#}" ></a>
-------------------------------------------------------------------

I would like the action of the form to be ***check code snippet***

But as the form is located on a different .tpl page and not in between the section... how do you communicate these variables with each other?

Or what would you do in this situation?


Kind regards,
Peter
{if $getlistportfolio_elec[portfolio].category == "elektriciteit"}
	<form class="main" method="post" action="managewebsite.php?action=portfolio&amp;mode=edit&amp;id={$getlistportfolio_elec[portfolio].id}" {literal}onsubmit="return validateCompleteForm(this);"{/literal} >
	{else}
	<form class="main" method="post" action="managewebsite.php?action=portfolio&amp;mode=edit&amp;id={$getlistportfolio_website[portfolio].id}" {literal}onsubmit="return validateCompleteForm(this);"{/literal} >
	{/if}

Open in new window

0
Mutsop
Asked:
Mutsop
  • 2
1 Solution
 
poisaCommented:
I'm not sure if I understood this correctly but Smarty automatically makes variables available within child templates...

For example:

{$test}

{section ... etc, etc}



{/section}
0
 
poisaCommented:
Sorry (accidental submit on last post!)


I'm not sure if I understood this correctly but Smarty automatically makes variables available within child templates...

For example:

{$test}

{section name=portfolio loop=$getlistportfolio_elec}
   {include file.tpl}
{/section}


Now in file.tpl, the var $getlistportfolio_elec[portfolio] IS available. No need to pass it through. If it isn't in your version try passing it explicitly:

  {include file.tpl var=$getlistportfolio_elec[portfolio] }

Does this help?
0
 
MutsopAuthor Commented:
Oh I'll try it out within the next few hours and will let you know.
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now