Grav – CLI

Grav – CLI ”; Previous Next In this chapter, we will understand how the CLI works in Grav. CLI stands for command line interface stored in bin/Grav. It performs some tasks such as clearing cache, creating backup copy, etc. Accessing CLI is different on different platforms. On Windows, you can access through cmd, on Mac you can access through Terminal and on Linux you can use shell. In windows, you can”t use UNIX style commands. To use these just install the msysgit package which provides GIT and GIT BASH and provides UNIX style commands on Windows. You can list out the available commands in the Grav by using below command − $ bin/Grav list You can see the available commands as shown in the following screenshot − New Project Creation Creating new project with Grav is very simple. You can create a new project with a Grav instance. Open your terminal or console and navigate to your Grav folder. $ cd ../ProjectFolder/grav Your Grav will be installed in the root of your web server. If you want to create folder called contact inside the root folder of your Grav, then use the command as − $ bin/Grav project-name ../webroot/ contact It will download all the required dependencies and create a new Grav instance. Installing Grav Dependencies While installing dependencies, Grav automatically installs plugins namely error plugin, problems plugin and antimatter theme. You can install these by using the following command in your terminal or console − $ cd ../webroot/myproject $ bin/Grav install You will now see the downloaded plugins in their respective folders as − ../webroot/ myproject/user/plugins/error ../webroot/ myproject/user/plugins/problems ../webroot/ myproject/user/themes/antimatter Clearing Grav Cache You can delete files and folders to clear the cache which are stored in the cache/ folder. To clear cache, you can use below command − $ cd ../webroot/myproject $ bin/Grav clear-cache Create Backup In Grav, you can back up your project stored under the root folder. As it won”t use the database so there is no difficulty to take a backup. If you want to create the backup of your project called myproject (../webroot/myproject), then use the following command − $ cd ../webroot/myproject $ bin/Grav backup You will see a zip file of the backup created under the backup/ folder. Updating Composer You can update the Grav composer which was installed via Github and installed manually using composer based vendor packages. The command is − $ bin/Grav composer Print Page Previous Next Advertisements ”;

Grav – Discussion

Discuss Grav ”; Previous Next Grav is a flat-file based content management system which doesn”t use database to store the content instead it uses text file (.txt) or markdown (.md) file to store the content. The flat-file part specifically refers to the readable text and it handles the content in an easy way which can be simple for a developer. Print Page Previous Next Advertisements ”;

Grav – GPM

Grav – GPM ”; Previous Next GPM stands for Grav Package Manager which is used to install, update, un install and list the available plugins on the Grav repository. GPM executes the commands using command line interface such as terminal or cmd. You can access CLI very easily. On Windows, you can access through cmd, on Mac you can access through Terminal and on Linux you can use shell. In windows, you can”t use UNIX style commands. To use these just install the msysgit package which provides GIT and GIT BASH and provides UNIX style commands on Windows. To list the available commands on the Grav repository type the command as − $ bin/gpm list You will receive the following − You can help the commands by adding help to the line as shown below − $ bin/gpm help install You can find the version of PHP on the command line interface by using the following command − $ php -v How Does it work? When you run the commands on the command line interface, GPM automatically downloads the required data from the GetGrav.org site. It includes all the details of available packages and also determines the packages that need to be installed and which packages needs to be updated. When you are downloading the packages from the repository, the Grav repository gets cached locally and no request will be able to contact the GetGrav.org server after the cache has been generated. Some commands come with the –force (-f) option, which forces to re-fetch the repository. Using this option, there is no need to wait for 24 hours cycle before cache gets cleared. Commands You can download the available packages from the Grav repository using some commands. To make use of the command, open your terminal and navigate to your root of the Grav folder and type as bin/gpm <command>. Index The index command is used to list the available plugins, themes in the Grav repository. Use the below command in your terminal to list out the available resources. $ bin/gpm index Each line defines the name of the plugin or theme, slug, version of plugin or theme and also displays whether it is installed or not. Info The info command is used to display the information about package such as author, version, date and time of last updated, repository of package, download link of package, license information etc. Install As the name implies the install command installs the required resources for the package from the Grav repository. You can use the following command to install the required package. $ bin/gpm install package_name If you try to install an already installed package, then it informs what to do next. If you type Y, it will overwrite on an already installed package and if you type N, it will abort the installation process. Update The update command informs about the package that need to be updated. Suppose if all packages are up to date, then it will say nothing to update. $ bin/gpm update Self-upgrade The self-upgrade command is used to upgrade the Grav to the latest version. Use the following command to upgrade the Grav. $ bin/gpm self-upgrade If you are using the latest version of Grav, then it will display a message saying “You are already running the latest version of Grav” along with the date of release and the time as shown in the screen. Print Page Previous Next Advertisements ”;

