The Collapsible field is presentational-only and only affects the Admin panel. By using it, you can place fields within a nice layout component that can be collapsed / expanded. Admin Config Example collections/ExampleCollection.ts import { CollectionConfig } from ‘payload/types’ export const ExampleCollection: CollectionConfig = { slug: ‘example-collection’, fields: [ { … Continue reading Collapsible Field in payload default
Tag: payload
Authentication Operations in Payload
Login using REST API const res = await fetch(‘http://localhost:3000/api/[collection-slug]/login’, { 2 method: ‘POST’, 3 headers: { 4 ‘Content-Type’: ‘application/json’, 5 }, 6 body: JSON.stringify({ 7 email: ‘dev@payloadcms.com’, 8 password: ‘this-is-not-our-password…or-is-it?’, 9 }), 10}) 11 12const json = await res.json() 13 14// JSON will be equal to the following: 15/* 16{ 17 user: { 18 email:… Continue reading Authentication Operations in Payload
Hosting of the Payload web application
in order to run the payload application on the server we need to configure the startup file with following code This code can be used for normal hosting platforms // Ensure that the ‘payload.config.js’ is in the correct directory const payloadConfig = require(‘./dist/payload/payload.config.js’); // Start the server const app = require(‘./dist/server.js’); // Check if server.js… Continue reading Hosting of the Payload web application
Plesk Panel Permissions Unable to access Plesk: /usr/local/psa/admin/logs/panel.log cannot be opened with mode “a”
Unable to access Plesk: /usr/local/psa/admin/logs/panel.log cannot be opened with mode “a” Cause Wrong ownerships for the /var/log/plesk/ directory or /var/log/plesk/panel.log file. Resolution Log into the the server via SSH. Execute the commands below one by one to set proper ownerships for /var/log/plesk/ directory: # chmod 0750/var/log/plesk/ # chown psaadm:root /var/log/plesk/ Run the following commands to set correct ownerships for the /var/log/plesk/panel.log file: # chmod 0640 /var/log/plesk/panel.log # chown… Continue reading Plesk Panel Permissions Unable to access Plesk: /usr/local/psa/admin/logs/panel.log cannot be opened with mode “a”
Typescript in payload CMS
Payload supports TypeScript natively, and not only that, the entirety of the CMS is built with TypeScript. To get started developing with Payload and TypeScript, you can use one of Payload’s built-in boilerplates in one line via create-payload-app npx create-payload-app@latest Payload exports a number of types that you may find useful while writing your own plugins,… Continue reading Typescript in payload CMS
How to create a json payload for a POST request?
Creating a JSON payload for a POST request involves constructing a JSON object and then converting it to a string format, which can be sent in the body of the POST request. Step 1: Constructing the JSON Object { “name”: “John Doe”, “email”: “john.doe@example.com”, “age”: 30, “address”: { “street”: “123 Main St”, “city”: “Anytown”, “state”:… Continue reading How to create a json payload for a POST request?
What is the difference between asynchronous and synchronous hooks in Payload, and when should each type be used?
In Payload, hooks can be either asynchronous or synchronous functions. Asynchronous Hooks: These are used when the hook needs to perform actions that involve asynchronous operations, such as fetching data from a third-party service. Asynchronous hooks ensure that these operations complete before continuing with the document’s lifecycle. They run in series, meaning if multiple async… Continue reading What is the difference between asynchronous and synchronous hooks in Payload, and when should each type be used?
What does the admin access control function do, and what arguments does it receive?
The admin access control function determines whether a user can access the Payload Admin panel for a specific Collection. This function is crucial for controlling administrative access within the Payload system. It receives the following argument: req: The Express request object containing the currently authenticated user. The function should return a boolean value indicating whether… Continue reading What does the admin access control function do, and what arguments does it receive?
What is the purpose of the create access control function, and what arguments does it receive?
The create access control function determines whether a user is allowed to perform the create operation in a Collection. It receives the following arguments: req: The Express request object containing the currently authenticated user. data: The data that is being passed to create the document. The function should return a boolean value indicating whether the… Continue reading What is the purpose of the create access control function, and what arguments does it receive?
Creating Custom Plugins for Payload CMS
Extending the functionality of Payload CMS through custom plugins can enhance its capabilities, allowing for tailored solutions that fit specific project needs. Topics to Cover Introduction to Payload CMS Plugins: Overview of plugins and their importance Examples of common use cases for custom plugins Setting Up the Development Environment: Prerequisites and tools needed Setting up… Continue reading Creating Custom Plugins for Payload CMS