Spectrum Module

alt=
Marla
@sweet
one month ago
53 posts
I understand now... thank you, Michael!!!
updated by @sweet: 12/22/24 02:32:13AM
michael
@michael
one month ago
7,772 posts
I don't know what the spectrum module is sorry. Is it from a different developer?

--edit--
Yeah its one of @ultrajam's
https://www.jamroom.net/ultrajam/networkmarket/148/spectrum-color-picker

if its allows a custom color picker to be saved to the database via CUSTOM FORM EDITOR then that will be a 2 step process.

Use it on the form to record the value. That value will then be there with the rest of the form information.

So if you added it to say a blog post as 'blog_background_color' then in the templates when you're using laying out the other blog info you will also have the value of what that was set to.

Maybe use it in combination with CSS or 'style=" to customize the look of whatever you're trying to build.
updated by @michael: 12/21/24 11:57:51PM
michael
@michael
one month ago
7,772 posts
Good on you for trying to understand, I know it can be complicated.

Any module that you can use the CUSTOM FORM fields on is using what we call a 'datastore'. Its a KEY -> VALUE database structure:

https://www.jamroom.net/the-jamroom-network/documentation/module-developer-guide/1023/datastores

It gives modules flexibility to interact with each other.

Basic Concept:
* info gets INTO the database via forms.
* info comes out of the database via templates. (usually via {jrCore_list} )

https://www.jamroom.net/the-jamroom-network/documentation/module-developer-guide/89/jrcore-list

https://www.jamroom.net/the-jamroom-network/documentation/modules/2885/simple-custom-forms


There's a ton of over-ride points to pretty much everything which allows for a lot of flexibility but it does create a lot of complexity unfortunately.

So: If you add something to some modules form like spectrum, when you add it you'll have to choose a name to add it on that starts with the 'prefix' of the module, so for the jrBlog module its 'blog_..... for jrAudio its 'audio_....... etc.

So when you open the CREATE or the MODIFY form and save it all the info gets stored along with that thing's '_item_id'.

Now its just info in the database, but if you go to a location where you can see the other info related to that item id you can customize the templates to do whatever you want.

So you need to decide what you want the color selected by spectrum to do. Once you know what you want it to do then you adjust the templates so it does that.
alt=
Marla
@sweet
one month ago
53 posts
That's pretty awesome that JR has this form setup! I'm learning... this is exciting to see my ideas come to life. I posted another questions in the developers area, but maybe you can answer here since we're discussing the form?

Is it possible to add a custom field type inside the form designer module? I have a drag and drop function that I need put into a form. I'm unable to find the right field type to make things work.

Thanks!

Marla
michael
@michael
one month ago
7,772 posts
It certainly is possible. A module made by The Jamroom Network is no different than a module Made By You. Even the core of jamroom is a moudle.

So modules are a core concept in jamroom.

You can create either a dedicated module that does something specific or a general module where you chuck all your changes for your specific site.

From there..... actually...

What might be more useful to you is: there already is jrCore_page_custom().

Eg:
                        $html = '<div id="pl-addon-options"><!-- addons load here --></div>';
                        jrCore_page_custom($html);

It will depend a lot on whether you're wanting to use the Form Designer to build the form or if you're building the form in php. The code above allows you to pass anything you want in and make it part of the form.

You'd generally use that method when its your modules form. If you're injecting into another modules form then either the Form Designer method or the Events and Listeners system are other ways to accomplish changing whats in a form.

For the form designer method you'd make a custom form field type that could be added via the Form Designer. To do that you'd use your module to create a form field type.

Lets look at 'daterange' since its very specific and is easily searched on in your IDE and is pretty simple.

First the jrCore module adds this line to its _init() function to register the form type:
    jrCore_register_module_feature('jrCore', 'form_field', 'jrCore', 'daterange');
Then these 3 functions are defined (you could do this in include.php, but the core is a big module so for tidyness it has an included form.php file where all form stuff is)
function jrCore_form_field_daterange_display($_field, $_att = null)....
jrCore_form_field_daterange_form_designer_options()
function jrCore_form_field_daterange_attributes()
function jrCore_form_field_daterange_assembly($_field, $_post)

If your custom field type was really simple you might not need _attributes() and _assembly().

Take a look at those functions, see if that's enough to get you going.
alt=
Marla
@sweet
one month ago
53 posts
Thank you for this information.

Where do I find this: $html = '';
jrCore_page_custom($html);
Thanks!

Marla
michael
@michael
4 weeks ago
7,772 posts
That would be if you are creating a form inside a module via php.
alt=
Marla
@sweet
4 weeks ago
53 posts
Go it! Thank you.
michael
@michael
4 weeks ago
7,772 posts
The best place to see what works is inside the modules themselves. They for the most part all share the same structure.

include.php // where internal functions go
index.php // where the views go. (functions starting with view_.......() and correspond to a URL pattern.

eg: view_jrProfile_avacardo() corresponds to the URL:
yoursite.com/profile/avacardo

Inside that page you can put whatever you want.

So for you you might make a simple module that just has those 2 files and call it maStuff or xxStuff then you could use yoursite.com/stuff/avacardo for whatever you wanted.

There's a few more conventions but that's a basic one the exists. Sometimes it can be hard to see the conventions on the larger modules because there's also so much other stuff going on.

Tags