Variable needed after {include}

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Variable needed after {include}

Post by Don Chambers »

A template's index.tpl uses included templates to render portions of the page like this:

Code: Select all

    {if $condition_1}{include file="content_1.tpl"}{/if}
    {if $condition_2}{include file="content_2.tpl"}{/if}
    {if $condition_3}{include file="content_3.tpl"}{/if}
Those included files fetch entries for a particular category using a specified entries template, such as:

Code: Select all

{serendipity_fetchPrintEntries limit="0,5" category=1 noCache=false fetchDrafts=false full=false use_footer=false prevent_reset=true filter_sql="$filter" template="entries_1.tpl"}
After fetching the entries, that same template sets or appends $filter so entries are not fetched again by the next included template's category.

My problem is that $filter does not survive from one included file to the next. Is there any way to do this?
=Don=
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Variable needed after {include}

Post by Don Chambers »

Yeah, that's pretty much the direction I took, plus I added the entire filter process to a function.
=Don=
kleinerChemiker
Regular
Posts: 765
Joined: Tue Oct 17, 2006 2:36 pm
Location: Vienna/Austria
Contact:

Re: Variable needed after {include}

Post by kleinerChemiker »

maybe try to use the var everywhere as $_GLOBAL['varname']. Than it have to be reachable everywhere you use it.
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Variable needed after {include}

Post by Don Chambers »

Sorry - I did not make myself clear. I solved the problem by making the variable global as you suggested.
=Don=
Post Reply