Page 2 of 2
Re: Load PHP code into Static Page
Posted: Sat Oct 19, 2024 10:02 am
by Kamikaze
@arfa,
Why create a plugin for a task that is solved with two lines of code?
Re: Load PHP code into Static Page
Posted: Sat Oct 19, 2024 7:32 pm
by arfa
... 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
Re: Load PHP code into Static Page
Posted: Sat Oct 19, 2024 7:54 pm
by neogeo
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
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.
Re: Load PHP code into Static Page
Posted: Sat Oct 19, 2024 7:58 pm
by neogeo
Edi wrote: Fri Oct 18, 2024 11:35 pm
neogeo wrote: Fri Oct 18, 2024 5:17 pm
Do you know which is the php-condition to show the tags only to a specific page-url-slug?
You have two possiblities.
1) Add an if condition to the template
You can enclose your code with the if condition:
Code: Select all
<?php
if ($page->slug() == "page-url-slug") {
$items = getTags();
foreach ($items as $tag) {
echo 'Tag name: ' . $tag->name();
}
}
?>
2) Use an own template
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');
}
Thx, I think that modifying the current template with conditional would be easier for me.
But I'm wondering if creating my own template would better/faster than the other option.
Re: Load PHP code into Static Page
Posted: Sat Oct 19, 2024 10:38 pm
by arfa
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.
Re: Load PHP code into Static Page
Posted: Wed Oct 30, 2024 9:26 pm
by arfa
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
Re: Load PHP code into Static Page
Posted: Sat Feb 15, 2025 9:29 pm
by arfa
This is going back a while and I wonder if the OP is still open?
How could I load that code on specific static page only. Is it possible?
As I mentioned I had been looking to wirte a plugin to add code to individual pages. Have a look here:
https://plugins.bludit.com/plugin/addcode2page#download
I haven't tried but how about (using this snippet in the plugin):
Code: Select all
<?php
// Returns an array with all the tags
$items = getTags(); // this may need adjustment/teaking?
foreach ($items as $tag) {
$snipData .= 'Tag name: ' . $tag->name();
}
?>
I would be interested to hear if you try this - and any result.