Question
Hello,
I'm been fighting with this for several hours, and finally decided it was time to ask for help
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
--
KathyDeLaCruz - 20 Oct 2008
Answer
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