Advanced plugin development documentation
Hi, i've chosen Bludit v3.13.1 for a project, and there is a bit of extra functionality i couldn't find in plugins, so i opted into making a plugin of my own.
And i have questions i haven't found answers to in docs and forum, that could lead to extension of the documentation portal of yours (unless you can point me to pages, that already explain the how-to):
1) db.php is for plugin settings, right? but i also need to have an extra data structure. Just like Categories do - plugin settings for the "looks" and core data about links, and page-category relations. What is the proper way to make plugin create extra json-datastructures?
2) you have docs on how to create extra editor fields/options, but i'd like my plugin to do that on installation/removal. What's the programmatic hoop for this?
And i have questions i haven't found answers to in docs and forum, that could lead to extension of the documentation portal of yours (unless you can point me to pages, that already explain the how-to):
1) db.php is for plugin settings, right? but i also need to have an extra data structure. Just like Categories do - plugin settings for the "looks" and core data about links, and page-category relations. What is the proper way to make plugin create extra json-datastructures?
2) you have docs on how to create extra editor fields/options, but i'd like my plugin to do that on installation/removal. What's the programmatic hoop for this?
- Edi
- Site Admin
- Posts: 3121
- Joined: Sun Aug 09, 2015 5:01 pm
- Location: Zurich
- Has thanked: 54 times
- Been thanked: 78 times
- Contact:
The easiest way is to look how other plugins are written and modify it to your needs. There are a lot of them with a lot of functions.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
- Edi
- Site Admin
- Posts: 3121
- Joined: Sun Aug 09, 2015 5:01 pm
- Location: Zurich
- Has thanked: 54 times
- Been thanked: 78 times
- Contact:
As you wrote: It's the easiest way.
And yes, learning could somethimes be hard. Also to learn coding.
Bludit uses JSON. There are a lot of tutorials about it. For example there is a tutorial at1) db.php is for plugin settings, right? but i also need to have an extra data structure.
https://www.w3schools.com/js/js_json_intro.asp
What do you mean with "extra data structure"?
Fields and options are not the same. What exactly should the plugin do?2) you have docs on how to create extra editor fields/options, but i'd like my plugin to do that on installation/removal.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
I am making a grouping plugin for the blog pages, static pages, and arbitrary links and wish to have this mix orderable within the group as well as ordering the groups themselves."extra data structure"
Thus i figured out storing it all in one json with plugin settings is not a good idea.
Though, i've seen some workarounds for altering db extension data, like creating a key for a subobject and processing it in post() method.
Am i reading this wrong? - "By default the custom fields appear in the options of the page."Fields and options are not the same.
---
It's the easiest of hard ways, once again. I might be wrong, of course, assuming that functionality i asked about is core func, and should have documentation, which is the best way. But i understand that while developing this CMS it could never come up as needed and planned func was always satisfied with existing conditions.
- Edi
- Site Admin
- Posts: 3121
- Joined: Sun Aug 09, 2015 5:01 pm
- Location: Zurich
- Has thanked: 54 times
- Been thanked: 78 times
- Contact:
What do you mean with "grouping"? Output based on taxonomy?
Can you perhaps show an example?
Where should the output be shown? In the plugin area (for example in the sidebar) or on a page?
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
There's no reference to point to, but i can design an example:
imagine, there are researches publishing articles. They do that both on site and on external platforms.
Let's organize the articles by field of study.
Though, now as you say it, it could also be purposed as navigation block in sidebar, if i register a plugin hook and inject it in theme.
Also, if one needs, adding blog pages into this grouping structure will be implemented as well. Probably in my case it is Categories replacement for a mashup of on-site and external resources.
imagine, there are researches publishing articles. They do that both on site and on external platforms.
Let's organize the articles by field of study.
- Maths
- bludit/article2
- bludit/article5
- somemagazine/uri1
- Chemistry
- bludit/article4
- somemagazine/uri3
- bludit/article3
- Cryophysics
- somemagazine/uri2
- bludit/article1
Though, now as you say it, it could also be purposed as navigation block in sidebar, if i register a plugin hook and inject it in theme.
Also, if one needs, adding blog pages into this grouping structure will be implemented as well. Probably in my case it is Categories replacement for a mashup of on-site and external resources.
- Edi
- Site Admin
- Posts: 3121
- Joined: Sun Aug 09, 2015 5:01 pm
- Location: Zurich
- Has thanked: 54 times
- Been thanked: 78 times
- Contact:
A static page shows one content (one page or one post). Otherwise you have to use the template home.php.
If you have a lot of content your system does not give you a good overview. But you could modify the template home.php and use categories or tags for the display.
The problem is the "mashup" with links because you have first to import the external content which is in any way a bit of tricky (if it is allowed at all).
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
So, i figured out the way to inject custom fields on plugin install programmatically, and feel like it should be added to docs:
and on uninstallation
Also, is "select" type in consideration for Bludit 4? I see "value"-"text" pairs being programmatically updated to keep them reflecting the latest settings for the plugin.
Code: Select all
public function install($position = 1) {
global $site;
global $L;
parent::install();
$fields=array(
"field-name"=>array(
"type"=>"string",
"label"=>$L->get('label'),
"tip"=>$L->get('tip')
)
);
$args['customFields']=json_encode(array_merge($site->customFields(),$fields));
$site->set($args);
return true;
}
Code: Select all
public function uninstall(): bool {
global $site;
parent::uninstall();
$pre=$site->customFields();
unset($pre['field-name']);
$args['customFields']=json_encode($pre);
$site->set($args);
return true;
}