Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

using keyword to add php header

I want some php code to appear in the head of one specific page, so I tagged that page with a keyword and then wrote this into the head of the template:

{$ foreach x in (keywordContains "email_manager") $}
{$ include "email_manager_php_code" $}
{$ next $}

It's not working (otherwise I woudn't be writing this :) I've been coding for about 10 hours so my brain is mush, but what's wrong here??? Or can you just not use Include inside of this construction?

Thanks in advance to any less-sleep deprived person who can help.

Chas

ChasInNapa
Tuesday, September 02, 2003

I think you have it backwards...

The condition isn't based on the article it's in, it searches all of the articles to see which one matches.

{$ foreach x in (keywordContains "email_manager") $}

will bring in every article that matches that condition.

What you want is something like:

{$ if nonblank Extra1 $}

which will only bring in the following code if you have something in Extra1.... which means that's the only thing you can use Extra1 for. It sucks..

The alternative, I guess, would be to create 2 templates... One with this code and one without, and just use one of the templates for this one page... I guess this is one of those things CityDesk isn't good at.

Also, I don't think Include works inside a loop like that, I think it stands on it's own, but I could be wrong.

It's been a while since I've coded anything in CityDesk, anyone feel free to jump in and correct me.

www.marktaw.com
Tuesday, September 02, 2003

What about something along the line of:

{$ foreach x in and( (keywordContains "email_manager")  (thisArticle) ) $}
{$ include "file" $}
{$ next $}

if your bug (sorry, you didn't say exactly what was wrong) was multiple includes, this extra constraint might just be the solution...

you could also substitue the include with a variable (containing the php code)

Daren Thomas
Tuesday, September 02, 2003

*  Recent Topics

*  Fog Creek Home