Tutorial: Publish a first page

In this section you'll create your first page in MyRed and publish it as default index page.

1. Create a new document

Open the admin area (subfolder /admin) page in your webbrowser and create a new document.

  1. Change to document management by clicking the corresponding "Page Editor" tab.
  2. Select the folder "Undefined". This folder contains documents you didn't insert into a specific folder. It's a container for all unsorted documents.
  3. Click "Create new" to create a new document in the global "Undefined" folder.
  4. Select the newly created document by clicking it's name. The document editor will be opened on the right side.
  5. Type the text 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).
  6. Enter a title like My first document.
  7. Enter a simple text like <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.
  8. Ensure that the option "Save this document" is selected from the radio buttons in the gray area on the page's bottom and click Execute.

 

2. Test the document

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.

 

3. Edit the template

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.

  1. Click on the blue document "Sampletemplate" in the document list of the "Undefined" folder on the left side.
  2. It opens inside the editor on the right.

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.