• Resolved celin007

    (@celin007)


    Hi,

    I want to check if a variable is null or not. Eg: if variable {date} is not null, I want to display date. Both ifNotEmptyAddLeft and ifNotEmptyAddRight doesnt work as there should be a text next to the variable.

    I want to show just the variable{date}, no text should be before or after it.

    Can you please help?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author berkux

    (@berkux)

    Hi,

    I’m not sure what is your challenge.
    If {..} is empty, nothing is displayed.

    Try this:
    [jsoncontentimporter url=https://wptest.kux.de/extra/celin007.php]
    date1: {date1} – {date1:ifNotEmptyAddRight:extratext1}<br>
    date2: {date2} – {date2:ifNotEmptyAddRight:extratext2}<br>
    date3: {date3} – {date3:ifNotEmptyAddRight:extratext3}<br>
    date4: {date4} – {date4:ifNotEmptyAddRight:extratext4}<br>
    [/jsoncontentimporter]

    Bernhard

    Thread Starter celin007

    (@celin007)

    Hi Bernhard,

    Thanks for the quick response.

    Imagine the variable date has value 2/3/2020
    The variable {date} will have value for a time period (for example from 1/3/2020 to 20/3/2020). All other times the value will be null.

    Input – {date:ifNotEmptyAddRight} output is empty
    Input – {date:ifNotEmptyAddRight:{date}} output shows 2/3/2020 2/3/2020 (displays twice)

    I want to display just the date not any text in front or after it.

    Is it possible to display just the date if not null?

    Thanks for all your help.

    Kind Regards
    Celin

    • This reply was modified 5 years ago by celin007.
    Plugin Author berkux

    (@berkux)

    Hi Celin,

    why is just using {date} not enough?

    Bernhard

    Thread Starter celin007

    (@celin007)

    Thanks Bernhard. You are a genius, I didn’t think that way.

    Regards
    Celin

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘JSON – variable is null or not’ is closed to new replies.