Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

howto: php + citydesk

when you mix your php scripts with cityscripts, you'll sometime get this:

Script Error: undeclared variable or illegal identifier "row" in \index\displayIndex.php

or some werid output when you preview.

my guess is when you mix php_scripts with cityscripts inside the same file, citydesk will try to eval the php scripts too. and when it doesn't makes sense, it will stop you in your tracks.

so what i did was to create another file type, .phpx in citydesk and untick the "files with this ext has cityscript" in it. and inside the actual .php with cityscript, i will just include the functions.phpx and call the php functions inline.

and that will solve the problem of using citydesk to manage the articles and using php to do the database runs.

ing yong chuan
Thursday, March 07, 2002

I'm an ASPer, so excuse my ignorance, but does PHP scripting utilize the {$ .. $} tokens?  If so, that'd be the conflict.

David Whatley
Thursday, March 07, 2002

not exactly {$, but vars in php are $var_name.

i_hate_php
Thursday, March 07, 2002

so when there's a code that does this,  {$row[ 'name' ]}, the scripting part will break.

i_hate_php
Thursday, March 07, 2002

Can you use a space and make it work: {$ x.headline $} works in CityDesk.  Will PHP pass it by?

David Whatley
Thursday, March 07, 2002

nope, because php vars using $variable_name, meaning, all variable names have to start with '$'.

$row[1] means array. {$row[1]} means this is string.

tried {$ row[1]} -> cityscript eval ok, but php doesn't.

and {$row[1]} -> cityscript not ok, but php works.

so my trick is to separate the bulk of php code into another file with a different extension and ask citydesk not to eval it for cityscripts.

Ing Yong Chuan
Thursday, March 07, 2002

What about { $var ? A space between the { and $ will stop CityDesk from trying to interpret it as CityScript. Will PHP still process it properly?

Darren Collins
Thursday, March 07, 2002

tried {  $ row[1]    } -> cityscript eval ok, but php doesn't. because php needs this {$row[1]} to work.

its because of the conflict in syntax.

Ing Yong Chuan
Friday, March 08, 2002

Does this older discussion help?

http://discuss.fogcreek.com/CityDesk/default.asp?cmd=show&ixPost=1096&ixReplies=11

tk
Friday, March 08, 2002

In you post above, you've still got a space between $ and var. What happens when you remove that?

Darren Collins
Sunday, March 10, 2002

If you want CityDesk to output {$ you have to write:
{{$$}$
The inner {$$} "evaluates" to a CityScript which "returns" nothing, but it keeps the outer { and $ away from each other so they don't trigger another script evaluation.

... this is documented in the Help file somewhere...

Joel Spolsky
Wednesday, March 13, 2002

*  Recent Topics

*  Fog Creek Home