Static Page Usage

This is the right place to report general bugs, make suggestions or ask for help.
Post Reply
User avatar
WineMan
Posts: 106
Joined: Tue Sep 01, 2020 5:03 pm

Static Page Usage

Post by WineMan » Thu Jul 21, 2022 1:50 pm

I have gone through the Wiki and can't seem to find the answer to my question which is...can php be used in static pages and if so how. I tried it with the code tag but all that does is show the php code. Thanks in advance.

User avatar
Arvid
FlatPress Coder
Posts: 558
Joined: Sat Jan 26, 2019 7:40 pm
Contact:

Re: Static Page Usage

Post by Arvid » Wed Jul 27, 2022 12:25 pm

Hi,

the code tag is indeed not for executing code, just for displaying it.

Take a look at the Inline PHP plugin - but make sure to read and understand the red warning box carefully.
The better (although more complex) way is always to embed your custom PHP code into a dedicated FlatPress plugin and/or custom BBCode tags.

All the best,
Arvid

User avatar
WineMan
Posts: 106
Joined: Tue Sep 01, 2020 5:03 pm

Re: Static Page Usage

Post by WineMan » Wed Jul 27, 2022 7:04 pm

Thank you Arvid...perhaps it will be better to generate my own plugin once I find out how to make my own plugin. Baby steps...

User avatar
Arvid
FlatPress Coder
Posts: 558
Joined: Sat Jan 26, 2019 7:40 pm
Contact:

Re: Static Page Usage

Post by Arvid » Thu Jul 28, 2022 12:09 pm

Don't worry, it's no rocket science, not at all :)

Start with the custom BBCode example, it's basically all you need to have a) your first own plugin that comes b) with your first own BBCode tag.
In the plugin_custombbcode_acronym() callback function that is called whenever a "acronym" tag is being parsed, you can return anything you like - for example, the output of the PHP code you wish to include.
If that works out, change the tag name from "acronym" to something more fitting, and play around with the other options in plugin_custombbcode_tags(). This is exactly how I started coding for FlatPress back in the days :)

All the best,
Arvid

Post Reply

Who is online

Users browsing this forum: No registered users and 51 guests