Load PHP code into Static Page
-
- Master Bludit
- Posts: 98
- Joined: Tue Jul 04, 2017 4:31 am
- Location: New Zealand
- Has thanked: 6 times
- Been thanked: 14 times
... managing a collection of snips - an interface where code can be written, named, saved/edited, (and a few other?) and page-inserted without the need to access template files.
I would be interested to see the extent of the (redundant?) existing snippet - but not enough to pay
cheers - kusalo
I would be interested to see the extent of the (redundant?) existing snippet - but not enough to pay
cheers - kusalo
- neogeo
- Ssr. Bludit
- Posts: 23
- Joined: Tue Sep 29, 2015 7:06 pm
- Has thanked: 8 times
- Been thanked: 3 times
If you want to experiment with this I could send you the https://plugins.bludit.com/plugin/php-shortcodes addon, but it does not work on php7 so you will need to do some fixes.arfa wrote: ↑Sat Oct 19, 2024 7:32 pm ... managing a collection of snips - an interface where code can be written, named, saved/edited, (and a few other?) and page-inserted without the need to access template files.
I would be interested to see the extent of the (redundant?) existing snippet - but not enough to pay
cheers - kusalo
- neogeo
- Ssr. Bludit
- Posts: 23
- Joined: Tue Sep 29, 2015 7:06 pm
- Has thanked: 8 times
- Been thanked: 3 times
Thx, I think that modifying the current template with conditional would be easier for me.Edi wrote: ↑Fri Oct 18, 2024 11:35 pmYou have two possiblities.
1) Add an if condition to the template
You can enclose your code with the if condition:
2) Use an own templateCode: Select all
<?php if ($page->slug() == "page-url-slug") { $items = getTags(); foreach ($items as $tag) { echo 'Tag name: ' . $tag->name(); } } ?>
You can use an own template, for example page-url-slug.php.
In this case you can modify the section $WHERE_AM_I in the index.php of your theme.
For example:
Code: Select all
if ($WHERE_AM_I == 'page') { if ($page->slug() == "page-url-slug") { include(THEME_DIR_PHP.'page-url-slug.php'); } else { include(THEME_DIR_PHP.'page.php'); } } else { include(THEME_DIR_PHP.'home.php'); }
But I'm wondering if creating my own template would better/faster than the other option.
-
- Master Bludit
- Posts: 98
- Joined: Tue Jul 04, 2017 4:31 am
- Location: New Zealand
- Has thanked: 6 times
- Been thanked: 14 times
If you only have one or two custom-code elements then working with the template would probably be good enough. But... if you like the flexibility of adding, editing and such and have thoughts for future spice then a plugin ??
I used to mutter with wordPress - !ABP... = another bloody plugin
it seemed that *everything* needed one (not quite
I would be very interested to see the approach of the snippet plugin so you can PM me (I need to change my email) with some detail. I am pretty PHP useful - but can't promise anything. I am still learning how-to in bludit.
I used to mutter with wordPress - !ABP... = another bloody plugin
it seemed that *everything* needed one (not quite
I would be very interested to see the approach of the snippet plugin so you can PM me (I need to change my email) with some detail. I am pretty PHP useful - but can't promise anything. I am still learning how-to in bludit.
-
- Master Bludit
- Posts: 98
- Joined: Tue Jul 04, 2017 4:31 am
- Location: New Zealand
- Has thanked: 6 times
- Been thanked: 14 times
I have tested the plugin [thanks neogeo for sending me that]
https://plugins.bludit.com/plugin/php-shortcodes
and got it working but... and it is a big BUT... there is enough that needs work that I can't see it being sorted by me. And when I say 'working' I mean functional; I suspect there may be elements of the package that I am not seeing. Just as an indication of the complexity there are 132 files in 15 folders; untangling some of my own old code can be tragic enough. I wonder if anyone tried contacting the author?
The plugin uses cURL which is especially good for connecting to remote sites, with some inherent danger, but for local insertion I can think of easier ways. I have started a plugin that so far feels flexible enough. It needs tidying up and testing so may take a while -
Bottom line...
unless the author of this plugin (or someone else?) is able to address this I suspect it may not be relevant.
happy hunting - kusalo
https://plugins.bludit.com/plugin/php-shortcodes
and got it working but... and it is a big BUT... there is enough that needs work that I can't see it being sorted by me. And when I say 'working' I mean functional; I suspect there may be elements of the package that I am not seeing. Just as an indication of the complexity there are 132 files in 15 folders; untangling some of my own old code can be tragic enough. I wonder if anyone tried contacting the author?
The plugin uses cURL which is especially good for connecting to remote sites, with some inherent danger, but for local insertion I can think of easier ways. I have started a plugin that so far feels flexible enough. It needs tidying up and testing so may take a while -
Bottom line...
unless the author of this plugin (or someone else?) is able to address this I suspect it may not be relevant.
happy hunting - kusalo