In this section you'll create your first page in MyRed and publish it as default index page.
Open the admin area (subfolder /admin) page in your webbrowser and create a new document.
index
into the eID input field. This causes MyRed
to open this page when the homepage is called without parameter (http://localhost/test)
or with parameter ?index
(http://localhost/test/?index).My first document
.<h1>Hello World</h1>
.
Note that you may enter html code like the <h1>
header
tag here. But don't enter head
and body
tags here,
this will be done inside templates later.
Now open the root url like http://localhost/test inside your web browser.
You should see something like this:
Title:My first document Hello World!
Nice, our title and document text are displayed. But why is there the word "Title:" visible and the Hello World! text green? These settings are stored inside a so called template each document uses.
When a document stored inside the database, MyRed reads the contents of the
document and the contents of the template assigned to the content doc. It then
replaces any occurence of {myred_page_body}
inside the template's
text with the content doc's text. The so created fusion of template and content
document is then sent to the browser.
In the document editor you can switch to the Integration tab.
Here you can define what template is used for the document and in which folder
the document (not the template) is saved.
Note that these folders are MyRed document folders not real folders in the file
system.
Let's have a look at the template's content.
The template contains some code:
<b>Title:<?=$myred['currentpage']->title?></b>
means write in bold font the word "Title:" followed by the currently
displayed document's title. This title is fetched through a small piece of php
code that connects directly to a MyRed variable.
<font color="green"> {myred_page_body} </font>
causes the currently displayed document's body to be inserted into a font tag.
This is where the green color comes from.
The template is a simple document just like our "Hello World" content document above. The difference is that this page has the DocType set to "Template" while the our content has the DocType "Page".
(Not important here, but you might ask: The text "#MYRED_PRESET" defined as Tag means that this page is installed and predefined by MyRed. Don't change it.)
Each content document has to have a template, but the template could be empty.
Nevertheless an empty template has at least to have the code {myred_page_body}
as text to insert the content document's text. A completely empty template would
should nothing in the final web page.