Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Putting CD script in "extras" fields ?

We have difficulty putting foreach-code including <br>'s and <SPAN>'s like the following into any of the article extras fields and having it be parsed correctly:

<SPAN CLASS=mainlinkstitle>
more links:
</SPAN>
<br>
<SPAN CLASS=mainlinks>
{$foreach x in (folder "article/content_intelligence")$}
<a href="{$x.link$}">&#149;{$x.extra1$} </a>
<br>
{$next$}
</SPAN>

Either the <br> or <SPAN> are lost when pasting without formatting or the result is a series of links consisting of the actual CD script part. Any ideas ?

Patrick

Patrick Thomas
Sunday, January 13, 2002

I'm sure the Fog guys will be more definitive, but what happens if you put your script and formatting into a variable and put the variable into your "extra" field?  (Probably the same result, but I've wanted to try it and haven't had a good reason to.)

TK
Sunday, January 13, 2002

Good idea, thought of that but to no avail - also splitting it up into several variables does not seem to help.

The question is again related on how to best define sub-menues which are easily edited by non-technical users (copy and paste-like) and do not require different templates.

Patrick

Patrick Thomas
Sunday, January 13, 2002

Patrick, I did one of those here:

http://williamcoit.com/Pages/Counties/fog0000000065.html

I didn't do any style stuff, I just typed in the script into the "sidebar" field and centered it:

{$foreach x in (folder "Pages\Counties")$}
{$x.filename$}
{$next$}

I know there has been some discussion on formatting in the extra fields:  It might be nice to have a HTML view of the extras.

TK
Sunday, January 13, 2002

I should take this opportunity to clarify what happens when you have CityScript inside CityScript.

The key thing to remember about CityDesk 1.0 as it stands right now is that CityDesk will interpret all the CityScript it finds, and then run through once more and interpret CityScript, and then stop.

That means that if you have a template containing {$.body$} and the body contains a variable {$.myVariable$}, both will be evaluated. But if that variable itself contains {$foreach...$} or some other CityScript, it *won't* get evaluated, because CityScript only runs twice and this is a third level of nesting.

This is a silly limitation and I really, really hope to fix it in time for the very first service pack, SP1, which will be free. We haven't announced a date for the service pack but my personal goal is March 1st.

Joel Spolsky
Sunday, January 13, 2002

I'm getting confused.  If you put a script in a variable:

1. If the variable is in a body - it will not evaluate.
2. If it's in an HTML file?
3. If it's in template?
4. When y'all fix it it will evaluate anywhere?

What is the correct CityDesk term for evaluating a script?  Run, evaluate, interpret, ??

TK
Sunday, January 13, 2002

The original script works fine if put in the BODY part of an article (as its only two layers deep leaving out the intermediary variable approach) but not in any of the extra or property fields, correct ?

Patrick Thomas
Monday, January 14, 2002

You only get two levels.

So -- a variable in a body (2) evaluates
A script in a variable in a body (3) doesn't
A script in a variable in an HTML file (2) does.
A variable in a variable in an HTML file (2) does
A variable in a varaible in a body (3) doesn't.

It's sort of dumb. We have this stupid code I personally wrote which goes through the file, replaces all the CityScript once. Then it does this a second time.

What it should really do (and will do) is go through the file, replacing the CityScript, and then if it notices that it is pulling in even more CityScript, it should replace that recursively.

The reason we didn't it right the first time is that it creates a risk of an infinite loop, for example if your X variable is defined as {$.x$}. So we will have to have loop detection and avoidance.

Joel Spolsky
Monday, January 14, 2002

Is the current level of script detection still set at 2?

Professional Edition Version 1.0.31
Build Date: 20020808A

Michael Costantino
Wednesday, November 27, 2002

*  Recent Topics

*  Fog Creek Home