Skip to content

Commit

Permalink
Revert "[FEATURE] Create a minimal site package (#189)"
Browse files Browse the repository at this point in the history
This reverts commit 6a737dd
Resolves: #283
  • Loading branch information
linawolf committed Nov 25, 2024
1 parent 7c11432 commit 9bc5730
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 138 deletions.
8 changes: 5 additions & 3 deletions Documentation/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ A working copy of the site package extension can be retrieved from the
.. card-footer:: :ref:`See the prerequisites <t3sitepackage:prerequisites>`
:button-style: btn btn-secondary stretched-link

.. card:: :ref:`Minimal site package <t3sitepackage:minimal-design>`
.. card:: :ref:`Minimal example <t3sitepackage:minimal-design>`

Create a minimal site package that outputs "Hello World".
We explain how you can easily show some text in the frontend. The
example explains how to use TypoScript to output text in the
frontend.

.. card-footer:: :ref:`Create a minimal site package <t3sitepackage:minimal-design>`
.. card-footer:: :ref:`See the minimal example <t3sitepackage:minimal-design>`
:button-style: btn btn-secondary stretched-link

.. card:: :ref:`Design Template <t3sitepackage:dt-external-resources>`
Expand Down
188 changes: 69 additions & 119 deletions Documentation/MinimalExample/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,148 +3,98 @@

.. _minimal-design:

====================
Minimal site package
====================
===============
Minimal example
===============

A site package is a custom TYPO3 extension which contains configuration,
templates, assets, etc that are used for the site it belongs to.
We want to create a site package that outputs a single web page with
minimal effort. This site package can be used to simply test system output or as
an example of the fewest possible steps to create a working site package.

So first we create a minimal extension.

.. _minimal-extension:

Create a minimal TYPO3 extension using b13/make
===============================================

:composer:`b13/make` is a convenient TYPO3 extension which you can use during
development to create a new TYPO3 extension quickly or add functionality to an
existing one.

Use Composer to install it for development only:

.. code-block:: bash
ddev composer req b13/make --dev
Execute the command `ddev typo3 make:extension` and answer the prompt

.. code-block:: bash
ddev typo3 make:extension
Enter the composer package name (e.g. "vendor/awesome"):
> t3docs/site-package
Enter the extension key [site_package]:
>
Enter the PSR-4 namespace [T3docs/SitePackage]:
>
Choose supported TYPO3 versions (comma separate for multiple) [TYPO3 v12 LTS]:
[10] TYPO3 v10 LTS
[11] TYPO3 v11 LTS
[12] TYPO3 v12 LTS
[13] TYPO3 v13
> 12
Enter a description of the extension:
> My site package
Where should the extension be created? [src/extensions/]:
> packages
May we add a basic service configuration for you? (yes/no) [yes]:
> no
May we create a ext_emconf.php for you? (yes/no) [no]:
>
[OK] Successfully created the extension my_site_package (myvendor/my-site-package).
This script creates a new folder called `packages` with a subfolder,
`my-site-package`. It mainly contains only a file called `composer.json`.

You could of course also create this file manually. Step
:ref:`extension-configuration` will explain the content of the :file:`composer.json`.
For the time being just remember the Composer name you have chosen
(`t3docs/site-package`) and the extension name (`site_package`).

In order to see a change in the TYPO3 backend or frontend your site package needs
to be :ref:`installed <extension-installation>`.

After you have created your site package extension you can uninstall :composer:`b13/make`:

.. code-block:: bash
ddev composer remove b13/make --dev
.. _minimal-extension-typoscript:
To start, in the TYPO3 backend, create a standard page named
:guilabel:`Minimal example` just under (inside) the page tree TYPO3 logo
container. Create a new TypoScript template record on this page.
Give the TypoScript template a title, and make it a root level template,
but do not include any static templates.

The TypoScript-only version
===========================

Create a file called :file:`setup.typoscript` containing basic TypoScript configuration
in the folder :path:`Configuration/Setup`:
In the TypoScript template Setup field, add the following three lines:

