Advanced plugin development documentation

Post Reply
inquirer
Jr. Bludit
Posts: 5
Joined: Thu May 12, 2022 3:22 am

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?
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 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
inquirer
Jr. Bludit
Posts: 5
Joined: Thu May 12, 2022 3:22 am

Yeah, it's the easiest of hard ways.
So, your response suggests there is no "Bludit" way of doing this, just be inventive :D
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

inquirer wrote: Fri May 13, 2022 5:11 am Yeah, it's the easiest of hard ways.
As you wrote: It's the easiest way.

And yes, learning could somethimes be hard. Also to learn coding.
1) db.php is for plugin settings, right? but i also need to have an extra data structure.
Bludit uses JSON. There are a lot of tutorials about it. For example there is a tutorial at

https://www.w3schools.com/js/js_json_intro.asp

What do you mean with "extra data structure"?
2) you have docs on how to create extra editor fields/options, but i'd like my plugin to do that on installation/removal.
Fields and options are not the same. What exactly should the plugin do?
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
inquirer
Jr. Bludit
Posts: 5
Joined: Thu May 12, 2022 3:22 am

"extra data structure"
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.
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.

Fields and options are not the same.
Am i reading this wrong? - "By default the custom fields appear in the options of the page."

---

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.
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

inquirer wrote: Mon May 16, 2022 3:47 am 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.
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
inquirer
Jr. Bludit
Posts: 5
Joined: Thu May 12, 2022 3:22 am

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.
  1. Maths
    1. bludit/article2
    2. bludit/article5
    3. somemagazine/uri1
  2. Chemistry
    1. bludit/article4
    2. somemagazine/uri3
    3. bludit/article3
  3. Cryophysics
    1. somemagazine/uri2
    2. bludit/article1
Output intended to be printed on a static page, with specific template tied in to it.
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.
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

inquirer wrote: Wed May 18, 2022 3:49 am Output intended to be printed on a static page, with specific template tied in to it.
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
inquirer
Jr. Bludit
Posts: 5
Joined: Thu May 12, 2022 3:22 am

So, i figured out the way to inject custom fields on plugin install programmatically, and feel like it should be added to docs:

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;
}
and on uninstallation

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;
}
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.
Post Reply