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

LVL 3
MutsopAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MutsopAuthor Commented:
Oh I'll try it out within the next few hours and will let you know.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.