Skip to content

Commit 6ca114e

Browse files
authored
[TASK] Site package tutorial depends on Site Package Builder (#306)
Explain how to read the generated files instead of having readers create them themselves. Releases: main, 13.4
1 parent 61bed3a commit 6ca114e

File tree

4 files changed

+66
-211
lines changed

4 files changed

+66
-211
lines changed

Documentation/ContentMapping/Index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ You can debug this variable in the main section of your template using the
153153
The debug output after clearing all caches and previewing the page should look
154154
like this:
155155

156-
.. figure:: _images/contents_debug.png
156+
.. figure:: /Images/ContentMapping/contents_debug.png
157157
:alt: Screenshot of the debug output of {content}
158158

159159
The debug output should contain sections "stage" and "main"

Documentation/MinimalExample/Index.rst

Lines changed: 65 additions & 210 deletions
Original file line numberDiff line numberDiff line change
@@ -1,162 +1,40 @@
1-
.. include:: /Includes.rst.txt
2-
.. highlight:: typoscript
1+
.. include:: /Includes.rst.txt
2+
.. highlight:: typoscript
33

4-
.. _minimal-design:
4+
.. _minimal-design:
55

6-
====================
7-
Minimal site package
8-
====================
6+
=======================
7+
Generate a site package
8+
=======================
99

1010
A site package is a custom TYPO3 extension which contains configuration,
1111
templates, assets, etc that are used for the site it belongs to.
1212

13-
So first we create a minimal extension.
13+
So first we generate a minimal extension.
1414

1515
.. contents::
1616

1717
.. _minimal-extension:
18-
19-
Create a minimal TYPO3 extension manually
20-
=========================================
21-
22-
Create the following file in the folder `packages` in your TYPO3 installation:
23-
24-
.. code-block:: json
25-
:caption: packages/my-site-package/composer.json
26-
:linenos:
27-
28-
{
29-
"name": "myvendor/my-site-package",
30-
"type": "typo3-cms-extension",
31-
"description": "My site package",
32-
"require": {
33-
"typo3/cms-core": "^13.4"
34-
},
35-
"autoload": {
36-
"psr-4": {
37-
"Myvendor\\MySitePackage\\": "Classes/"
38-
}
39-
},
40-
"extra": {
41-
"typo3/cms": {
42-
"extension-key": "my_site_package"
43-
}
44-
}
45-
}
46-
47-
In order to see any changes in the TYPO3 backend or frontend your site package
48-
needs to be :ref:`installed <extension-installation>`:
49-
50-
.. code-block:: bash
51-
52-
ddev composer req myvendor/my-site-package
53-
54-
.. note::
55-
The Composer name in this example is `myvendor/my-site-package`. Use this
56-
name for all Composer commands like `ddev composer req myvendor/my-site-package`.
57-
58-
`my_site_package` is the extension name. For historical reasons all dashes need
59-
to be converted to underscores and the vendor name removed. This name is used
60-
to reference files, for example `packages/my_site_package/Resources/Public/Css/my.css`.
61-
62-
63-
.. _minimal-b13-make-extension:
64-
65-
Create a minimal TYPO3 extension using b13/make
66-
===============================================
67-
68-
:composer:`b13/make` is a convenient TYPO3 extension which you can use during
69-
development to create a new TYPO3 extension quickly or add functionality to an
70-
existing one.
71-
72-
Use Composer to install it for development only:
73-
74-
.. code-block:: bash
75-
76-
ddev composer req b13/make --dev
77-
78-
Execute the command `ddev typo3 make:extension` and answer the prompt
79-
80-
.. code-block:: bash
81-
82-
ddev typo3 make:extension
83-
84-
Enter the composer package name (e.g. "vendor/awesome"):
85-
> myvendor/my-site-package
86-
87-
Enter the extension key [my_site_package]:
88-
>
89-
90-
Enter the PSR-4 namespace [Myvendor/MySitePackage]:
91-
>
92-
93-
Choose supported TYPO3 versions (comma separate for multiple) [TYPO3 v12 LTS]:
94-
[10.4] TYPO3 v10 LTS
95-
[11.5] TYPO3 v11 LTS
96-
[12.4] TYPO3 v12 LTS
97-
[13.4] TYPO3 v13 LTS
98-
> 13.4
99-
100-
Enter a description of the extension:
101-
> My site package
102-
103-
Where should the extension be created? [src/extensions/]:
104-
> packages
105-
106-
May we add a basic service configuration for you? (yes/no) [yes]:
107-
> no
108-
109-
May we create a ext_emconf.php for you? (yes/no) [no]:
110-
>
111-
112-
[OK] Successfully created the extension my_site_package (myvendor/my-site-package).
113-
114-
This script creates a new folder called `packages` with a subfolder,
115-
`my-site-package`. It mainly contains only a file called `composer.json`.
116-
117-
You could of course also create this file manually. Step
118-
:ref:`extension-configuration-composer` will explain the content of the :file:`composer.json`.
119-
For the time being just remember the Composer name you have chosen
120-
(`myvendor/my-site-package`) and the extension name (`my_site_package`).
121-
122-
In order to see any changes in the TYPO3 backend or frontend your site package
123-
needs to be :ref:`installed <extension-installation>`:
124-
125-
.. code-block:: bash
126-
127-
ddev composer req myvendor/my-site-package
128-
129-
After you have created your site package extension you can uninstall :composer:`b13/make`:
130-
131-
.. code-block:: bash
132-
133-
ddev composer remove b13/make --dev
134-
13518
.. _minimal-site-package-builder:
13619

137-
Create a minimal TYPO3 extension using the Site Package Builder
138-
===============================================================
139-
140-
To quickly build a site package you can also use the
141-
`Sitepackage Builder <https://get.typo3.org/sitepackage>`__.
20+
Generate and download a site package
21+
====================================
14222

143-
To follow this tutorial you can fill in the form like that:
23+
You can download a site package by using the official Site Package Builder at
24+
https://get.typo3.org/sitepackage or by using curl.
14425

145-
.. figure:: SitePackageGeneratorForm.png
146-
:alt: Form fields to generate the tutorial package site
147-
:caption: Form fields to generate the tutorial package site
26+
You have the choice of three site packages types:
14827

149-
The summary of your data is then displayed.
28+
* Bootstrap Package: This site package comes with a ready to use theme
29+
* Fluid Styled Content: A minimal site package where you can build your own
30+
custom theme.
31+
* Site Package Tutorial: Contains all files that are used as examples in
32+
this tutorial.
15033

151-
.. figure:: SitePackageGeneratorSummary.png
152-
:alt: Summary of information provided
153-
:caption: Summary of information provided
34+
To follow this tutorial, chose "Site Package Tutorial" as type of the site package.
15435

155-
You have to click on the "Download" link, on the top of the summary
156-
in order to get your zipped site package.
157-
158-
You can then unzip the zip file, place the resulting folder in your
159-
`packages` folder, and :ref:`install it <extension-installation>`.
36+
Download and unzip the zip file, place the result in folder
37+
`packages/my_site_package`, and :ref:`install it <extension-installation>`.
16038

16139
.. _extension-installation:
16240

@@ -176,24 +54,27 @@ followed these steps:
17654
Install the site package you just created
17755
-----------------------------------------
17856

179-
Move your extension folder :path:`my-site-package/` into the :path:`packages/`
57+
If you used the Site Package Builder, file :file:`packages/my_site_package/README.md`
58+
contains instructions on how to install your site package.
59+
60+
Move / unzip your extension folder :path:`my_site_package/` into the :path:`packages/`
18061
folder. Then *require* the extension via Composer using the
18162
package name defined in the site package extension's :file:`composer.json` now located
182-
at :file:`packages/my-site-package/`
63+
at :file:`packages/my_site_package/`
18364

18465
.. code-block:: json
18566
:caption: packages/my-site-package/composer.json
18667
18768
{
188-
"name": "myvendor/my-site-package"
69+
"name": "my-vendor/my-site-package"
18970
}
19071
19172
require it by:
19273

193-
.. code-block:: bash
74+
.. code-block:: bash
19475
:caption: Execute in directory page_root
19576
196-
composer require myvendor/my-site-package:@dev
77+
ddev composer require my-vendor/my-site-package:@dev
19778
19879
.. _extension-installation-project-structure:
19980

@@ -214,13 +95,13 @@ Your project should now have the following structure:
21495

21596
* sites
21697

217-
* :ref:`[site identifier] <typo3-backend-site>`
98+
* main
21899

219100
* config.yaml
220101

221102
* packages
222103

223-
* my-site-package
104+
* my_site_package
224105

225106
* [All sitepackage files]
226107

@@ -246,56 +127,63 @@ Your project should now have the following structure:
246127
* composer.json
247128
* composer.lock
248129

249-
250130
.. _minimal-extension-siteset:
251131

252-
Create a basic site set
253-
=======================
132+
Look at the a basic site set
133+
============================
254134

255135
.. versionadded:: 13.1
256136
:ref:`Site sets <t3coreapi:site-sets>` have been introduced.
257137

258-
Create a folder called :path:`Configuration/Sets/SitePackage/` in the site package
259-
and add a file called :file:`config.yaml` to it. This file contains the
260-
**site set** of your site package:
138+
The site package build by Site Package Builder comes with a ready to use
139+
site set in folder :path:`packages/my_site_package/Configuration/Sets/SitePackage/`.
140+
141+
The set itself is defined within this folder in the file :file:`config.yaml`:
261142

262-
.. literalinclude:: _config.yaml
143+
.. literalinclude:: /CodeSnippets/my_site_package/Configuration/Sets/SitePackage/config.yaml
263144
:caption: packages/my-site-package/Configuration/Sets/SitePackage/config.yaml
145+
:emphasize-lines: 1-2
264146

265147
You will learn more about site sets in chapter
266148
:ref:`site_set`.
267149

268150
You can find the complete reference in TYPO3 explained:
269151
:ref:`Site sets <t3coreapi:site-sets>`.
270152

271-
Edit the site configuration that was created in step :ref:`typo3-backend-site`
272-
and add the site set to it. You can do this by using the backend module:
153+
During installation of your site package a page tree with example content was
154+
created, and should already have a site configuration in folder
155+
:path:`config/sites/main`.
156+
157+
When you look at the site configuration in module :guilabel:`Site Management > Sites`
158+
it should already contain the set "My Site package". Other sets, for example
159+
if you want to use :composer:`typo3/cms-form` can be added here.
273160

274161
.. figure:: AddSiteSet.png
275-
:alt: Screenshot demonstrating adding the "Example: My Site package" to the site main
162+
:alt: Screenshot demonstrating adding the "My Site package" to the site main
276163

277164
Use module :guilabel:`Site Management > Sites` to add the "Example: My Site package"
278165

279-
On saving, the site package is added to your site configuration file, which changes to this:
166+
If you made no changes, the site configuration should look like this:
280167

281-
.. literalinclude:: _config.yaml.diff
168+
.. literalinclude:: /CodeSnippets/my_site_package/Initialisation/Site/main/config.yaml
169+
:caption: config/sites/main/config.yaml
282170

283171
.. _minimal-extension-typoscript:
284172
.. _make-typoscript-available:
285173

286-
The TypoScript-only version
287-
===========================
174+
The site set as TypoScript Provider
175+
===================================
288176

289177
.. versionadded:: 13.1
290178
A site set can be used as :ref:`TypoScript provider <t3coreapi:site-sets-typoscript>`.
291179

292-
Create a file called :file:`setup.typoscript` containing basic TypoScript configuration
293-
in the folder of the site set you created in step :ref:`minimal-extension-siteset`:
294-
295-
.. literalinclude:: _minimal.typoscript
296-
:caption: packages/my-site-package/Configuration/Sets/SitePackage/setup.typoscript
180+
TYPO3 uses TypoScript as configuration language. The TypoScript is used to
181+
configure the templates, which are created with the templating language Fluid.
297182

298-
Clear all caches and preview the web page.
183+
A file called :path:`packages/my_site_package/Configuration/Sets/SitePackage/setup.typoscript`
184+
provides the TypoScript to your site. This file contains imports of files from
185+
folder :path:`packages/my_site_package/Configuration/Sets/SitePackage/TypoScript`
186+
which contain the actual configuration.
299187

300188
You can learn more about the TypoScript syntax used here in chapter
301189
:ref:`A minimal page created by pure TypoScript <t3start:typoscript>`
@@ -306,49 +194,16 @@ of the "Getting Started Tutorial".
306194
The TYPO3 Fluid version
307195
=======================
308196

309-
Replace file :file:`setup.typoscript` of previuous example with the following lines:
197+
File :path:`packages/my_site_package/Configuration/Sets/SitePackage/TypoScript/page.typoscript`
198+
Defines how the output of all pages of the site is rendered with Fluid templates:
310199

311-
.. literalinclude:: _pageview.typoscript
312-
:caption: packages/my-site-package/Configuration/Sets/SitePackage/setup.typoscript
200+
.. literalinclude:: /CodeSnippets/my_site_package/Configuration/Sets/SitePackage/TypoScript/page.typoscript
201+
:caption: packages/my_site_package/Configuration/Sets/SitePackage/TypoScript/page.typoscript
202+
:emphasize-lines: 6
313203
:linenos:
314204

315-
If you preview your page now you would get an error output like:
316-
317-
.. code-block:: html
318-
319-
Oops, an error occurred! Request: bddd8a816bda3
320-
321-
.. todo: Add information about dealing with errors such as these and link from here.
322-
323-
This is because the template has not been found.
324-
325-
By searching for the hash `bddd8a816bda3` in the log file you will find such an entry:
326-
327-
.. code-block:: plaintext
328-
:caption: var/log/typo3_ece44d5005.log
329-
:emphasize-lines: 7
330-
331-
Mon, 07 Oct 2024 04:09:44 +0000 [ALERT] request="bddd8a816bda3"
332-
component="TYPO3.CMS.Frontend.ContentObject.Exception.ProductionExceptionHandler":
333-
Oops, an error occurred! Request: bddd8a816bda3- InvalidTemplateResourceException:
334-
Tried resolving a template file for controller action "Default->Pages/Default"
335-
in format ".html", but none of the paths contained the expected template file
336-
(Default/Pages/Default.html).
337-
The following paths were checked: /var/www/html/vendor/myvendor/my-site-package/Resources/Private/PageView/
338-
339-
This error message also tells you the path where TYPO3 expects to find the file. If no path
340-
is listed here, the path defined in line 6 of the TypoScript above is incorrect,
341-
for example if you mistyped the extension name or part of the path.
342-
343-
Create a file named :file:`Default.html` in folder
344-
:path:`packages/my-site-package/Resources/Private/PageView/Pages`.
345-
346-
.. code-block:: html
347-
:caption: packages/my-site-package/Resources/Private/PageView/Pages/Default.html
348-
349-
Hello Fluid World!
350-
351-
Clear all caches and preview the web page.
205+
Line 6 defines from what directory the Fluid Templates are loaded. Line 7 allows
206+
to override this part via settings.
352207

353208
Learn more about using Fluid Templates in chapter :ref:`fluid-templates`.
354209

@@ -382,7 +237,7 @@ a file called :file:`composer.json` was created for you:
382237
:linenos:
383238

384239
At the top of the :file:`composer.json` file we see the Composer package name
385-
`myvendor/my-site-package` (with a dash) and at the bottom we see the TYPO3
240+
`my-vendor/my-site-package` (with a dash) and at the bottom we see the TYPO3
386241
extension key in the extra section - :file:`my_site_package` (with an underscore).
387242
The Composer "name" consists of a vendor name followed by a forward slash and the
388243
lowercase extension name with dashes.
-82 KB
Binary file not shown.
-283 KB
Binary file not shown.

0 commit comments

Comments
 (0)