Tutorial: building a blog with BWEB

This tutorial walks you through building a small blog with BWEB V21: a back-office to write articles, and a public site that shows the published ones. You build the application as you read, in your own 4D project.

The goal is not to cover all of BWEB, but to take you once through each basic move: installing the component, composing a page in the dev panel, showing a table in a listbox, editing a record in a form and saving it with a 4D function.

What you will build

The back-office

  • an Articles page: the list of articles, sortable, with a link to create a new one;
  • an Article editing page: a form (title, summary, rich-text content, publication), a save button and a delete button.

The public blog

  • the home page: the published articles, newest first;
  • an Article page: one full article, found by its readable address (its "slug").

Prerequisites

Technical

  • 4D 21, in local (single-user) mode: BWEB is installed into a project opened locally and not compiled.
  • Internet access on first launch, so that 4D can download the component and its dependencies.
  • Node.js: if it is missing, the installation wizard offers to install it.
  • A recent browser, in a wide window: the dev panel is hidden on small screens.

Knowledge

  • 4D basics: tables, fields, methods, dataclass classes (ORDA).
  • Some web notions (URL, request) help, but are not required.
  • No need to know HTML, JavaScript or Tailwind: pages are composed in the dev panel.

How you work with BWEB

A BWEB page is a tree of blocks (container, input field, button, listbox…) stored in the database. You place and configure them in the dev panel, the editor that opens in the browser when you are logged in with the right to edit the page. Styling is set in the dev panel's layout tab, without writing CSS.

Business code stays in 4D. When the user clicks a button, BWEB calls a function of your table's dataclass, which answers with a WebFormController: a message to show, a redirect, a block to reload.

The steps

  1. Part 1: setting up the project — the 4D project, installing BWEB, the POST table and its class.
  2. Part 2: the back-office — the article list, the editing form, and the save and delete functions.
  3. Part 3: the public blog — the home page, the article page, and protecting the back-office.

The tutorial resources gather the useful links.

BWEB screens change from one version to the next. This tutorial quotes the dev panel and administration labels as they are in BSPK Tools 21.6; if a label differs on your side, the technical names given in brackets (vt_FieldName, vt_TableName…) remain the reference.

See also