.. literalinclude:: _minimal.typoscript
:caption: packages/site-package/Configuration/TypoScript/Setup/setup.typoscript
.. code-block:: typoscript
:caption: TypoScript Setup
Clear all caches and preview the web page.
page = PAGE
page.1 = TEXT
page.1.value = Hello, world.
You can learn more about the TypoScript syntax used here in chapter
:ref:`A minimal page created by pure TypoScript <t3start:typoscript>`
of the "Getting Started Tutorial".
View the web page.

.. _minimal-extension-fluid:
This TypoScript-only design has the least instructions required to output a
web page from TYPO3. This TypoScript template is self contained and
no other files or database records needed. Changing this content
only requires the appropriate access needed to make changes to TypoScript
templates.

The TYPO3 Fluid version
=======================

Replace file :file:`setup.typoscript` of example
:file:`minimal-extension-typoscript` with the following lines:
Empty the :guilabel:`Minimal design` page TypoScript template Setup field,
then add the following lines:

.. literalinclude:: _pageview.typoscript
:caption: ackages/site-package/Configuration/TypoScript/Setup/setup.typoscript
:linenos:
.. code-block:: typoscript
:caption: TypoScript Setup
If you preview your page now you would get an error output like:
page = PAGE
page.1 = FLUIDTEMPLATE
page.1.file = EXT:site_package/Resources/Private/Templates/Minimal.html
.. code-block:: html
Create a file named :file:`Minimal.html` in a
:file:`typo3conf/ext/site_package/Resources/Private/Templates` folder.

Oops, an error occurred! Request: bddd8a816bda3
The site package extension has to be :ref:`installed <extension-installation>`
and requires a :ref:`minimal composer configuration <extension-configuration>` (if composer is used)
for this to work

.. todo: Add information about dealing with errors such as these and link from here.
This is because the template has not been found.
.. code-block:: html
:caption: EXT:site_package/Resources/Private/Templates/Minimal.html

By searching for the hash `bddd8a816bda3` in the log file you will find such an entry:
Hello, world.

.. code-block:: plaintext
:caption: var/log/typo3_ece44d5005.log
:emphasize-lines: 7
Now view the web page.

Mon, 07 Oct 2024 04:09:44 +0000 [ALERT] request="bddd8a816bda3"
component="TYPO3.CMS.Frontend.ContentObject.Exception.ProductionExceptionHandler":
Oops, an error occurred! Request: bddd8a816bda3- InvalidTemplateResourceException:
Tried resolving a template file for controller action "Default->Pages/Default"
in format ".html", but none of the paths contained the expected template file
(Default/Pages/Default.html).
The following paths were checked: /var/www/html/vendor/t3docs/site-package/Resources/Private/Templates/
Here we are putting the page content into a separate HTML file, allowing for
separate access control and for an editing workflow that does not need much
TypoScript. The TYPO3 renderer still requires a TypoScript template on the
:guilabel:`Minimal design` page to know which file to process.

This error message also tells you the path where TYPO3 expects to find the file. If no path
is listed here, the path defined in line 6 of the TypoScript above is incorrect,
for example if you mistyped the extension name or part of the path.
Resulting web page
==================

Create a file named :file:`Default.html` in folder
:path:`packages/site-package/Resources/Private/Pages`.
Here is the resulting web page HTML source for both the TypoScript-only and
the Fluid based implementations. Notice how TYPO3 has added default markup
around the single line of content:

.. code-block:: html
:caption: packages/site-package/Resources/Private/Pages/Default.html

Hello Fluid World!

Clear all caches and preview the web page.

Learn more about using Fluid Templates in chapter :ref:`fluid-templates`.
:caption: Example frontend output

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!--
This website is powered by TYPO3 - inspiring people to share!
TYPO3 is a free open source Content Management Framework initially
created by Kasper Skaarhoj and licensed under GNU/GPL.
TYPO3 is copyright 1998-2018 of Kasper Skaarhoj. Extensions are
copyright of their respective owners.
Information and contribution at https://typo3.org/
-->
<title>Minimal design</title>
<meta name="generator" content="TYPO3 CMS">
</head>
<body>
Hello, world.
</body>
</html>
7 changes: 0 additions & 7 deletions Documentation/MinimalExample/_minimal.typoscript

This file was deleted.

9 changes: 0 additions & 9 deletions Documentation/MinimalExample/_pageview.typoscript

This file was deleted.

0 comments on commit 9bc5730

Please sign in to comment.