Grav – Forms

Grav – Forms ”; Previous Next You can create a form using the form plugin available in this link. Search for the form plugin and install it in your Grav folder. You can also install this plugin using the command $ bin/gpm install Form. Navigate to your root folder of Grav and type this command. It will automatically download the form plugin and install the necessary dependencies. Creating a Simple Form You can create a simple form which can be defined in the page YAML frontmatter. The following is an example of a form − — title: Contact Form form: name: contact fields: – name: name label: Name placeholder: Enter your name autofocus: on autocomplete: on type: text validate: required: true – name: email label: Email placeholder: Enter your email address type: email validate: required: true – name: message label: Message placeholder: Enter your message type: textarea validate: required: true – name: g-recaptcha-response label: Captcha type: captcha recatpcha_site_key: 6LelOg4TAAAAALAt1CjjjVMxFLKY8rrnednYVbr8 recaptcha_not_validated: ”Captcha not valid!” validate: required: true buttons: – type: submit value: Submit – type: reset value: Reset process: – email: subject: “[Site Contact Form] {{ form.value.name|e }}” body: “{% include ”forms/data.html.twig” %}” – save: fileprefix: contact- dateformat: Ymd-His-u extension: txt body: “{% include ”forms/data.txt.twig” %}” – message: Thank you for getting in touch! – display: thankyou — The above code shows simple form page with name, email, message and Captcha fields. When you submit the information after filling the form, the form will process by adding process field to the YAML frontmatter as shown in the code. The process field uses the following information − The email option uses two fields such as from field specify sender of the email and to field specify receiver of the mail. The subject uses [feedback][entered mail] option in which email is sent to the entered email. The body of the email is specified in the forms/data.html.twig file which is present in the theme folder. The form input data is stored under the user/data folder. The template is defined in the forms/data.txt.twig file which is present in the theme folder. Create a subpage under the thankyou/ sub folder which will be redirected to that page when a user submits the form. You can use some fields with the form plugin as shown in the following table − Sr.No. Field & Description 1 Captcha It is an antispam field which is used in computing to determine whether or not the user is human. 2 Checkbox It displays a simple checkbox. 3 Checkboxes It displays multiple checkboxes. 4 Date and Datetime Both fields are used to display date and date along with time respectively. 5 Email It is an email field with validation. 6 Hidden It specifies the hidden field. 7 Password It specifies the password field. 8 Radio It displays the simple radio buttons. 9 Select It provides select field. 10 Spacer It allows to add title, text or horizontal line to the form. 11 Text It displays simple text field. 12 Textarea It displays simple text area field. 13 Display It displays the text or instruction field, not the input field. Fields Parameter Every field accepts the following parameters which can be used to customize the appearance in the form. Sr.No. Parameter & Description 1 label It defines the label field. 2 validate.required It makes the element required. 3 validate.pattern It specifies validation pattern. 4 validate.message It display the message when validation fails. 5 type It defines the field type. 6 default It defines the default field type. 7 size It displays the field size such as large, x-small, medium, long, small. 8 name It defines the field name. 9 classes It uses string with css classes. 10 id It defines the field id. 11 style It specifies the style of the field. 12 title It defines the title of the field. 13 disabled It determines whether or not the field is in a disabled state. 14 placeholder It is a short hint which is displayed in the input field before the user enters a value. 15 autofocus It specifies that an input element should automatically get focus when the page loads. 16 novalidate It specifies that form data should not be validated when submitted. 17 readonly It determines field as read only state. 18 autocomplete It displays the options in the field when user starts typing in the field and displays the values based on earlier typed values. Some of the fields contains specific parameters such as − Sr.No. Parameter & Description 1 date and datetime These fields use validate.min and validate.max to set minimum and maximum values. 2 spacer It uses underline to add <hr> tag, adds text values using text and uses title as <h3> tag. 3 select It uses multiple parameter to add multiple values. 4 select and checkboxes It uses options field to set the available options. 5 display It uses content parameter to display the content. It sets the markdown to true to show the content. 6 captcha It uses recatpcha_site_key and recaptcha_not_validated parameters. Note on Captcha We have code on captcha information under field called g-recaptcha-response as shown below − – name: g-recaptcha-response label: Captcha type: captcha recatpcha_site_key: 6LelOg4TAAAAALAt1CjjjVMxFLKY8rrnednYVbr8 recaptcha_not_validated: ”Captcha not valid!” validate: required: true The reCaptcha is used to protect your website from spam and abuse. It uses the recatpcha_site_key option and displays the widget on your site. To use reCaptcha, just refer the reCaptcha docs. If reCaptcha is incorrect, then it will display message using the recaptcha_not_validated option. Form Actions Email You can send an email with specific options under the process field as shown below − – email: from: “{{ config.plugins.email.from }}” to: “{{ config.plugins.email.to }}” subject: “Contact by {{ form.value.name|e }}” body: “{% include ”forms/data.html.twig” %}” It uses the email option which includes two fields; the from field specifies the sender of the email address and the to field specifies the recevier of the email address by using the Email plugin configuration. The email field also uses subject

