Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

Is it possible to obfuscate php output of date in blog

Solved by pamtbaau View solution

Started by Joel Marks 6 years ago · 2 replies · 589 views
6 years ago

Shameless request to a coder for a quick solution for a non-coder.
I'm using unmodified Quark Open Publishing.

I'd like to keep the dates in my item.md blog files... and I'd like the blog to continue to be presented in date order...

However I would like Grav to somehow obfuscate the date wherever it is rendered on the site. I could keep the year and month, but I don't want users to know the day.

Is this even possible? Thanks to anyone who wants to chip in some ideas.
If I know how to ask the question, I could even post it on Fiverr as a small coding request.

Thank you fellow Grav users!
Joel

6 years ago Solution

@joel-marks, I've had a quick look at Open Publishing and think the following will do what you are after:

  • Copy file '/user/themes/quark/templates/partials/blog/date.html.twig' to '/user/themes/mytheme/templates/partials/blog/date.html.twig'.
  • Replace the contents with:
    TWIG
    <span class="blog-date">
      <time class="dt-published" datetime="{{ page.date|date("Y-m") }}">
          <i class="fa fa-calendar"></i> {{ page.date|date('Y-m') }}
      </time>
    </span>
    
  • The dates in the blog-item-list and each blog-item will now be: 'Y-m', or '2020-03'

Other date formats can be found at https://www.php.net/manual/en/function.date.php.
To set a different date format, replace 'Y-m" on line 3 with any combination found at above link, or below:

  • 4-digit year: Y (2020)
  • 2-digit month: m (01 - 12)
  • Full textual month: F (January through December)
  • A short textual representation of a month: M ( Jan through Dec)

Eg.

  • 'January 2020': 'F Y'
  • 'Jan 2020': 'M Y'
  • '2020/03': 'Y/m'

Hope this helps...

6 years ago

Thank you so much @pamtbaau that was exactly what I was looking for. Thanks for the link as well, there is some great stuff there.

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 4 days ago
2 74 6 hours ago
General · by pamtbaau, 11 hours ago
1 47 11 hours ago
General · by Andy Miller, 23 hours ago
0 43 23 hours ago
General · by Marcel, 12 months ago
6 346 5 days ago
General · by Duc , 5 days ago
3 39 5 days ago