Search…

X3 Photo Gallery Support Forums

Search…
 
User avatar
JMM
Experienced
Topic Author
Posts: 154
Joined: 02 Aug 2021, 11:18

Is there a way that I can get X3 to display the result of the PHP function: echo date("Y") ?

10 Jun 2023, 00:24

Hello, Karl,

I realize that footers (and other parts) of X3 are not able to execute PHP by default.

Is there a way, somehow, that I can get the result of the following to display in my footers?
Code
<?php echo date("Y"); ?>
At present, the result would be 2023 (the current year), and I would like to display that year for the "to" part of my :copyright: Copyright in my X3 footers.

Example:
For one of my X3 sites, the footer shows :copyright: 2008-2023.  Each year I need to remember to manually increment the current year to the next year.  I realize that it's something very-minor & only takes just a couple of seconds to change for each of my X3 sites, but I was hoping that there is a way that I can automate it, similar to the way PHP does it with the above PHP function.

Similar to the way that I can add Custom-CSS to my X3 sites/folders, and then call that Custom-CSS using <span>, is there a similar way that I could call that PHP function?

Thanks in advance & have yourself a great day.

Regards,
John
Location: Burlington (Toronto-ish), Ontario, Canada
Self-hosted using Abyss Web Server:   AuroraWings.me   |   GalleryWings.com   |   PanAurora-Studio.com   |
Externally-hosted using LiteSpeed/Apache Web Server:   GenealogyWings.com/galleries   |
 
User avatar
JMM
Experienced
Topic Author
Posts: 154
Joined: 02 Aug 2021, 11:18

Re: Is there a way that I can get X3 to display the result of the PHP function: echo date("Y") ?

10 Jun 2023, 00:38

It looks like I might be able to use something like this... still investigating how to use it...
Code
.getFullYear();
Location: Burlington (Toronto-ish), Ontario, Canada
Self-hosted using Abyss Web Server:   AuroraWings.me   |   GalleryWings.com   |   PanAurora-Studio.com   |
Externally-hosted using LiteSpeed/Apache Web Server:   GenealogyWings.com/galleries   |
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13998
Joined: 30 Sep 2006, 03:37

Re: Is there a way that I can get X3 to display the result of the PHP function: echo date("Y") ?

10 Jun 2023, 04:08

JMM wrote: It looks like I might be able to use something like this... still investigating how to use it...
Code
.getFullYear();
Yes, javascript is the way to go for such simple functionality rendered directly in the browser. You could just add the below code wherever you want the current year to display:
Code
<script>document.write(new Date().getFullYear())</script>
 
User avatar
JMM
Experienced
Topic Author
Posts: 154
Joined: 02 Aug 2021, 11:18

Re: Is there a way that I can get X3 to display the result of the PHP function: echo date("Y") ?

10 Jun 2023, 20:08

That worked perfectly, Karl, thank you.

Am I also able to use Javascript or CSS to display the output of:
Code
phpversion();
Just looking to (hopefully) have an output similat to 8.2.5 to also display in my footer (which is currently hard-coded in my footers).

Thanks in advance & have a great day.

Regards,
John
Location: Burlington (Toronto-ish), Ontario, Canada
Self-hosted using Abyss Web Server:   AuroraWings.me   |   GalleryWings.com   |   PanAurora-Studio.com   |
Externally-hosted using LiteSpeed/Apache Web Server:   GenealogyWings.com/galleries   |
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13998
Joined: 30 Sep 2006, 03:37

Re: Is there a way that I can get X3 to display the result of the PHP function: echo date("Y") ?

10 Jun 2023, 21:44

You can't use PHP directly in X3, mainly because X3 caches processed pages into html templates, and we want to avoid PHP processing for best performance on output. It would also be a security hole if we allowed PHP input directly in the content section. This is meant for html only.

Although you can use Javascript to display non-server related info like DATE, "PHP version" is on the server and Javascript knows nothing about it. The only way you could introduce this into X3, would be to build some "get_version.php" and call it via Javascript and then inject it. Definitely not worth the hassle compared to adding it manually. Especially considering nobody has much interest in this info, and most would avoid putting the PHP version public, as it's considered a security vulnerability.
 
User avatar
JMM
Experienced
Topic Author
Posts: 154
Joined: 02 Aug 2021, 11:18

Re: Is there a way that I can get X3 to display the result of the PHP function: echo date("Y") ?

13 Jun 2023, 08:13

I kinda figured that it couldn't be done.  And noted about that info being a security risk.

Thanks anyway & have a great day.
Location: Burlington (Toronto-ish), Ontario, Canada
Self-hosted using Abyss Web Server:   AuroraWings.me   |   GalleryWings.com   |   PanAurora-Studio.com   |
Externally-hosted using LiteSpeed/Apache Web Server:   GenealogyWings.com/galleries   |