Grav – Permission

Grav – Permission ”; Previous Next In general, permission is a process of permitting to do something on your hosting environment. The permission includes read or write access to the files on the server or editing the files on the file system. Grav is a flat file based CMS which needs to write to the file system for creating cache and log files. Grav comes under three main scenarios − PHP/Webserver runs with same user that edits the files This scenario works great with most shared hosting setup and also for local development. On the dedicated web host, we can”t consider this approach as secure enough. PHP/Webserver runs with different accounts but same group With 775 and 664 permissions using shared group between the user and PHP/Webserver account, you can ensure that two different accounts will have the Read/Write access to the files. We can create new files by setting umask 0002 on the root with proper permissions. Different accounts, fix permissions manually This approach will have different accounts and update the ownership and permission of files which ensure that the PHP/Webserver user will have the Read/Write access on the files. Following is the simple code of permissions-fixing shell script. You can edit this file as per the group which works for the setup. #!/bin/sh chown joeblow:staff . chown -R joeblow:staff * find . -type f ! -path “./bin/” | xargs chmod 664 find . -type f -path “./bin/” | xargs chmod 775 find . -type d | xargs chmod 775 find . -type d | xargs chmod +s umask 0002 chown joeblow:staff is used to change the group and user of the directory to joeblow and staff. chown -R joeblow:staff * line changes the ownership of the files and subfolder to joeblow and staff. The line find . -type f ! -path “./bin/” | xargs chmod 664 sets 664 permissions for all files from the directory to Read for the others and Read/Write for group and user. The line find . -type f -path “./bin/” | xargs chmod 775 sets 775 permissions for all files from the directory to RX for the others and RWX for group and user. umask 0002 is used to create new files with 664 and 775 permissions. Print Page Previous Next Advertisements ”;

Grav – Theme Customization

