CMS Development

stephenpratley_
Member | Partner
Member | Partner

Write to HubDB from Module?

We've created a HubDB table and a module to show it on a page.


We want to show different queries from the table on different pages so this seems the way to go, rather than holding the data with a single module.

My question is, is there any way to write to the table from a module?
I'm just trying to avoid the user having to leave the usual CMS editor to create entries.

0 Upvotes
7 Replies 7
magmar
Contributor | Platinum Partner
Contributor | Platinum Partner

Write to HubDB from Module?

Hi, we have a similar request for almost every CMS project: Tag/categorize pages and add tag/category filters to the frontend, so that a user may select a tag/category and gets a list view of pages that match his choice. The only way that I know how to achieve this is to create the tags in HubDB and create an additional table that contains the page URL and the associated tags. We'd then create filter and list views for the frontend by queying the HubDB via Javascript/node.js.

But for the editor, this means, he/she has to edit this HubDB for every page that he/she wants to tag. It would be way easier if the user could tag the pages (like in the blog) from within the page editor. As far as I know, we could read the tags from HubDB within the module, but I don't know a way to write the selected tags/categories back into a HubDB which associates page and selected tags.  

We'd be using Enteprise CMS in most cases - so does anyone know if I could write from a module into HubDB? I don't think that serverless components would run from the backend.

Thanks in advance!

0 Upvotes
piersg
Key Advisor

Write to HubDB from Module?

@magmar You could:

  1. create a custom module which only has a repeater text field (not rich text) for tags and doesn't display them anywhere but can be edited on each page, then
  2. use the Pages API (GET from /content/api/v2/pagesto get module data via "widgets" in the returned JSON and finally
  3. use the HubDB API to add a new row (POST to /cms/v3/hubdb/tables/{tableIdOrName}/rows) to a table for each page with the tag data

A bit long winded maybe and you would need serverless functions to do it.

magmar
Contributor | Platinum Partner
Contributor | Platinum Partner

Write to HubDB from Module?

Thanks so much for your quick help.👍 I'll discuss this with our developer and let you know if we had success doing it this way! 

stephenpratley_
Member | Partner
Member | Partner

Write to HubDB from Module?

https://community.hubspot.com/t5/HubSpot-Ideas/Manage-hubdb-from-modules/idi-p/438183#M83086


I'm not sure what you can see in the back end of each portal, but we have a page here that is managed with a custom moodule:
https://www.emergingcomms.com/training-events

That module has all the functionaliyty we need, but the data is tied to the module and can't be re-used.

If I wanted to have a "lastest event" signpost on the homepage, I couldn't.

From an editor perspective, it should be exactly the same, but the data should be stored in a HubDB table to allow it to be re-used elsewhere.

Using the HuBDB tables shoudl also make it a lot easier to reskin sites at a later date.
Currently too much is stuck in custom modules so just moving from one theme to another feel like a rebuild on some occasions.

stephenpratley_
Member | Partner
Member | Partner

Write to HubDB from Module?

The issue isn't the ectual editing.
It's someone going into the CMS on the page where they want to add another entry and thinking "where do I go now?"
A content manager shouldn't have to leave the editor.

"Files and templates" isn't an intuitive label for it either.

Plus manging the extra permissions.

I'll see if we can just add a lebel of some sort in the module we built to display the data, but that sounds like a hack.

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

Write to HubDB from Module?

@piersg is correct here.  I appreciate your concern with that editing experience.  I wonder what it would look like in your ideal scenario. If you are feeling up to it, could you add how you believe it should look to the ideas board and link back here?  At the minimum, I can get some eye on it.  I know the product teams are always looking for these types of ideas.

piersg
Key Advisor

Write to HubDB from Module?

@stephenpratley_ Basically, no. The only other way (that I know of, admittedly) to update a HubDB is to use the API but using that from within the editor doesn't seem possible, at least not in a secure, well managed way. It's not too onerous to simply have the HubDB open in another tab next to the page being edited, no?

 

Unless @dennisedson knows something I don't (which is usually true).