Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Data Driven Citydesk Site

I did a little write up on creating a data driven web site ( http://www.stronglytyped.com/Articles/Buildingadatadrivensitewi.html ) with CityDesk which led me to another thought:

Would it be advantageous to add custom fields to articles?

For example:  Let's say I was maintaning a product list in CityDesk.  I could use a custom field for SKU, price, qty, etc.

Richard Caetano
Wednesday, April 03, 2002

I'm fairly new to CityDesk but was also thinking about custom fields in articles. They could be saved as label/value pairs in a single field in the CD database using XML. This way there would be no limitation on the number and names for the fields (except for field size limitations of the database, of course). The user interface would hide the XML and work like the variable editor already in CD.

I'd also like to see true If statements to go with them so that I could test article field values and control the rendering of the page accordingly.

Anyone else feel this way? Has it already been suggested?

P.S. While I'm asking...
How about a field to return the folder name for an article and a condition that matches all articles within the same folder as the current article with optional exclusion of the current article?

Stu
Wednesday, April 03, 2002

Nice proposal!  I use XML in this manner with some of my code...seems to be a nice fit.

Richard Caetano
Wednesday, April 03, 2002

I don't see the point in doing that since there is an editor anyways for articles in CityDesk. Why not just insert the name, address, all that stuff, there, instead of clicking properties and inserting a picture and all that stuff in the different sidebars and teasers.

Why not just add it in the regular site WYSIWYG editor provided in CityDesk. I don't see a use for the properties.

Jared
Wednesday, April 03, 2002

In Richard's situation, I believe he'd like to have a way to change the look of the data without editing the articles containing the data. Having separate fields would allow him to specify the format in the template and change it at will or publish the data in different formats by using template sets.

For me, I'd like to be able to test the values of the fields using If statements that conditionally controlled the formatting of the article and to store more pieces of information than you can currently.

An example of the first use is to display a vaue in red if it exceeds a trigger value in a field.

As for the second, I want to specify the graphic to use on the top of each article page. I can't do that in the body of the article so I have to use one of the extra fields. That's one down and one to go. With the current limitations I have to be very careful in choosing the customizations I will use in designing my site.

Another possible use for the fields would be in embedding data in the middle of an article. Suppose you have a set of articles describing your salespeople. It would be nice to be able to update certain data (gross sales, major clients, client quotes, etc.) using an outisde program or the CD editor and have the data embedded within the body of the article. Once again having just 2 Extra fields is a bit limiting and placing the data in separate articles and nesting them can get a bit awkward.

I see a lot of up-side to this idea.

Stu
Thursday, April 04, 2002

I would like to be able to do calculations with CD and show the result.

Something like putting numbers in fields, like
(extra1*extra2)/sidebar

How could this be done?
Thanks.

Paul Iliano
Friday, April 05, 2002

Well...

I've been giving it a lot of thought and I've come up with an answer for Richard's situation as well as other calculations. It involves JavaScript and setting Java variables using the extra1 field. You then use named SPAN or DIV tags in your template or article and some JavaScript to set the innerText property of the tag.

To get this to work within a FOR loop you also have to make the IDs of the multiple tags unique for each pass of the loop. To do that I place an identifier in the extra2 field and concatenate it to the ID of the tag as it's rendered.

Believe me, it sounds much more complicated than it really is. I'm working up a page with a full explanation but in the meantime feel free to take a look at a sample cty file I've uploaded to my site. The URL is:

http://www.stuartistry.com/citydesk/testdir.cty

Here's an outline of what to look for:

. The extra1 field doesn't allow HTML so I created variables to start and end the JavaScript block.

. The extra1 field has the definitions of the variable values. For this example, based on Richard's message, I set up employee directory data. Each article represents a person. The variables are reused for each person and will change their values to represent the current person for each pass of the FOR loop.

. The extra2 field contains a unique identifier for each person. It is used to render unique SPAN tag IDs when the directory is rendered.

. The index article renders each person's data. At the top of the loop it renders extra1 to set the variables. Within the loop each field is represented by a SPAN block with a unique ID generated by concatenating the extra2 variable to the field name. At the bottom of the loop there is a JavaScript block that sets the SPANs to the values set at the top of the loop using the same unique IDs. Here is where any calculations would be performed.

. The template required no modification. I didn't modify how an article is displayed so there is extraneous data displayed if you click on a name in the directory and bring up the detail.

I believe that's about it. Sorry to post such a long message here but I thought it important to get this info out before I could formally add it to my website.

I intend to use a similar technique to do things like conditionally display data and modify my menus depending on the article being rendered and its folder.

If anyone has any questions feel free to write. I hope this proves useful.

Stu
Friday, April 05, 2002

We are building an internal site for which we desperately need to have per-article meta data.

To be clear, I want to have a set of articles that each have a list of answers to specific questions.

Take a simple example, a real-estate site (not what we're building.) For a real estate site, we would need to include price, #bathrooms, #bedrooms, etc. Then we would like to index the site and report on houses that have 2 or more bedrooms, and cost less than $300,000.

We're getting into a new range of functionality here ... but content managers need this kind of stuff.



Michael or Joel, do you care to comment on this issue?

Alan Armstrong
Friday, April 05, 2002

If I was doing what you are doing, I would build a database that could be read by .asp code or perl or some scripting language on the server.

If you want the data to be changeable by a non-technical sort, create a data entry page with a form to update the data tables

Joel Goldstick
Friday, April 05, 2002

To Joel Goldstick, I understand the workaround you're describing, but in the longer term that's not a solution for the average CityDesk user. CityDesk should make it easy for an MS Office user with scripting-level abilities to manage content including meta-information. Designing, deploying and managing databases is asking too much for the average user.

BTW, most average users (and they're the most important) cannot even deploy a database, because they have no access to the server, and ISP-managed database functionality is expensive.

Alan Armstrong
Saturday, April 06, 2002

I agree. If I had access to the server, a database, ASP, and a solid understanding of how all 3 worked, why would I need CityDesk?

Mark W
Wednesday, April 10, 2002

I would like to add my name to the list of people asking for more than two 'extra' data fields.

I am considering migrating my smallish web site [ www.marquis-kyle.com.au ] to CityDesk, and having more fields would make things better for me.

BTW: After experimenting with the CD demo version for a few hours I am very impressed. I used to think a database-based system was beyond me.

Peter Marquis-Kyle
Monday, April 15, 2002

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

tk
Wednesday, April 17, 2002

*  Recent Topics

*  Fog Creek Home