Grav – Theme Customization ”; Previous Next In this chapter, let us study about Theme Customization. There are several ways to customize your theme. Grav provides many features and a few functionalities to easily customize your theme. Custom CSS You can provide your own custom.css file to customize your theme. The Antimatter theme refers the css/custom.css file through the use of Asset Manager. If no reference to the CSS file is found, then the Asset Manager will not add the reference to HTML. Creating the CSS file in Antimatter”s css/ folder will override the default CSS. For example − custom.css body a { color: #FFFF00; } The default link color is overriden and set to yellow. Custom SCSS/LESS Another way to provide custom CSS file is by using the custom.scss file. The SCSS( Syntactically Awesome Style Sheets ) is a CSS preprocessor which allows you to build CSS efficiently through the use of operators, variables, nested structures, imports, partials and mix-ins. The Antimatter is written using SCSS. In order to use SCSS, you need the SCSS compiler. You can use the command-line tools and the GUI applications to install SCSS compilers on any platform. Antimatter uses the scss/ folder to place all your .scss files. The compiled files are stored in css-compiled/ folder. The SCSS files should be watched for any updates which can be done by using the following command − scss –watch scss:css-compiled The above command tells the SCSS compiler to watch the directory called scss and whenever the css-compiled folder is updated the SCSS compiler should compile it. You can keep your custom SCSS code in scss/template/_custom.scss file. There are many advantages of keeping your code in this file. Any update from the SCSS files and other CSS files are compiled into css-compiled/template.css file You can access any of the SCSS that are used in your theme and make use of all variables and mix-ins available to it. For easier development, you are provided with access to all the features and functionalities of standard SCSS. An example of _custom.scss file is shown below − body { a { color: darken($core-accent, 20%); } } When you upgrade your theme, all the custom css will be overridden. This is the major drawback of choosing this way to customize a theme. This can be solved by using the theme inheritance. Theme Inheritance Theme Inheritance is the best way of modifying or customizing a theme and can be accomplished with a few setups. The basic idea is that a theme is defined as the base-theme that you are inheriting from, and only some bits can be modified and the rest of the things is handled by the base theme. The advantage of using theme inheritance is that the customized inherited theme will not be directly impacted whenever the base theme is updated. To accomplish this, you need to follow these steps. To store your new theme, create new folder called mytheme/ inside /user/themes/ folder. Next you need to create a new theme YAML file called mytheme.yaml under the newly created /user/themes/mytheme/ folder with the following content. streams: schemes: theme: type: ReadOnlyStream prefixes: ””: – user/themes/mytheme – user/themes/antimatter Create a YAML file called blueprints.yaml under the /user/themes/mytheme/ folder with the following content. name: MyTheme version: 1.0.0 description: “Extending Antimatter” icon: crosshairs author: name: Team Grav email: [email protected] url: http://getgrav.org We will now understand how to define a theme blueprints.yaml that consists of basic elements. More details can be provided for form definitions to control your form functionalities. The blueprints.yaml file can be examined for more details on this. In your user/config/system.yaml file edit pages: theme: option to change your default theme to new theme as shown below. pages: theme: mytheme Now new theme is created and Antimatter will be the base theme for this new mytheme theme. If you want to modify specific SCSS we need to configure SCSS compiler so that it looks your mytheme theme first and secondly the Antimatter theme. It uses the following settings − First copy the template.scss file which is placed in the antimatter/scss/ folder and paste it in the mytheme/scss/ folder. This file will contain all the @import calls for various files like template/_custom.scss and sub files. The load-path points to antimatter/scss/ folder which contains large number of SCSS files. To run the SCSS compiler, you need to provide load-path to it as shown below. scss –load-path ../antimatter/scss –watch scss:css-compiled Now, create a file called _custom.scss under mytheme/scss/template/. This file will contain all your modifications. When the custom SCSS file is changed, automatically all the SCSS files will be compiled again into template.css which is located under the mytheme/css-compiled/ folder and then the Grav references this accurately. Print Page Previous Next Advertisements ”;

Grav – Development

Grav – Development ”; Previous Next You can build Grav with different types of Development such as Grav Core, Grav Plugins, Grav Skeleton and Grav Themes. Grav Core Grav is a modern CMS in which writing content is simple and building pages is more friendly and intuitive. The Grav core specially talks about the system folder which controls everything about Grav and represents the qualities of Grav workflow and life cycle. It focuses mainly on pages which can be written in good manner. It focuses on your content and turns your content into navigable site. Grav Plugins Plugin is a piece of software that provides enhanced functionality which was not originally completed by Grav”s core functionality. There are many plugins available on the Grav repository which shows functionality on the site. Consider the following points relating to Grav plugins − Grav itself is super-lean which adds only needed plugins for your site. There is no need to wait for adding extra functionality that you want. To achieve this, just create a plugin to extend Grav. Plugins are so flexible and powerful which display site map, blog archives, search engine, provides breadcrumbs etc. Grav Skeletons The Grav skeleton describes a sample site which contains Grav Core, plugins, pages, theme all together. The initial idea behind Grav was to build site very easily. All that is needed to develop a site is placed in a user folder. The skeleton of Grav comes with various dependencies such as plugins, theme, etc. and stored in a package which can be unzipped. Grav Themes Grav supports different types of themes ehich form an integral part of a Grav site. When you install Grav on your system, it comes with Antimatter theme. Most of the themes come with skeleton package or with sample pages. You can see the sample pages under the user/pages folder which provides similar experience as the skeleton package. The installed theme requires appropriate twig templates for your pages. A theme is combination of theme and content which is equal to the entire site design. You can create your own twig templating engine according to your design. Theme/Plugin Release Process You can notice some of the points for your created theme or plugin which is added in the Grav repository. It is an open source which is licensed by MIT. It has the README.md file which specifies installation process and configuration of the project. It contains blueprints.yaml file which includes information about resource and can be found at the root of each plugin and theme. Contains CHANGELOG.md file which includes version of the theme or plugin and displays the information whenever changes made to the file. Creating releases are better ways to place your completed theme or plugin on the GitHub. If there is no release, then you won”t find your plugin or theme. Add the details about your plugin or theme and do a test to ensure its working functionality. ChangeLog Format The changelog format is written in the Markdown syntax which keeps the content and visual display separate. It uses simple CSS which is displayed in the following format. # vX.Y.Z ## 01/01/2015 1. [](#new) * New features added * Another new feature 2. [](#improved) * Improvement made * Another improvement 3. [](#bugfix) * Bugfix implemented * Another bugfix …repeat… GitHub Setup GitHub is a largest open community which shares your projects with the users, get feedback and contribute to the repositories hosted on GitHub. Clone the URL of external repository into single project folder on your local system. You can clone the external Git repository to new repository as shown in the steps below. Open the command line and create folder called “my_project”. $ mkdir my_project $ cd my_project $ mkdir Grav $ cd Grav $ git clone https://github.com/getGrav/Grav.git $ git clone https://github.com/Grav_project/Grav-plugin-error.git $ git clone https://github.com/ Grav_project /Grav-plugin-problems.git $ git clone https://github.com/ Grav_project /Grav-theme-antimatter.git Here Grav_project is a repository where you will get all the files and folders related to this repository will be saved in the /my_project/Grav folder. Grav includes dependencies such as error plugin, problems plugin and Antimatter theme. You can setup the test site for Grav by using the bin/Grav new-project command. We need to develop the cloned code from the web root. So we have to symbolically link the related parts using -s flag to the bin/Grav new-project command. Create one configuration file in a new folder called .Grav/ to find the repository by using the command and you need to create this under the root directory. $ cd $ mkdir .Grav $ vi .Grav/config Navigate to your Grav folder and setup the symbolically linked site using -s flag. $ cd ~/Projects/Grav/Grav $ bin/Grav my-project -s ~/www/Grav Here, www is a root folder and Grav is the location where you”re going to create the test site. Print Page Previous Next Advertisements ”;

Grav – Lifecycle

Grav – Lifecycle ”; Previous Next In this chapter, we will understand the lifecycle of Grav. Grav Lifecycle determines how Grav processes in order to extend the Grav via Plugins. The following diagram shows the flow of Grav lifecycle process. The following four steps from the Grav lifecycle − PHP Version Loader class is initialized Obtain Grav Instance Call Grav Process PHP Version It checks the version of PHP to make sure that we are running the PHP version above 5.4.0. Loader class is initialized In the second step, the class loader gets initialized. Obtain Grav Instance If no instance exists, then it calls the load() method and adds Grav. It initializes the debugger value and adds to the debugger. It registers the log and the error handler. It adds the uri, task, events, cache, session, plugins, themes, twig, taxonomy, language, pages, assets and base url. It registers the stream and the config handler. Call Grav Process It initializes the configuration, Uri object, error handler, debugger and session. After initializing, it starts buffering the output. It initializes the timezone and the plugins and fires the onPluginsInitialized event. Next it initializes the theme and fires the onThemeInitialized and onTask[TASK] events. It initializes the assets and fires the onAssetsInitialized event. It initializes the twig with the following actions − Based on the configuration, it sets the twig template paths. Handles the available language templates. Next it fires the onTwigTemplatePaths event. Loader chain and twig configuration is loaded. Fires onTwigInitialized event. It loads the twig extensions and fires onTwigExtensions event. It sets the standard twig variables. Next it initializes the pages. It calls the buildPages() method. If cache is good, then it loads pages from cache. If cache is not good then the recurse() method is called. onBuildPagesInitialized event is fired in the recurse() method. If a file is found as .md, the following actions are performed − To load the file details, the init() method is called. It sets the filePath, modified and id. The header() method is called to initialize header variables. The slug() method is called to set the URL slug. The visible() method is called to set the visible state. Based on the folder that starts with _(underscore), modularTwig() is set. It later fires the onPageProcessed event. recurse() the children if a folder is found. It fires the onFolderProcessed event. calls the buildRoutes() method. For all pages the taxonomy is initialized The route table is built for fast lookup. The events onPagesInitialized and onPageInitialized gets fired. Debugger CSS/JS is added to the assets. Using Twig”s processSite() method, we get the output. The event onTwigSiteVariables is fired. Gets the output of the page. When page is not found or not routable then the event onPageNotFound is fired. All Twig variables are set on twig object. Template name is set depending upon the file/header/extension information. render() method is called. Returns the file format in HTML It fires the onOutputGenerated event. Set the HTTP headers. Displays the output The output buffer is flushed to the page. The event onOutputRendered will get fire. Closes the connection to client. Lastly, it fires the onShutDown event. When the content() method is called on page, then the following lifecycle occurs. The event onPageContentRaw will get fire. According to the Markdown and Twig settings, it processes the page. It fires the onPageContentProcessed event. Print Page Previous Next Advertisements ”;

Grav – Blueprints

Grav – Blueprints ”; Previous Next Blueprints are metadata information about the resource (source of information). It serves two purposes − First is the resource identity itself. Second is regarding the forms. This complete information is saved in the blueprints.yaml file present in each plugin or theme. Resource Identity In blueprints.yaml file identity is defined for each themes and plugins. Resource will not be added in Grav repository until blueprints are not formatted and compiled perfectly. Blueprints Example name: plugin name version: 0.6.0 description: Adds an advanced plugin to manage your site icon: empire author: name: Team Grav email: [email protected] url: http://getGrav.org homepage: https://github.com/getGrav/Grav-plugin-assets keywords: assets, plugin, manager, panel bugs: https://github.com/getGrav/Grav-plugin-assets/issues readme: https://github.com/getGrav/Grav-plugin-assets/blob/develop/README.md license: MIT dependencies: – form – email – login form: validation: loose fields: Basics: type: section title: Basics underline: false enabled: type: hidden label: Plugin status highlight: 1 default: 0 options: 1: Enabled 0: Disabled validate: type: bool The following few properties are optional and some are used to give your identity and resource. Sr.No. Properties & Description 1 name* Mention the name of the resource. 2 version* Specifies the version of the resource. 3 description* Gives brief description about the resource. It should not exceed more than 200 characters. 4 icon* Specifies an icons library for developing a new theme or plugin. 5 author.name* Specifies the name of the developer. 6 author.email (optional) Specifies the email address of the developer. 7 author.url (optional) Specifies the URL homepage of developer. 8 homepage (optional) Specifies the allocated Url for homepage for your resource. 9 docs (optional) Specifies the documentation link which you have written for your resource. 10 demo (optional) Specifies the link of demo resource. 11 guide (optional) Specifies the link of how to guide or tutorials for your resource. 12 keywords (optional) Specifies the list of keywords that are related to your resource. 13 bugs (optional) Specifies the Url where issues or bugs can be reported. 14 license (optional) Specifies your resource license i.e. MIT, GPL etc. 15 dependencies (optional) Specifies the name of the dependencies that are required for plugins or themes. The following is an example of the login plugin blueprint − name: Login version: 0.3.3 description: Enables user authentication and login screen. icon: sign-in author: name: Team Grav email: [email protected] url: http://getGrav.org keywords: admin, plugin, login homepage: https://github.com/getGrav/Grav-plugin-login keywords: login, authentication, admin, security bugs: https://github.com/Getgrav/Grav-plugin-login/issues license: MIT Forms You can fill the blueprints.yaml file with forms if you want themes or plugins to have options directly configurable from the admin interface. The part of this resource can be configured via the Admin Plugin, which is defined by the Forms metadata. The following is an example of the Archives Plugin archives.yaml file. enabled: true built_in_css: true date_display_format: ”F Y” show_count: true limit: 12 order: by: date dir: desc filter_combinator: and filters: category: blog These are the plugin”s default settings. To configure them without the use of Admin plugin the user has to copy this file in the /user/config/plugins/archives.yaml folder and make the changes. You can provide the archives.yaml file correctly; you can choose to change the settings in the admin interface from the users. After saving the changes, it will automatically get written to <your_folder_name>/user/config/plugins/archives.yaml. The blueprint.yaml file of the Archives Plugin contains the structure as shown below − name: Archives version: 1.3.0 description: The **Archives** plugin creates links for pages grouped by month/year icon: university author: name: Team Grav email: [email protected] url: http://getGrav.org homepage: https://github.com/getGrav/Grav-plugin-archives demo: http://demo.getGrav.org/blog-skeleton keywords: archives, plugin, blog, month, year, date, navigation, history bugs: https://github.com/getGrav/Grav-plugin-archives/issues license: MIT form: validation: strict fields: enabled: type: toggle label: Plugin status highlight: 1 default: 1 options: 1: Enabled 0: Disabled validate: type: bool date_display_format: type: select size: medium classes: fancy label: Date Format default: ”jS M Y” options: ”F jS Y”: “January 1st 2014″ ”l jS of F”: “Monday 1st of January” ”D, m M Y”: “Mon, 01 Jan 2014″ ”d-m-y”: “01-01-14″ ”jS M Y”: “10th Feb 2014″ limit: type: text size: x-small label: Count Limit validate: type: number min: 1 order.dir: type: toggle label: Order Direction highlight: asc default: desc options: asc: Ascending desc: Descending Following are the form elements present in the archive.yaml. Toggle enabled: type: toggle label: Plugin status highlight: 1 default: 1 options: 1: Enabled 0: Disabled validate: type: bool Select date_display_format: type: select size: medium classes: fancy label: Date Format default: ”jS M Y” options: ”F jS Y”: “January 1st 2014″ ”l jS of F”: “Monday 1st of January” ”D, m M Y”: “Mon, 01 Jan 2014″ ”d-m-y”: “01-01-14″ ”jS M Y”: “10th Feb 2014” Text limit: type: text size: x-small label: Count Limit validate: type: number min: 1 The root element Enabled, date_display_format and limit are the options. The field present in this root element determines the type, size, label, default and options. Depending upon the field type, the other fields can change; for example, the select field requires options list. Order direction order.dir: type: toggle label: Order Direction highlight: asc default: desc options: asc: Ascending desc: Descending This field consists of the nested options. There are many field types that can be used in plugins/admin/themes/Grav/templates/forms/fields. As we can see in the archive.yaml file, the form validation is set to strict. When validation is set as strict, then for all the options you have to add the blueprints form, otherwise it will pop up an error while saving. The form.validation can be set as loose when you want to customize only the two fields to admin interface. The following table gives a brief explanation of the fields relating to the above form elements. Sr.No. Field & Description 1 Type Indicates the field type. 2 Size Specifies the size of the field. 3 Label Specifies label to the field. 4 Validate It validates the type of the field and the minimum length entered in the field. 5 Default Sets default fields. 6 Options Specifies the list of options. 7 Classes Specifies the class for the field. Form Fields available in the admin There are many

Grav – YAML Syntax

Grav – YAML Syntax ”; Previous Next YAML stands for YAML Ain”t Markup Language which includes human readable content and often used in configuration files, blueprints (metadata information about resource) and page settings. Features Following are the features of YAML − Compared to XML or JSON, YAML is less complex and provides same features. It provides configuration settings without the need to learn complex code types such as CSS, JavaScript or PHP. YAML describes data and content of the YAML file which can be easily translated to multiple language types. Basic Rules of YAML There are some basic rules of YAML which are used to reduce the ambiguity in multiple languages and editable programs. You must end the YAML files with .yaml extension. YAML must be case-sensitive. YAML doesn”t support the use of tabs. Instead of tabs, it uses spaces which are not supported universally. Basic Data Types of YAML YAML supports some basic data types which can be used with programming languages such as − Scalars − strings or numbers. Sequences − arrays or lists. Mappings − hashes or dictionaries. Scalars Scalars are the basic data types that use strings or numbers on the pages to work with the data. It may be a boolean property (either yes or no), integer value such as 2 or string of text such as word or sentence or title of the website. For instance − string: “Grav” integer: 10 float: 10.5 boolean: true Sometimes scalars come with unquoted values like integer, float or Boolean. The string value uses punctuation which comes with single or double quotation marks which uses escaping to specify ASCII and Unicode characters. Sequences YAML represent sequences in the form of arrays or lists. It defines each item with opening dash (-) placed in the list as shown below. For instance − – Apple – Orange – Grapes Suppose if you want to define nested sequence with the sub items, and then place a single space before each dash in the sub items. For instance − – – Apple – Orange – Grapes If you want nested sequence within the nested list, then add some levels as shown below − For instance − – – – Apple – Orange – Grapes Mappings It is a way of defining keys along with the values. For example, you can assign some value to a specific element as − Sports: cricket Here the value is “cricket” that maps with the key called “Sports”. You can use this mapping with the sequence to specify the list of items for cricket; for example, we will define some player names for the value “cricket” making names as child and Sports: cricket as parent. Sports: cricket – Sachin Tendulkar – Rahul Dravid – M S Dhoni Print Page Previous Next Advertisements ”;