NEW - Add code to page

Post Reply
arfa
Master Bludit
Posts: 145
Joined: Tue Jul 04, 2017 4:31 am
Location: New Zealand
Has thanked: 13 times
Been thanked: 24 times

A shortcode system to insert code (PHP, jQuery, HTML) on individual pages.
The plugin compiles a single php variable, using your code, and swaps it with the shortcode.

This was on my list anyhow but grew as a response to this post.
viewtopic.php?p=13561&hilit=code#p13561

It is in the repository:
http://localhost/bum/admin/configure-plugin/akSnippets

This is my 2nd plugin and I am still learning Bludit so feedback is welcome. This can easily include mod suggestions - which I am happy to explore, develop, add.

Depending on take up here there is the possibility of sharing snippets. What use are you putting it to?

enjoy - Kusalo
User avatar
novafacile
Master Bludit
Posts: 130
Joined: Sat Oct 06, 2018 4:47 pm
Has thanked: 58 times
Been thanked: 17 times
Contact:

Thanks for this, but:
arfa wrote: Fri Feb 14, 2025 6:55 pm It is in the repository:
http://localhost/bum/admin/configure-plugin/akSnippets
This is localhost. Nobody has access to this, except you. ;)

You have to publish it to github or a similar service.
arfa
Master Bludit
Posts: 145
Joined: Tue Jul 04, 2017 4:31 am
Location: New Zealand
Has thanked: 13 times
Been thanked: 24 times

@novafacile
Thanks for the feedback... the URL you echoed is indeed one of my offline tests - a bum (steer).

My bad - it should read...
It is in repository: https://plugins.bludit.com/plugin/addcode2page#download

just an old brain...
thx - Kusalo
User avatar
LRAM
Legend Bludit
Posts: 223
Joined: Sat Sep 24, 2016 4:02 pm
Location: France
Has thanked: 48 times
Been thanked: 5 times
Contact:

Hi
I asked claude.ia to make me a php script listing the videos in a specific directory and allowing me to read them
this script works like a charm
if I want a Bludit page to use this script, how do I proceed? how do I call the script from your plugin, I've read the example, I can't see what I need to write and where
thank you.
https://sucrepop.com
Candies for the ears
arfa
Master Bludit
Posts: 145
Joined: Tue Jul 04, 2017 4:31 am
Location: New Zealand
Has thanked: 13 times
Been thanked: 24 times

The plugin is for writing a variable - $snipData - to a page. Without seeing your script I am not able to say how it might best be added to $snipData. You can see in the example snippet I have used some jQuery.

You have a php script and I wonder how complex it is. It may require an ajax call and I have not tried that with addCode2Page.

>> videos in a specific directory
Is that a local directory or remote?

If the script is not too huge you can post it here and I can have a look and further share thoughts.

go well - Kusalo
User avatar
LRAM
Legend Bludit
Posts: 223
Joined: Sat Sep 24, 2016 4:02 pm
Location: France
Has thanked: 48 times
Been thanked: 5 times
Contact:

Thank for the answer
it's a remote directory
Here's the script generated by Claude
Attachments
mp42.zip
(2.49 KiB) Downloaded 157 times
https://sucrepop.com
Candies for the ears
arfa
Master Bludit
Posts: 145
Joined: Tue Jul 04, 2017 4:31 am
Location: New Zealand
Has thanked: 13 times
Been thanked: 24 times

OK - AI...? It can be useful for sure.
If you understand how code2Page works then you can do it yourself.
You have an array $videos
You need to loop through that adding to $snipData concatenating using .=
for ($i=0; $i<count($videos); $i++) {
$snipData .= '<div ???>'.$videos[$i].'</div>';
}
This is hardly complete but I hope you get the idea.

So, AI -
I asked my friend
can you write a complete compilation - including the php function and all. Also the css - written as a part of the $snipData .= compilation.
The aim is to have a complete code that runs and compiles $snipData - which is echoed on a web page via the plugin
And it compiled the following:

https://kusalo.net/temp/videoSnippet.zip
In theory all you need to do copy/paste the whole php into a new snippet instance + change $directory = __DIR__;
insert your [% snip=whateverYourSnippet %] on a bludit page - Et voilà !

IMHO - Claude is too verbose. The script could be simpler.
Let me know how this goes.
kusalo
User avatar
LRAM
Legend Bludit
Posts: 223
Joined: Sat Sep 24, 2016 4:02 pm
Location: France
Has thanked: 48 times
Been thanked: 5 times
Contact:

Thank a lot
Will try that and tell you how it goes
https://sucrepop.com
Candies for the ears
arfa
Master Bludit
Posts: 145
Joined: Tue Jul 04, 2017 4:31 am
Location: New Zealand
Has thanked: 13 times
Been thanked: 24 times

I had a look through the script and spotted a blip - about line 234
$snipData .= '</div>'; // .video-list
$snipData .= '</'; this line had no closing ';

total failure without.
Post Reply