Planning out this module... (?)

alt=
@gcuezy
10 years ago
23 posts
I'm creating a custom module for a random site idea I have (partially to get back into jamroom so we can relaunch our old site that's in limbo).

The plan is to have items that can be created (think page/post/etc but way simpler) and also to have categories that they can be in.

These categories and items need to live in separate data-stores and be related. The item may be in multiple categories and categories, although modifiable from the item form, should be able to be modified separately. The items, when they're being created, need to run a php script from the form via ajax before the form is submitted. Does this php file live on it's own in the module folder or is it a part of the index.php?

Can this realistically be one module with different views? How would I populate the "categories" multi select of the items using the categories data store... smarty templates and hidden fields?

I am a text-book overthinker and just finished the udemy Jamroom course so feel free to give what little advice you can and tell me to just start trying. I'm still a little fuzzy on the optimal structure of these things.
updated by @gcuezy: 05/04/14 11:22:28PM
brian
@brian
10 years ago
10,148 posts
One issue you'll hit right away is that each module is limited to 1 datastore. So instead of storing each category in it's own DS, just create a "category" key that is part of any search.

Check out the jrBlog module for a simple example of how that's used.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
alt=
@gcuezy
10 years ago
23 posts
Thanks, the problem with that would be that I need the option to have multiple categories per 1 item.

I'd prefer they're also editable on their own too.

So should this be two modules that interact based on events or something?
paul
@paul
10 years ago
4,326 posts
Could the 'module_categories' DS field be a comma separated list - songs,videos,images
You could then still search for specific categories with the IN operator


--
Paul Asher - JR Developer and System Import Specialist
alt=
@gcuezy
10 years ago
23 posts
Would I be able to make those persist across the different items still?
Not sure I understand exactly how the current select-or-add works.

These categories work more like persistent tags. Here's an example of what the form for adding items looks like in my mind -

Item URL: ______
Item Name: ________
Item Category(s): _[News],_[Inspiration],_[Favorites]_
(+ Add new category)

Where name/url are text fields and category is a multi-select.

The current setup where you select one or add a new one is nice, but I need the option for them to be selected together.
paul
@paul
10 years ago
4,326 posts
Not sure, but I think you might be able to create a 'multi' select_and_text field already.
If not, it could easily be emulated with a normal multi-select field and an associated text field, then build the comma separated list in the form save function.
In fact, that might be more flexible as users could then select multiple options and a new one all in one go.


--
Paul Asher - JR Developer and System Import Specialist
alt=
@gcuezy
10 years ago
23 posts
Appreciate all the help so far, I might just move ahead with that in mind for now.

Part of what I left out is that I'd like to have parent categories. Still having trouble wrapping my mind around how this might work, practically...

Category 1
|- Sub Cat a
|- Sub Cat b
Category 2
|- Sub Cat c
|- Sub Cat d

Where Post 1 might be a part of Cat 1, Sub Cat b, and Sub Cat d.
paul
@paul
10 years ago
4,326 posts
The jrChainedSelect module might help here, maybe not directly as its designed for use with the Form Designer, but keep it in mind.
Alternatively, what you want is still doable when developing a module. When building a form field you can specify a javascript call in the parent select field that will populate a child select.


--
Paul Asher - JR Developer and System Import Specialist

Tags