|
3 | 3 |
|
4 | 4 | .. _minimal-design: |
5 | 5 |
|
6 | | -==================== |
7 | | -Minimal site package |
8 | | -==================== |
| 6 | +=============== |
| 7 | +Minimal example |
| 8 | +=============== |
9 | 9 |
|
10 | | -A site package is a custom TYPO3 extension which contains configuration, |
11 | | -templates, assets, etc that are used for the site it belongs to. |
| 10 | +We want to create a site package that outputs a single web page with |
| 11 | +minimal effort. This site package can be used to simply test system output or as |
| 12 | +an example of the fewest possible steps to create a working site package. |
12 | 13 |
|
13 | | -So first we create a minimal extension. |
14 | | - |
15 | | -.. _minimal-extension: |
16 | | - |
17 | | -Create a minimal TYPO3 extension using b13/make |
18 | | -=============================================== |
19 | | - |
20 | | -:composer:`b13/make` is a convenient TYPO3 extension which you can use during |
21 | | -development to create a new TYPO3 extension quickly or add functionality to an |
22 | | -existing one. |
23 | | - |
24 | | -Use Composer to install it for development only: |
25 | | - |
26 | | -.. code-block:: bash |
27 | | -
|
28 | | - ddev composer req b13/make --dev |
29 | | -
|
30 | | -Execute the command `ddev typo3 make:extension` and answer the prompt |
31 | | - |
32 | | -.. code-block:: bash |
33 | | -
|
34 | | - ddev typo3 make:extension |
35 | | -
|
36 | | - Enter the composer package name (e.g. "vendor/awesome"): |
37 | | - > t3docs/site-package |
38 | | -
|
39 | | - Enter the extension key [site_package]: |
40 | | - > |
41 | | -
|
42 | | - Enter the PSR-4 namespace [T3docs/SitePackage]: |
43 | | - > |
44 | | -
|
45 | | - Choose supported TYPO3 versions (comma separate for multiple) [TYPO3 v12 LTS]: |
46 | | - [10] TYPO3 v10 LTS |
47 | | - [11] TYPO3 v11 LTS |
48 | | - [12] TYPO3 v12 LTS |
49 | | - [13] TYPO3 v13 |
50 | | - > 12 |
51 | | -
|
52 | | - Enter a description of the extension: |
53 | | - > My site package |
54 | | -
|
55 | | - Where should the extension be created? [src/extensions/]: |
56 | | - > packages |
57 | | -
|
58 | | - May we add a basic service configuration for you? (yes/no) [yes]: |
59 | | - > no |
60 | | -
|
61 | | - May we create a ext_emconf.php for you? (yes/no) [no]: |
62 | | - > |
63 | | -
|
64 | | - [OK] Successfully created the extension my_site_package (myvendor/my-site-package). |
65 | | -
|
66 | | -This script creates a new folder called `packages` with a subfolder, |
67 | | -`my-site-package`. It mainly contains only a file called `composer.json`. |
68 | | - |
69 | | -You could of course also create this file manually. Step |
70 | | -:ref:`extension-configuration` will explain the content of the :file:`composer.json`. |
71 | | -For the time being just remember the Composer name you have chosen |
72 | | -(`t3docs/site-package`) and the extension name (`site_package`). |
73 | | - |
74 | | -In order to see a change in the TYPO3 backend or frontend your site package needs |
75 | | -to be :ref:`installed <extension-installation>`. |
76 | | - |
77 | | -After you have created your site package extension you can uninstall :composer:`b13/make`: |
78 | | - |
79 | | -.. code-block:: bash |
80 | | -
|
81 | | - ddev composer remove b13/make --dev |
82 | | -
|
83 | | -.. _minimal-extension-typoscript: |
| 14 | +To start, in the TYPO3 backend, create a standard page named |
| 15 | +:guilabel:`Minimal example` just under (inside) the page tree TYPO3 logo |
| 16 | +container. Create a new TypoScript template record on this page. |
| 17 | +Give the TypoScript template a title, and make it a root level template, |
| 18 | +but do not include any static templates. |
84 | 19 |
|
85 | 20 | The TypoScript-only version |
86 | 21 | =========================== |
87 | 22 |
|
88 | | -Create a file called :file:`setup.typoscript` containing basic TypoScript configuration |
89 | | -in the folder :path:`Configuration/Setup`: |
| 23 | +In the TypoScript template Setup field, add the following three lines: |
90 | 24 |
|
91 | | -.. literalinclude:: _minimal.typoscript |
92 | | - :caption: packages/site-package/Configuration/TypoScript/Setup/setup.typoscript |
| 25 | +.. code-block:: typoscript |
| 26 | + :caption: TypoScript Setup |
93 | 27 |
|
94 | | -Clear all caches and preview the web page. |
| 28 | + page = PAGE |
| 29 | + page.1 = TEXT |
| 30 | + page.1.value = Hello, world. |
95 | 31 |
|
96 | | -You can learn more about the TypoScript syntax used here in chapter |
97 | | -:ref:`A minimal page created by pure TypoScript <t3start:typoscript>` |
98 | | -of the "Getting Started Tutorial". |
| 32 | +View the web page. |
99 | 33 |
|
100 | | -.. _minimal-extension-fluid: |
| 34 | +This TypoScript-only design has the least instructions required to output a |
| 35 | +web page from TYPO3. This TypoScript template is self contained and |
| 36 | +no other files or database records needed. Changing this content |
| 37 | +only requires the appropriate access needed to make changes to TypoScript |
| 38 | +templates. |
101 | 39 |
|
102 | 40 | The TYPO3 Fluid version |
103 | 41 | ======================= |
104 | 42 |
|
105 | | -Replace file :file:`setup.typoscript` of example |
106 | | -:file:`minimal-extension-typoscript` with the following lines: |
| 43 | +Empty the :guilabel:`Minimal design` page TypoScript template Setup field, |
| 44 | +then add the following lines: |
107 | 45 |
|
108 | | -.. literalinclude:: _pageview.typoscript |
109 | | - :caption: ackages/site-package/Configuration/TypoScript/Setup/setup.typoscript |
110 | | - :linenos: |
| 46 | +.. code-block:: typoscript |
| 47 | + :caption: TypoScript Setup |
111 | 48 |
|
112 | | -If you preview your page now you would get an error output like: |
| 49 | + page = PAGE |
| 50 | + page.1 = FLUIDTEMPLATE |
| 51 | + page.1.file = EXT:site_package/Resources/Private/Templates/Minimal.html |
113 | 52 |
|
114 | | -.. code-block:: html |
| 53 | +Create a file named :file:`Minimal.html` in a |
| 54 | +:file:`typo3conf/ext/site_package/Resources/Private/Templates` folder. |
115 | 55 |
|
116 | | - Oops, an error occurred! Request: bddd8a816bda3 |
| 56 | +The site package extension has to be :ref:`installed <extension-installation>` |
| 57 | +and requires a :ref:`minimal composer configuration <extension-configuration>` (if composer is used) |
| 58 | +for this to work |
117 | 59 |
|
118 | | -.. todo: Add information about dealing with errors such as these and link from here. |
119 | | -
|
120 | | -This is because the template has not been found. |
| 60 | +.. code-block:: html |
| 61 | + :caption: EXT:site_package/Resources/Private/Templates/Minimal.html |
121 | 62 |
|
122 | | -By searching for the hash `bddd8a816bda3` in the log file you will find such an entry: |
| 63 | + Hello, world. |
123 | 64 |
|
124 | | -.. code-block:: plaintext |
125 | | - :caption: var/log/typo3_ece44d5005.log |
126 | | - :emphasize-lines: 7 |
| 65 | +Now view the web page. |
127 | 66 |
|
128 | | - Mon, 07 Oct 2024 04:09:44 +0000 [ALERT] request="bddd8a816bda3" |
129 | | - component="TYPO3.CMS.Frontend.ContentObject.Exception.ProductionExceptionHandler": |
130 | | - Oops, an error occurred! Request: bddd8a816bda3- InvalidTemplateResourceException: |
131 | | - Tried resolving a template file for controller action "Default->Pages/Default" |
132 | | - in format ".html", but none of the paths contained the expected template file |
133 | | - (Default/Pages/Default.html). |
134 | | - The following paths were checked: /var/www/html/vendor/t3docs/site-package/Resources/Private/Templates/ |
| 67 | +Here we are putting the page content into a separate HTML file, allowing for |
| 68 | +separate access control and for an editing workflow that does not need much |
| 69 | +TypoScript. The TYPO3 renderer still requires a TypoScript template on the |
| 70 | +:guilabel:`Minimal design` page to know which file to process. |
135 | 71 |
|
136 | | -This error message also tells you the path where TYPO3 expects to find the file. If no path |
137 | | -is listed here, the path defined in line 6 of the TypoScript above is incorrect, |
138 | | -for example if you mistyped the extension name or part of the path. |
| 72 | +Resulting web page |
| 73 | +================== |
139 | 74 |
|
140 | | -Create a file named :file:`Default.html` in folder |
141 | | -:path:`packages/site-package/Resources/Private/Pages`. |
| 75 | +Here is the resulting web page HTML source for both the TypoScript-only and |
| 76 | +the Fluid based implementations. Notice how TYPO3 has added default markup |
| 77 | +around the single line of content: |
142 | 78 |
|
143 | 79 | .. code-block:: html |
144 | | - :caption: packages/site-package/Resources/Private/Pages/Default.html |
145 | | - |
146 | | - Hello Fluid World! |
147 | | - |
148 | | -Clear all caches and preview the web page. |
149 | | - |
150 | | -Learn more about using Fluid Templates in chapter :ref:`fluid-templates`. |
| 80 | + :caption: Example frontend output |
| 81 | + |
| 82 | + <!DOCTYPE html> |
| 83 | + <html lang="en"> |
| 84 | + <head> |
| 85 | + <meta charset="utf-8"> |
| 86 | + <!-- |
| 87 | + This website is powered by TYPO3 - inspiring people to share! |
| 88 | + TYPO3 is a free open source Content Management Framework initially |
| 89 | + created by Kasper Skaarhoj and licensed under GNU/GPL. |
| 90 | + TYPO3 is copyright 1998-2018 of Kasper Skaarhoj. Extensions are |
| 91 | + copyright of their respective owners. |
| 92 | + Information and contribution at https://typo3.org/ |
| 93 | + --> |
| 94 | + <title>Minimal design</title> |
| 95 | + <meta name="generator" content="TYPO3 CMS"> |
| 96 | + </head> |
| 97 | + <body> |
| 98 | + Hello, world. |
| 99 | + </body> |
| 100 | + </html> |
0 commit comments