• [if exists]{PARAM}[show]The first parameter was passed
    [else]The first parameter wasn't passed[/if]

    the else only works correct if i send as [myshortcode param=""]

    if i just use [myshortcode] then [if exists] returns true.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter codemonkeynorth

    (@codemonkeynorth)

    i found a workaround for now:

    [if check={PARAM} value="{PARAM}"]
    param not passed
    [else]
    {PARAM}
    [/if]

    essentially if the param isn’t passed in the shortcode then {PARAM} just equates to the literal string "{PARAM}" so it means it hasn’t parsed it to something else

    Thread Starter codemonkeynorth

    (@codemonkeynorth)

    above doesn’t seem to work anymore

    anybody know a way to check if a param wasn’t passed?

    thanks

    Thread Starter codemonkeynorth

    (@codemonkeynorth)

    found another temporary workaround, for anybody awaiting a fix:

    [myshortcode]
    [myshortcode param="foo"]

    
    [if exists][format split="{}" part=2]{PARAM}[/format][show]
    param was not passed
    [else]
    param was passed as {PARAM}
    [/if]
    

    what the format split does is create the literal string “PARAM” if no param is passed, or creates a blank string if a param *was* passed, since there are no {} brackets to split on due to it being parsed to an actual value

    Thread Starter codemonkeynorth

    (@codemonkeynorth)

    i found why my original workaround failed in some cases

    [if check={PARAM} value="{PARAM}"]
    param not passed
    [else]
    {PARAM}
    [/if]

    if param does not contain a space it doesn’t work

    [myshortcode param="foo"] shows “param not passed”
    [myshortcode param="foo bar"] shows “foo bar”

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[if exists]{PARAM} – else clause fails unless param sent as blank string’ is closed to new replies.