ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

assign_variable Problem

December 31, 2008 7:04am

Subscribe [1]
  • #1 / Dec 31, 2008 7:04am

    juro

    118 posts

    Hi,
    I am having problems with the assign_variable functionality. Depending on the segment_3, I am assigning |-delimited email addresses to the variable notifyemail.
    Although the if/else… construct works, notifyemail is not correct. Moreover, it omits the first part, i.e.

    If segment_3 is ‘news’, notify_email is “|test.test.com”.

    This is the code:

    {exp:weblog:entries weblog="{segment_3}" dynamic="off" disable="categories|member_data|pagination|trackbacks" limit="1" url_title="{segment_4}"}
            {if segment_3 == "people"}
              {assign_variable:notifyemail="{mail}|[email protected]"}
              {assign_variable:subjectline="Website contact with {title}"}
            {if:elseif segment_3 == "offices"}
              {assign_variable:notifyemail="[email protected]|[email protected]"}
              {assign_variable:subjectline="Website contact with {title} office"}
            {if:elseif segment_3 == "news"}
              {assign_variable:notifyemail="[email protected]|[email protected]|[email protected]"}
              {assign_variable:subjectline="Website contact regarding article: {title}"}
            {if:else}
              {assign_variable:notifyemail="[email protected]"}
              {assign_variable:subjectline="Website Contact"}
            {/if}
            {segment_3} - {notifyemail}

    Should this not be possible, please state as to how I can solve this.

    juro

  • #2 / Dec 31, 2008 7:12am

    Ingmar

    29245 posts

    assign_variable is not meant to be used that way. It is a simple string replacement performed at the beginning of the template parsing process. In your case, I’d probably use some simple PHP.

    (PS: Neither test.com nor none.com are recommend to be used as placeholders the way you do, they are valid and existing domains. The only domain safe to use is example.com.)

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases