Page 1 of 1

Variable needed after {include}

Posted: Fri Aug 13, 2010 6:00 pm
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?

Re: Variable needed after {include}

Posted: Fri Aug 13, 2010 7:51 pm
by kleinerChemiker
have you made your variable global?

Re: Variable needed after {include}

Posted: Sun Aug 15, 2010 6:08 pm
by Don Chambers
Yeah, that's pretty much the direction I took, plus I added the entire filter process to a function.

Re: Variable needed after {include}

Posted: Sun Aug 15, 2010 8:31 pm
by kleinerChemiker
maybe try to use the var everywhere as $_GLOBAL['varname']. Than it have to be reachable everywhere you use it.

Re: Variable needed after {include}

Posted: Sun Aug 15, 2010 10:46 pm
by Don Chambers
Sorry - I did not make myself clear. I solved the problem by making the variable global as you suggested.

Re: Variable needed after {include}

Posted: Sun Aug 15, 2010 11:49 pm
by kleinerChemiker
Ok, happy to hear that :)