Hide

YetaWF Documentation

Display
Print

Site Templates

Site Templates are text files and exported pages (ZIP files) which define a group of pages, modules and configuration settings. They are typically used for YetaWF upgrades and during module/package development to install and/or remove a group of pages. Third-party packages can also provide Site Templates and exported pages to quickly define a group of pages so they don't have to be created manually.

Site Templates are located in the ./SiteTemplates folder of the YetaWF Website folder:

    Solution
        Website
            SiteTemplates
                Data
                    *.zip files (complete packages)
                *.txt files
                *.(version).txt files
                (areaName) folders
                    Install
                        *.zip files (pages)
                    (version) folders
                        *.zip files (pages)

Site Templates and page ZIP files are copied from all packages to this location (./Website/SiteTemplates) during site startup. Site Templates and page ZIP files are distributed with each package that require them.

Packages include Site Templates page ZIP files within the package at ./Addons/_SiteTemplates.

You can test site templates by adding them directly in the Website folder ./SiteTemplates, but when distributing packages they must be included in the package folder ./Addons/_SiteTemplates.

The text files each contain a set or definitions used to create pages/modules and settings.

ZIP files are exported pages or packages that are imported.

Data Folder

The Website's SiteTemplates/Data folder is used by YetaWF when a new site is created. While a new site is created using Admin > Sites (standard YetaWF site), Add New Site action, all package ZIP files present in the Data folder are imported for the new site and the Add Additional Site.txt file is executed.

*.txt And *.(version).txt Files

All *.txt files are base templates for new packages. These files contain statements that can be executed. When a new package is installed, the *.txt with the package's name is executed. For example, if the YetaWF.Text package is installed, the file YetaWF_Text.txt is executed.

The general format for a base template is:

package_name.txt

Files with version numbers are installed when a package is installed or upgraded to the version. For example, if the YetaWF.Text package (version 4.2.0) is installed/upgraded, all *.txt files with a version number less or equal to 4.2.0 are executed (YetaWF_Text.3.9.0.txt, YetaWF_Text.4.1.0.txt, YetaWF_Text.4.2.0.txt, but not YetaWF_Text.4.3.0.txt).

The general format for versioned templates is:

package_name.version.txt

where version usually has 3 parts, "x.y.z" (for example, YetaWF_Text.1.3.4.txt).

Also see Upgrading In Development.

(areaname) Folders

Packages can distribute ZIP files containing exported pages. These are originally located in the package's ./Addons/_SiteTemplates folder and are copied to the website's ./SiteTemplates during site startup.

(areaname)/Install Folder

Any ZIP files (exported pages) located in the (areaname)/Install folder are imported when a package is installed for the first time.

(areaname)/(version) Folder

Any ZIP files located in the (areaname)/(version) folder are imported when a package is upgraded to the specified version.

Process A Template

Admin > Panel > Packages (standard YetaWF site) can be used to process a template (Process Site Template Module) which creates all pages and modules defined within the Site Template.

Remove A Site Template

Admin > Panel > Packages (standard YetaWF site) can be used to undo a template (Undo Site Template Module) which removes pages and unique modules. Non-unique modules are never removed as they could still be in use on other pages. (TODO: Investigate if we can automate removal, because this sucks.)

Example

The following example is the YetaWF_Blog.txt file, which defines all pages for the YetaWF.Blog Package. This package is installed in a standard YetaWF site, but no pages are created.

### Copyright © 2020 Softel vdm, Inc. - https://yetawf.com/Documentation/YetaWF/Licensing
###
### Adds sample pages for the YetaWF.Blog package
###

::PAGE-SECTION::

Anonymous+User /Blog
    Title=Blog
    Blog
    -
    YetaWF.Blog, YetaWF.Modules.Blog.Modules.CategoriesListModule
    YetaWF.Blog, YetaWF.Modules.Blog.Modules.CategoryHeaderModule
        ShowFormButtons = false
    YetaWF.Blog, YetaWF.Modules.Blog.Modules.BlogModule

Administrator /Admin/Config/Blog
    Title=Blog Settings
    Admin > Settings  > {YetaWF.Blog, YetaWF.Modules.Blog.Modules.BlogConfigModule}.GetAction_Edit(null)
    -
    YetaWF.Blog, YetaWF.Modules.Blog.Modules.BlogConfigModule

