Search…

X3 Photo Gallery Support Forums

Search…
 
User avatar
Dane
Experienced
Topic Author
Posts: 173
Joined: 04 Dec 2020, 15:05

Gallery NEW Badges – Original Upload Date and Sorting by Date

Today, 06:40

Hi,

I’ve implemented another small feature on my X3 site that marks new content with a “NEW” (NEU) badge.

The logic currently works like this:

- If a blog article is newer than 30 days, it gets a NEW badge.
The main Articles menu item also shows NEW if at least one recent article exists.
- I added the same system to the gallery.
- If a gallery category contains content from the last 30 days, the Gallery menu item and the corresponding gallery category are marked NEW.
- Inside the gallery category, the individual recent gallery entries are marked as well.
- The result is cached locally for performance, so the gallery does not need to be checked again on every page load.
2026-09-01 12_36_34-.jpg
2026-09-01 12_36_34-.jpg (247.24 KiB) Viewed 8 times
2026-09-01 12_36_12-Einstellungen.jpg
2026-09-01 12_36_12-Einstellungen.jpg (79.73 KiB) Viewed 8 times
2026-09-01 12_35_53-Einstellungen.jpg
2026-09-01 12_35_53-Einstellungen.jpg (68.39 KiB) Viewed 8 times

For the gallery entries I’m currently reading:
Code
<meta property="og:updated_time" ...>
and using that value as the date.

However, og:updated_time is of course the last modified/updated date, which is not necessarily the same as the date when the gallery entry was originally uploaded or published.

Is there an X3 variable, meta tag or other value available on the gallery detail page that contains the original upload/publication date?

If so, what is the field called? I’d then change the JavaScript to use that date instead of og:updated_time.

I also have one related issue regarding the sorting of my gallery entries.

Ideally, the newest images should always appear at the top of each gallery category. However, after updating some existing gallery entries, the order seems to have changed and is now mixed up.

In the gallery sorting settings I have already selected Date, but this does not seem to give me the expected result.

Is X3 sorting by the last modified date in this case as well, or is there another setting/field I should use if I want the gallery to be sorted strictly by the original upload or publication date, with the newest entries first?

Thanks for any help!
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14486
Joined: 30 Sep 2006, 03:37

Re: Gallery NEW Badges – Original Upload Date and Sorting by Date

Today, 22:18

Nice job on this. It's a bit unclear how the Javascript works ... I can see how you might use `<meta property="og:updated_time` to see if a specific page is updated. However, it's not clear how your Javascript knows that a menu item (like in your screenshot) knows that that the link is "NEU" ... It seems you are using some javascript that loads all the pages in the background and checks the meta tag? OK.
Dane wrote:However, og:updated_time is of course the last modified/updated date, which is not necessarily the same as the date when the gallery entry was originally uploaded or published.
True. You would need to get creative. X3 uses "og:updated_time" simply because that's the "modified time" of the folder on the server. On the other hand, if you are adding new images to the folder, then shouldn't the folder become "NEU" when there is new content and `og:updated_time` gets updated? Unfortunately, there is no "when a folder was first created" timestamp anywhere on your server, so X3 simply can't know this.

In reality, if you needed a "first created" timestamp, this would need to get stored in TXT or JSON file at the point in time when the folder gets created from the X3 panel. Otherwise, we simply don't know.

On a related note, if someone asked me to build this from scratch, I would perhaps use a PHP script to loop through the dirs, and get the date of the "oldest" file inside each dir. The oldest file would normally approximately be the earliest date the folder existed. You would then return all the data as a JSON response to javascript. Still not an optimal process, but surely more optimal than remote-loading all pages in multiple requests from javascript.

Some would argue that you should want to get the "updated time" of each dir instead of "the oldest file inside", so that you know if any of the content of the dir was updated, and it could be considered "new (content)".

For a simple solution, although it feels much less elegant, it would only take you a couple of minutes every week/month to add a class to the pages and menu items that you want to be considered as "new". Yep, not elegant, but it would allow you to have full control.
Dane wrote:Ideally, the newest images should always appear at the top of each gallery category. However, after updating some existing gallery entries, the order seems to have changed and is now mixed up.
If you are sure that you have selected sorting by DATE (descending) for the specific GALLERY, then yes it would sort images by date. The only thing that could cause some confusion, could be if one (or more) of your images contain EXIF date, while some don't. If you have a folder that is sorted incorrectly, please include a link so I can diagnose.