Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Besim Karadeniz

    (@besimk)

    Hello again,

    I have made a workaround but it’s a bit dirty and would be better with some intentions from the plugin site.

    I have a loop to get some content from post of a given category, in a specified year (done with a custom field named “jahr”) and a specified weeknumber (custom field “kalenderwoche”):

    [loop type=post category=wochenangebot field=jahr value=today date_format=o field_2=kalenderwoche value_2=today date_format_2=W]
    <p>[user]
    [pass field=modified date_format=N]
    [if pass='{FIELD}’ value=1]
    [field monday_angebot] ? [field monday_preis] Euro
    [field monday_hinweis]
    [/if]
    [if pass='{FIELD}’ value=2]
    [field tuesday_angebot] ? [field tuesday_preis] Euro
    [field tuesday_hinweis]
    [/if]

    … so on for every day of a week …

    [/pass]
    [/loop]

    The crux is to get the current weekdaynumber in a string. I’ve tried to get the “today” value in a loop which works (as a value). But using this Today-Field in an IF (or SWITCH) doesn’t work.

    So my workaround gets in a PASS the modified_date of the post and formats this string with “N” into the ISO weekday number. When I’m scheduling this article with an task scheduler and reposting this post every day so this works.

    But it would be cleaner and more secure if we could use the current date/time in a usable way.

    Besim

    Plugin Author Eliot Akira

    (@miyarakira)

    Hi,

    I’m scheduling this article with an task scheduler and reposting this post every day

    Wow, that is quite a workaround!

    In the newest udpate v3.3.0, I added a feature to switch by day of week:

    [switch day_of_week]
      [when 1]Monday[/when]
      [when 2]Tuesday[/when]
      ...
      [when 7]Sunday[/when]
    [/switch]

    I hope that will simplify things for you. ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using Switch with Today’ is closed to new replies.