ph91.de
  • Home
  • About me
  • Categories
    • Software Development
    • New Zealand
    • Music
    • Tech & IT
    • Sports
    • Dublin
    • Junk
  • Contact
  • Disclaimer
ph91.de
ph91.de
  • Home
  • About me
  • Categories
    • Software Development
    • New Zealand
    • Music
    • Tech & IT
    • Sports
    • Dublin
    • Junk
  • Contact
  • Disclaimer
  • Software Development

wpDataTables Hack: Default to current year

  • 23. January 2021
  • Philipp

For speed-kini.de we have two types of tables:

  1. Tables which show the current rankings overall, women, juniors, foil..
  2. Tables which show rankings of previous years (archive) for overall, women, juniors, foil…

The initial approach was having two different wpDataTables: one for the current year and one with the year as variable. This duplication should ring all your software engineer alarm bells! 

Another possibility would have been to use the archive tables for the current rankings by just setting the variable to 2021, 2022 etc… this would mean work every year to edit the wordpress pages and manually increase the variable to the current year. So this is a bit nicer but still means regular maintenance work.

After some thought, I ended up with a neat approach how to use one table for both: current and archive.

For the current year you just leave the variable empty and for archive you specify the variable to your desired year. 
The mechanism to default to the current year in case no year is specified consists of two parts:

#1 Setting the default value of %VAR1% to a very high number (> 5000 should be enough 😉 )

#2 Small SQL modifications to the places which use %VAR1%

[...]

WHERE
YEAR(date) = LEAST(year(curdate()), %VAR1%)

[...]

Related Topics
  • speed-kini
  • wordpress
  • wpDataTables
Philipp

Previous Article
action adventure beach clouds
  • Software Development

Creating “Windwarner”

  • 2. January 2021
  • Philipp
View Post
37,567 comments

Comments navigation

Older comments
  1. finding the right personal loan options says:
    17. December 2025 at 07:32

    Nice Post. It’s really a very good article. I noticed all your important points. Thanks.

  2. fen daison kypit_jlet says:
    17. December 2025 at 07:33

    дайсон официальный сайт стайлер дайсон официальный сайт стайлер .

  3. melbet ry_ciSn says:
    17. December 2025 at 07:36

    мелбет полная версия сайта мелбет полная версия сайта .

  4. RandomNamebag says:
    17. December 2025 at 07:37

    designdiscoverhub – DesignDiscoverHub presents well-curated items in a clean, organized interface.

  5. sobaki slot_tyEt says:
    17. December 2025 at 07:37

    бонусы казино melbet бонусы казино melbet .

  6. melbet ry_uoKn says:
    17. December 2025 at 07:38

    мелбет официальный сайт мелбет официальный сайт .

  7. melbet ry_zvSn says:
    17. December 2025 at 07:39

    скачать приложение мелбет ставки на спорт скачать приложение мелбет ставки на спорт .

  8. melbet_gjsl says:
    17. December 2025 at 07:41

    мелбет букмекерская контора мелбет букмекерская контора .

  9. sobaki slot_ndEt says:
    17. December 2025 at 07:41

    играть в слоты играть в слоты .

  10. vivoz mysora _ogml says:
    17. December 2025 at 07:42

    вывоз мусора https://unews.pro/news/133692// .

  11. melbet_efsl says:
    17. December 2025 at 07:46

    промокод melbet промокод melbet .

  12. shkola onlain_vska says:
    17. December 2025 at 07:48

    онлайн школа для школьников с аттестатом https://www.shkola-onlajn1.ru .

  13. GELATIN TRICK says:
    17. December 2025 at 07:49

    Howdy, i read your blog from time to time and i own a
    similar one and i was just wondering if you get a lot of spam responses?
    If so how do you prevent it, any plugin or anything you can advise?
    I get so much lately it’s driving me mad so any help is
    very much appreciated.

  14. fen daison kypit_ydet says:
    17. December 2025 at 07:49

    фен купить дайсон официальный фен купить дайсон официальный .

  15. melbet_bePa says:
    17. December 2025 at 07:50

    мелбет личный кабинет мелбет личный кабинет .

  16. kypit sheben _fhEa says:
    17. December 2025 at 07:50

    щебень щебень .

  17. GELATIN TRICK says:
    17. December 2025 at 07:52

    Hey there! I’m at work browsing your blog from
    my new iphone 3gs! Just wanted to say I love reading through your blog
    and look forward to all your posts! Carry on the fantastic
    work!

Comments navigation

Older comments

Leave a Reply

Your email address will not be published. Required fields are marked *

ph91.de
Blog by Philipp Schreitmüller

Input your search keywords and press Enter.