Tags:
create new tag
view all tags

Question

Hello,

I'm been fighting with this for several hours, and finally decided it was time to ask for help smile

This works:

%IF{ "%FORMFIELD{"citycode" topic="AGA"}%" then="%INCLUDE{InclCitySideMenu}%"}%

But when I try to use a variable for the topic name, it doesn't work:

%IF{ "%FORMFIELD{"citycode" topic="%PORTCODE%"}%" then="%INCLUDE{InclCitySideMenu}%"}%

I tried all the combinations of quotes, no quotes, backslashes, %, $percnt, etc that I could think of, but couldn't get it working -it would either return nothing, or return part of the if statement, or just a mess...

I had more luck in other places using calc inside the topic parameter in a form field

(example: This works:

Set PORTCITY = %FORMFIELD{"cityname" topic="%CALC{$REPLACE(%INCLUDINGTOPIC%, 4, 100)}%"}%

But this does not:

Set PORTCODE = %CALC{$REPLACE(%BASETOPIC%, 4, 100)}%

Set PORTCITY = %FORMFIELD{"cityname" topic="%PORTCODE%"}%

So I thought I'd use calc:

%IF{ "%FORMFIELD{"citycode" topic="%CALC{$REPLACE(%BASETOPIC%, 4, 100)}%"}%" then="%INCLUDE{InclCitySideMenu}%"}%

But I couldn't get that to work either, even using all kinds of combinations of quotes, etc.

I saw this support topic: UseCalcInTopicName, but couldn't figure out how to apply it to my situation

The idea behind this is that I want to include a file in my webleftbar for only some pages. I'm trying to figure out if a page is one that should include the file or not.

The pages I want to include this file in, are ones that relate to a city, and all pages related to a city will have that city's code as the first 3 characters of the topic name, and the main topic for a city is named with just the 3-character code. Each main page has a form attached to it, containing several fields, one of which is "citycode" -- if this field does not exist, or is empty, then I do not want to include this file in the webleftbar.

I don't want to attach the form to ALL city-related topics, because I'm using a search that creates Country and Region menus, and I only want it to show the main page for each city. (And I have 10,000 pagesin this web, and I think the search might be slower if it has to search through so many more forms ...)

Can someone see what I'm doing wrong?

Thank you!

Kathy

Environment

TWiki version: TWikiRelease04x01x02
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Windows 2003 server
Web server: Apache 2
Perl version: indigo perl 5.8.6
Client OS: Windows
Web Browser: Firefox, IE
Categories: Forms

-- KathyDeLaCruz - 20 Oct 2008

Answer

ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.

OK, I really don't know what happened. It is working, after all!

Maybe my vision was off from staring at this for so long, but this syntax does work:

%IF{ "%FORMFIELD{"citycode" topic="%CALC{$REPLACE(%BASETOPIC%, 4, 100)}%"}%" then="%INCLUDE{InclCitySideMenu}%"}%

I will leave this here in case anyone else runs into a similar problem.

-- KathyDeLaCruz - 20 Oct 2008

Change status to:
Topic revision: r1 - 2008-10-20 - KathyDeLaCruz
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.