Forum OpenACS Development: lang::messages not existing

Posted by Jeff Rogers on

I have a form that I want to optionally put help text on each field. The most flexible way to set this up (i.e., so I can delegate the writing of the help text to a writer) is to make the help text a message that can be managed through the i18n system. Not every field will have helptext, so I only want to render the help link (a "?" to pop up the helptext) if the help text is set.

However, when rendering a template, #strings# aren't expanded in tags, so you can't do logic with them. What I ended up with is this, which is kind of ugly:

<% if {[lang::message::message_exists_p [ad_conn locale] mysite.$elements(id)_help]} { %>
<% } else { %>
  No help available.
<% } %>

Is there a cleaner way to accomplish this switching on message existence?

Posted by Gustaf Neumann on
A cleaner way is probably to set a proper variable from the .tcl side based on the connection locale and to test then with something along the following lines:

   <if not nil>
      No help available.

or even define your help-widget via an own tag:

<my_help_widget id="@id@" />