Administrator /Admin/Blog/Categories
    Title=Blog Categories
    Admin > Blog > Categories
    -
    YetaWF.Blog, YetaWF.Modules.Blog.Modules.CategoriesBrowseModule
        BrowseEntriesUrl = "/Admin/Blog/Entries"
        WantSearch = false

Administrator /Admin/Blog/Entries
    Title=Blog Entries
    Admin > Blog > Entries
    -
    YetaWF.Blog, YetaWF.Modules.Blog.Modules.EntriesBrowseModule
        WantSearch = false

Anonymous+User /BlogEntry
    Title=Blog Entry
    -
    -
    YetaWF.Blog, YetaWF.Modules.Blog.Modules.CategoryHeaderModule
        ShowFormButtons = false
    YetaWF.Blog, YetaWF.Modules.Blog.Modules.EntryDisplayModule
        ShowFormButtons = false
    YetaWF.Blog, YetaWF.Modules.Blog.Modules.CommentsDisplayModule
        ShowFormButtons = false
    YetaWF.Blog, YetaWF.Modules.Blog.Modules.CommentAddModule

::UNIQUE-MODULE-SECTION::

YetaWF.Blog, YetaWF.Modules.Blog.Modules.BlogConfigModule
    UpdateConfigProperty("BlogUrl", "/Blog")
    UpdateConfigProperty("BlogEntryUrl", "/BlogEntry")

Template Sections:

Site Templates contain multiple sections, each with its specific types of definitions.

SectionDescription
::PAGE-SECTION::Used to define pages and modules
::UNIQUE-MODULE-SECTION::Used to define unique modules
::NON-UNIQUE-MODULE-SECTION::Used to define non-unique modules
::LINK-SECTION::Adds Urls (links) to the main menu.
::WEBCONFIG-SECTION::Adds AppSettings.json entries.
::COMMAND-SECTION::Calls methods in class objects.
::INCIncludes the contents of another Site Template file.

::PAGE-SECTION::

Defines pages and modules. Instead of using ::PAGE-SECTION:: to define pages and modules, the pages including modules should be exported and placed in the (areaname) folders instead.

::PAGE-SECTION::

Anonymous+User /
    Title=Home Page
    Home
    -
    YetaWF.Text,YetaWF.Modules.Text.Modules.TextModule
        Contents = "<a class="linkpreview-show" href="https://YetaWF.com/">https://YetaWF.com/</a>"
Anonymous+User /User/Login
    Title=Login
    User > YetaWF.Identity,YetaWF.Modules.Identity.Modules.LoginModule.GetAction_Login("/User/Login")
    -
    YetaWF.Identity,YetaWF.Modules.Identity.Modules.LoginModule

Following the ::PAGE-SECTION:: statement, 0, 1 or multiple pages can be defined:

Page Definition

The first line, starting in the first column, defines the authorized users, followed by the Url. The page is created using the specified Url.

Possible authorized user specifications are Anonymous+User, User, Anonymous or Administrator. Only one can be specified.

Any lines following the first line must be indented if they are part of the current Page Definition. Any line starting in the first column is interpreted as the start of a new Page Definition.

If the next indented line starts with Title=, the remainder of the line is assigned as the page title.

The next indented line defines the main menu path where a link to the new page is added. Specify - if no main menu entry is desired.

The next indented line(s) define new modules to be added to the page in the following format:

package_name,module_class
    or
package_name,module_class : pane

pane is optional. If not specified, all new modules are added to the page's Main pane.

Any lines following with a deeper nesting level than the new module definition are considered property settings for the newly created module.

Anonymous+User /BlogEntry Sample
    Title=Blog Entry
    Admin > Blog > Some Blog Entry
    -
    YetaWF.Blog, YetaWF.Modules.Blog.Modules.CategoryHeaderModule
        ShowFormButtons = false
    YetaWF.Blog, YetaWF.Modules.Blog.Modules.EntryDisplayModule
        ShowFormButtons = false
    YetaWF.Blog, YetaWF.Modules.Blog.Modules.CommentsDisplayModule
        ShowFormButtons = false
    YetaWF.Blog, YetaWF.Modules.Blog.Modules.CommentAddModule

:UNIQUE-MODULE-SECTION::

TODO: Will need to document further