Load PHP code into Static Page

Kamikaze
Jr. Bludit
Posts: 3
Joined: Mon Sep 30, 2024 7:33 pm
Been thanked: 1 time

@arfa,

Why create a plugin for a task that is solved with two lines of code?
arfa
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
User avatar
neogeo
Ssr. Bludit
Posts: 23
Joined: Tue Sep 29, 2015 7:06 pm
Has thanked: 8 times
Been thanked: 3 times

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.
User avatar
neogeo
Ssr. Bludit
Posts: 23
Joined: Tue Sep 29, 2015 7:06 pm
Has thanked: 8 times
Been thanked: 3 times

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.
arfa
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.
arfa
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
Post Reply