Create CT Template
Observe to create a template you need to know PHP, HTML and CSS. This is for advanced users, if you do not understand the guide bellow then ask for a peronal training.
Creating templates in CT i very much like creating a template in Wordpress. Only it is simpler if you know how some frameworks work. We have created an example bellow, how to create a regular page template.
1. Create template (page)
- Namnge mallen: The template name
- Koppla till modul: The modul you want to use the template in
- Är lika med: Some modules has diffrent types. Page modul has for example has "page" and "section". If you only want to create a template for only pages then you write here "page".
2. Create field
- Rubrik: The field label
- Fält namn: The field name. The field need to match the database columns, see bellow the image what columns you can use. Should always be lower case.
- Fälttyp: This is what kind of form field tou want to create
2.1 Database columns to use for page in the "field name":
- name: If it is a page it should allways have label (Rubrik) "Menynamn" becouse it will be used to create a permalink also. If it is section it should only be a headline.
- content: This columns is for long information text.
- extra: Within this column you can create custom columns. So if you write "extra,subheader" then the filed will create a column subheader within the extra column in database.
- upload: Much like extra above. but you should write "upload,image", "upload" for the DB column and a unique key phrase "image" for the name inside the column.
Allways use lowercases.
3. Field settings
- Rubrik: The field label
- Fält namn: The field name. The field need to match the database columns. Should always be lower case
- Klass: some fields has a class function attached to its self. If you write for example "editor" for a textarea field then the regular textarea will be converted into a editor (WYSIWYG).
- Default value: If value is empty then set a default value.
- Rubrik: Add an "extra" seperator headline.
- Info: Add a description under the label.
- Attributer: Add custom attributes to the field. If it is for example a input text field then you can add the attribute Namn: type and Value: email.
- Validate: most fields should have some sort of validation on it. For more information click here.
4. Create the frontend template
At the start page of "CT mallar" there is a table that list all created template. In the column named "Modulnamn" is the file name of the template that should be created.
4.1 Create file
Create an empty file with the template name inside the directory "content/templates/YOUR_TEMPLATE_NAME/views/pages/", I named my template "Test" so I created a empty ".php" file (test.php).
4.2 Add code
Fill the template with html and php code. For more information on how to call DB columns click here and read under the headline "Example - page templates".