Re: [dotcms] Customizing Forms, Database Access, Plugins, Multilingual Features, and Email Shooting in dotCMS Cloud Instance

69 views
Skip to first unread message

Mark Pitely

unread,
Dec 2, 2024, 11:08:54 AM12/2/24
to dot...@googlegroups.com
There's a lot to tackle here. I will answer what I can. You will probably find that asking a single question will get you much better results. 

1. If you use the 'Add Content' option to add a Form Builder form to a page, you can use whatever CSS you like to manipulate it. However, because form elements are usually set by the browser, you are limited in what you can do. With a Custom form you can do the extra effort to hide the HTML buttons and make js actions to activate them giving you 100% control of appearance. 

2/3. You can create an API key that has permission to submit a form and then use the API via javascript to do so. Now, that API username/password will be visible, but the form is already open to submit. Obviously that key should only be used to submit that form. I appended working code at the end to show how. 

4. No; they don't want you to have direct access to the SQL. The API and the queries you can build should give you everything you need. You can do it with a plugin, but again, that's unwise. When there are version changes and upgrades, your code will fail. You want the database level abstract

5. You can definitely create custom plugins, but I am not sure why. There's tons of documentation, but I would strongly recommend against it. It also has a tendency to fail over time and requires developer time to keep operational, and just about anything you'd like to do can be done using the tools available. If I absolutely need something to talk to a different machine (your business SQL, etc) I just use Node or PHP on that internal machine and use $Import.read() to fetch the content. 

6. It is cumbersome and exists for when you really need a separation. There is built-in google translate functionality if you want easy: https://www2.dotcms.com/docs/latest/apps-integrations

7. The Workflow system can be set up to send emails on submit. 


Notes:

JS to fetch an authorized API token:

    let url = '/api/v1/authentication/api-token';  
fetch(url, {
  method: 'POST',
  headers: {
    'Accept': 'application/json, text/plain, */*',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({"user":"redacted", "password":"redactedaswell", "expirationDays": 10 })
}).then(res => res.json())
  .then(res => gettoken(res));   

function gettoken(res){
 console.log(res);
 console.log(res.entity);
 console.log(res.entity.token);
document.token=res.entity.token;    
   
}

Function to PUBLISH a piece of content using that token:

let url = '/api/v1/workflow/actions/default/fire/PUBLISH';      
fetch(url, {
  method: 'POST',
  headers: {
    'Accept': 'application/json, text/plain, */*',
    'Content-Type': 'application/json',
    "Authorization": "Bearer "+document.token
  },
  body: jsonout
}).then(res => res.json())
  .then(res => finish(res));


Good luck!
Mark Pitely
Albright College



On Mon, Dec 2, 2024 at 7:40 AM 'Jenish Dadhania' via dotCMS User Group <dot...@googlegroups.com> wrote:

I am currently using a dotCMS cloud instance and facing challenges with the following functionalities. I would appreciate guidance on these points:

  1. Form Customization:

    • If I create a form using a form content type, is there a way to customize its design (CSS) and functionality (e.g., buttons)?
    • Where is the VTL file for such forms located in dotCMS, and can we directly edit it to apply customizations?
  2. Custom Form Integration via VTL:

    • If I create a form directly in a VTL file using HTML, how can I configure it to store submitted data in the dotCMS backend without requiring the user to log in as an admin?
  3. Issue with API /api/v1/workflow/actions/default/fire/NEW:

    • I created a form in a VTL file and used the dotCMS API /api/v1/workflow/actions/default/fire/NEW to submit the form data.
    • The data is successfully stored in the content type when I am logged in as an admin in the dotCMS UI. However, when not logged in, the API throws an error. I noticed the same issue occurs on the dotCMS demo site. How can I resolve this?
  4. Database Access in Cloud Instance:

    • I want to directly store form data into the PostgreSQL database. Is it possible to access the database in a dotCMS cloud instance? Does dotCMS provide database access for cloud users?
  5. Creating a Custom Plugin:

    • How can I create a custom plugin from scratch in dotCMS?
    • Is there a specific file structure or format for developing plugins?
    • Once created, how can I use the plugin’s functionalities in a VTL file?
  6. Multilingual Implementation:

    • Implementing multilingual features seems cumbersome, as it involves creating separate content, pages, and files for each language.
    • Does dotCMS provide a built-in tool to streamline this process, such as automated translations or centralized management, to reduce duplication and manual effort?
  7. Email Shooting on Form Submission:

    • I want to implement email notifications for users who submit the form.
    • Is this possible in dotCMS? If yes, how can I configure email shooting so that users receive an email confirmation upon form submission?
    • Can this be done using VTL files, workflows, or plugins? Please provide examples or documentation references if available.

--
http://www.dotcms.com - Open Source headless/hybrid CMS
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/dotcms/ce813f80-fdac-4f47-9a75-46c152acc33dn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages