Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Why doesn't this work?

                  <table width="125" border="0" cellspacing="1" cellpadding="2">
                    <tr bgcolor="#eeeeee">
                      <td><b class="arial11">Site Index</b></td>
                    </tr>

<!-- this line is a link to the index page -->

                    <tr bgcolor="#eeeeee">
                      <td><A  class=arial08
                        href="PTMFOG0000000080"><img src="PTMFOG0000000081.gif" width="6" height="8" border="0">&nbsp;Home</A></td>
                    </tr>

<!-- the page you're on, bold -->

                    <tr bgcolor="#eeeeee">
                      <td  class=arial08><img src="PTMFOG0000000081.gif" width="6" height="8" border="0">&nbsp;<b>{$.headline$}</b></td>
                    </tr>

<!-- every page but the one you're on, doesn't work -->

                    {$foreach x in (and (keyword_contains "(index)") (not (filename "{$.filename$}")) )$}
                    <tr bgcolor="#eeeeee">
                      <td><A class=arial08 href="{$x.link$}"><img src="PTMFOG0000000081.gif" width="6" height="8" border="0">&nbsp;{$x.headline$}</a></td>
                    </tr>
                    {$next$}
                  </table>

Mark W
Saturday, March 23, 2002

I'm going to venture a guess.

{$foreach x in (and (keyword_contains "(index)") (not (filename "{$.filename$}")) )$}

It has to do with the order in which things are parsed in CityDesk. The expression is parsed before {$.filename$} is replaced with the filename.

If {$.filename$} were parsed first then we'd end up with:

{$foreach x in (and (keyword_contains "(index)") (not (filename "My New Article")) )$}

But since it's not, it looks for the string {$.filename$}, which isn't the name of any of my articles.


HA I just tried to check this by creating a filename named {$.filename$} with the keyword (index) and got this error:

"The variable .filename is not defined. (\keywords.html:530)"

Which has a loop with {$x.filename$} which was replaced by {$.filename$}... and somehow caused an error that *didn't publish*.

Temporarily disabling this I was able to check again.

This published a page with the quasi-legal name of .filename.html (try creating a name like that in Windows and you can't, but download .htaccess and it exists).

As expected it didn't show up in the loop, even though it had the keyword (index).

Which all goes to show you, when you're working with loops, it really pays to know what gets parsed first and what waits for later. In any case, I would consider this a bug and I'd LOVE to be able to do this with my sites.

Mark W
Saturday, March 23, 2002

Mark, in laymans terms, what is that Cityscript supposed to do?

TK
Saturday, March 23, 2002

=) I thought I might've been a little obscure.

It should create a listing of "every file that matches my criteria except this one."

To put it in the same terms as the script:

files with the keyword "(index)" AND are not this file.

Mark W
Saturday, March 23, 2002

CityScript can't have CityScript as a parameter.  At least not in v.1.

So you can't do things like {$foreach x in (folder {$x.extra1$}) $}

because the folder clause is a parameter.

Michael H. Pryor
Saturday, March 23, 2002

That is a really BIG pity, at least to us THE most important feature still lacking as it forces to script templates again every time a new

"foreach-depending on the current article"

is required. Mist. That was the only feature we hoped for in SP1, all the other improvements don't really mean anything to us in terms of new functionality (...well the "if" is kind of nice but don't need it either).

Very disappointing.

Patrick

Patrick Thomas
Sunday, March 24, 2002

Unfortunately this feature did not make it into consideration for SP1.  SP1 was scheduled to be a bug fix only release.  The only features that made it into SP1 were those that could be added with only minor changes in the code (so more bugs weren't introduced).

Major releases such as 2.0, 3.0 are scheduled to be feature releases and so something like the above would be scheduled for those releases.  Hopefully in one of the next major releases we'll add support for Active Scripting so you can do anything that jscript or vbscript (or perl) can do, and we don't have to duplicate effort be reinventing the wheel.  Of course CityScript would still be around for simple things.

With that in mind, it doesn't make too much sense for us to spend a lot of time expanding CityScript when advanced features will be accessible through a fully featured scripting language such as vbscript or jscript.

Again, sorry if we disappointed you.  We certainly didn't mean to give the impression that we were going to add the above feature during SP1, and if we did, we regret the confusion.

Michael H. Pryor
Sunday, March 24, 2002

Does this mean that CityScript will be stuck in this state and that in order to use CityDesk "to it's fullest extent" I'll have to learn these other scripting languages?

IMHO one of the strengths of CityDesk is the easy to use scripting language. Otherwise, what's the difference between CityDesk and, say, PHP?

Mark W
Sunday, March 24, 2002

Yes, please do spend at least a little time expanding CityScript.  Please.

tk
Sunday, March 24, 2002

Yes, please do reconsider.

The ability to use a variable such as .headline or any other article specific field or the current folder as a reference in

(folder "var") or (keyword_contains "var")

is the ONLY substantial feature missing, IMHO. It is very basic in order to be able to stick with one template instead of several templates (which our customers cannot add anyway, we would have to do it for them).

Example:

We have navigation buttons which are automatically generated using (folder "navigation") and this gives the individual articles as well as the links automatically. Very nice so far.

The CD user can easily add new navigation items by simply placing them in the "navigation" folder. Or removing them by deleting an article. Totally dynamic and transparent to the user.

But when we want the content of a (navigation) article to display second-level links to other, related, articles we have to resort to individual templates PER navigation item instead of simply doing a, e.g.

(folder "{$.extra2$}/morearticles")

which would allow us and the user to stick with one template only. Also it means that we cannot dynamically assign second-level articles = every time the user adds/changes a navigation item he would need us to script a new template hardcoding the second-level article folder with

(folder "products/morearticles")

This is very basic to any website we try to convert to CD at the moment and a major hurdle to sales of CD.

So, to us, never mind any further scripting features or new scripting language. On the contrary, CD is fine as is. Just this ability to use article-dependent variables in (folder) or (keyword_contains) is really important.

For everything else CD is great as is. Please reconsider. Thanks.

Patrick Thomas
telepark

Patrick Thomas
Monday, March 25, 2002

*  Recent Topics

*  Fog Creek Home