Grav – Server Error ”; Previous Next Server error occurs due to misconfiguration of Grav. When server has encountered an internal error or something happened unexpectedly, then Grav is unable to serve and recover the page. If the server is running in production mode, to hide the information from the user, a server error message occurs. All the error messages are logged in Grav.log file present under the folder <your_folder_name>/logs/Grav.log. Following are some of the reasons that may cause server error − Out-of-date configuration Incorrect file permission Invalid formatted configuration files Changes in file system not known to the Grav Out-of-date configuration You can flush the cache to check whether the configuration is up to-date or not. Use the following command to flush the cache. bin/Grav clear-cache Installation and configuration issues The issues for installation and configuration are − Configuration Issues Installation Issues System Requirement File Permissions Print Page Previous Next Advertisements ”;
Category: grav
Grav – Debugging & Logging
Grav – Debugging & Logging ”; Previous Next Debugging & logging information is very necessary while developing the themes and plugins. Grav uses the debugging information by using some features as described below. PHP Debug Bar Grav comes with a tool called the Debug Bar to display debugging information. By default, this feature is disabled. You can turn it on globally or use system.yaml for your development environment. debugger: enabled: true twig: true shutdown: close_connection: true After enabling the debugger true, you can view the following debug bar as shown below. Click on the G symbol which is present at the left side of the corner. In the debug bar, you can view the overall memory usage and the time used for processing at the corner on the right side. It also consists several tabs that provide information in detail. In the Messages tab, you can view the messages which will help you to debug your Grav development process and the information will get post to this tab from the code via $Grav[”debugger”]→addMessage($my_var). In Timeline tab, you can view the breakdown of Grav timing. Error Display It displays the error messages regarding the block or page at a runtime. In Grav, you can easily identify the error and resolve the errors very quickly. Following are the error messages that will get displayed on your screen as shown in the following screenshot. In the user/config/system.yaml file, you can disable the error page by setting it to false. errors: display: false log: true Logging Logging is used for reporting errors and status information from libraries and application. In Grav, there are a few important logging features as specified below. $Grav[”log”]->info(”My informational message”); $Grav[”log”]->notice(”My notice message”); $Grav[”log”]->debug(”My debug message”); $Grav[”log”]->warning(”My warning message”); $Grav[”log”]->error(”My error message”); $Grav[”log”]->critical(”My critical message”); $Grav[”log”]->alert(”My alert message”); $Grav[”log”]->emergency(”Emergency, emergency, there is an emergency here!”); All logging messages will get displayed in the Grav.log file which is present under the folder <your_folder_name>/logs/Grav.log Print Page Previous Next Advertisements ”;
Grav – Event Hooks
Grav – Event Hooks ”; Previous Next In this chapter, we will study about Event Hooks in Grav. In Plugins chapter you will see, the logic of plugin was included in two methods. The methods are onPluginsInitialized and onPageInitialized; these methods are similar to event hooks. To know more and control the power of Grav plugins, you need to check the availability of event hooks. The event hooks have a direct relationship with Grav from beginning to end. You must be aware of the order in which the hooks are called and what is usable at the time of these calls. The following table lists out the core Grav event hooks that are activated during the processing of a page. Sr.No. Event & Description 1 onFatalException You can fire this event at any moment, if PHP gives a fatal exception. The Problem plugin uses this to manage displaying a list of full explanation, for why the Grav delivers the fatal error. 2 onPluginsInitialized This is the first plugin event that is usable in Grav. The following objects have been introduced as mentioned below − Uri Config Debugger Cache Plugins 3 onAssetsInitialized This specifies that the assets manager is loaded and ready to use and manage. 4 onPageNotFound If you found an unexpected page, you can dismiss this event. Presently, the error plugin is used to specify a 404 error page. 5 onPageInitialized This specifies the requested page by a URL which is loaded into the Page object. 6 onOutputGenerated This specifies the output process by the Twig templating engine. Presently, it is just a string of HTML. 7 onOutputRendered This is an output process, which is sent to the display. 8 onShutdown This is a new and very powerful event that allows you to perform actions. This is done after Grav has completed processing and the connection to the client is closed. This individual action does not require any interaction with the user, in result can affect the performance. It includes the user tracking and jobs processing. 9 onBeforeDownload This is a new event which passes into the event object that contains a file. It allows the users to perform logging, grant and ignore permission to download the mentioned file. Twig Event Hooks Twig has its own collection of event hooks to use as mentioned below. Sr.No. Event & Description 1 onTwigTemplatePaths The template path”s base location is set on the Twig object. This event is used to add other locations where Twig will search for template paths. 2 onTwiglnitialized It initialize the Twig templating engine. 3 onTwigExtensions It specifies the core twig extensions is ready to use. This event hook allows you to add your own Twig extension. 4 onTwigPageVariables This Twig process permits you a page directly, i.e. you can locate process:twig:tru in a page of YAML headers. Here you can add any variables to Twig and should accessible to twig during this process. 5 onTwigSiteVariables In this process, you will see the full site template in order wise by Twig methods. Further, you can add any variable to Twig during this process. Collection Event Hooks The following table lists out a collection event hook. Sr.No. Event & Description 1 onCollectionProcessed In this section, once the process is completed you can control a collection. Page Event Hooks The following table lists out a collection of page event hooks. Sr.No. Event & Description 1 onBuildPagesInitialized This event is useful for plugins to control the content and cache the results. Once this event is activated the pages will be recycled. This occurs, when the cache has expired or needs refreshing. 2 onBlueprintCreated This event helps in processing and managing forms. 3 onPageContentRaw In this process, when a page is found, headers are fixed, but content will not be fixed. You will see every page is fired in the Grav system. If you have cleared the cache or clearing the cache this event occurs. 4 onPageProcessed Once a page is tested and fixed, every page is dismissed in the Grav system. Performance doesn”t matter in this case, since it will not play on a cached page. 5 onPageContentProcessed You can see this event is dismissed, once the page”s content() technique has fixed the page content. This event is useful in case, you want to perform actions on the post-fixed content but make sure that the results are cached. 6 onFolderProcessed Once a folder is tested and fixed, every folder is dismissed in the Grav system. Performance doesn”t matter in this case, since it will not play on a cached page. Print Page Previous Next Advertisements ”;
Grav – Plugin Basics
Grav – Plugin Basics ”; Previous Next In this chapter, we will understand how a plugin works as an additional functionality in Grav. Plugin is a piece of software that provides additional functionality which was not originally completed by Grav”s core functionality. Grav Plugin can be uploaded to expand the functionality of the site. Plugins are used to make your work easier. The Dependency Injection Container helps access the key objects in Grav. In the entire life cycle with the help of Grav”s event hooks, we can manipulate Grav as per our need and can also access whatever the Grav knows. We will study in detail about the Grav event hooks in the Chapter Grav – Event Hooks. Dependency Injection is a software design pattern in which components are given their dependencies instead of hard coding them within the component. There are many free plugins available for Grav which are used for displaying blog archive, sitemap, search engine, form, light slider and many more. You can download the plugins from here. In the Plugin folder, you can store the plugins with a unique name; the name should be related to the function of the plugin and it should not contain any capital letter, underscore or space. We will study about how to use plugin in the Chapter Grav – Plugin Tutorials . Powerful Plugins are easy to write, flexible and powerful. There are 46 plugins, and have the features that include displaying a sitemap, provides breadcrumbs, display blog archives etc. Essentials When Grav is installed on your system, you can see there are two plugins inside the <your_folder_name>/user/plugins folder. Error plugin Problem plugin Error Plugin − It is used to display the HTTP errors i.e. 404 Page Not Found when there is no request page available for the given URI. Problem Plugin − It is used for detecting issues regarding the permissions, hosting setup and missing folders. It is useful when you install new Grav for identifying such issues. Print Page Previous Next Advertisements ”;
Grav – Overview
Grav – Overview ”; Previous Next Grav is a flat-file based content management system. This system does not use database to store the content, instead it uses a text (.txt) file or a markdown (.md) file to store the content. The flat-file part refers to the readable text and it handles the content in an easy way which can be simple for a developer. Grav was developed by the Rocket Theme team. It runs on PHP and is an open-source CMS like Joomla, WordPress or Drupal. Why Grav? Grav is now the fastest flat-file content management system. It is easier to publish and manage content with Grav. It allows a developer to handle content very easily by storing content in files (such as text or markdown files) rather than in database. Grav helps you build a simple, manageable and a quick site. It costs less than the database driven CMS and is useful with I/O for file handling, when you don”t have enough resources. Features of Grav It is a fast, easy and powerful flat-file web platform. It is used to build websites with no extra tools or html knowledge. It uses text file or markdown file to store the content. It doesn”t use database, so this mitigates the instances of bottlenecking. It uses PHP based template provided by Twig which is parsed directly into PHP that makes it fast. Advantages It is not based on database CMS, so it”s very easy to install and will be ready to use when you upload the files to the server. It uses Markdown text files to make things easy. Using this, the content is dynamically converted to HTML and displayed in the browser. In case of security, Grav doesn”t have admin area and database. So there is no chance of hacking into account or in the database to access the important data. You can easily backup all the files to keep the backup copy of your website, since there is no database to backup. It is a piece of software which doesn”t require more time to learn. Disadvantages You might come across instances where unauthorized users may access your content from the files directly as there is no database for the files. It is difficult to build complex websites using Grav CMS. Print Page Previous Next Advertisements ”;
Grav – Useful Resources
Grav – Useful Resources ”; Previous Next The following resources contain additional information on Grav. Please use them to get more in-depth knowledge on this. Gravitation 20 Lectures 3 hours Tutorialspoint More Detail Class 9th – Gravitation 31 Lectures 4 hours Tutorialspoint More Detail How to Develop Gravitas: Be the Voice of Wisdom & Influence 25 Lectures 1 hours Mike Clayton More Detail Print Page Previous Next Advertisements ”;
Grav – Quick Guide
Grav – Quick Guide ”; Previous Next Grav – Overview Grav is a flat-file based content management system. This system does not use database to store the content, instead it uses a text (.txt) file or a markdown (.md) file to store the content. The flat-file part refers to the readable text and it handles the content in an easy way which can be simple for a developer. Grav was developed by the Rocket Theme team. It runs on PHP and is an open-source CMS like Joomla, WordPress or Drupal. Why Grav? Grav is now the fastest flat-file content management system. It is easier to publish and manage content with Grav. It allows a developer to handle content very easily by storing content in files (such as text or markdown files) rather than in database. Grav helps you build a simple, manageable and a quick site. It costs less than the database driven CMS and is useful with I/O for file handling, when you don”t have enough resources. Features of Grav It is a fast, easy and powerful flat-file web platform. It is used to build websites with no extra tools or html knowledge. It uses text file or markdown file to store the content. It doesn”t use database, so this mitigates the instances of bottlenecking. It uses PHP based template provided by Twig which is parsed directly into PHP that makes it fast. Advantages It is not based on database CMS, so it”s very easy to install and will be ready to use when you upload the files to the server. It uses Markdown text files to make things easy. Using this, the content is dynamically converted to HTML and displayed in the browser. In case of security, Grav doesn”t have admin area and database. So there is no chance of hacking into account or in the database to access the important data. You can easily backup all the files to keep the backup copy of your website, since there is no database to backup. It is a piece of software which doesn”t require more time to learn. Disadvantages You might come across instances where unauthorized users may access your content from the files directly as there is no database for the files. It is difficult to build complex websites using Grav CMS. Grav – Installation In this chapter, we will understand the installation of Grav. We will discuss the software requirements for Grav and also how to download it. Software Requirements for Grav Let us now understand the software requirements for Grav. Web Server WAMP (Windows) LAMP (Linux) XAMP (Multi-platform) MAMP (Macintosh) Nginx Microsoft IIS Operating System − Cross-platform Browser Support − IE (Internet Explorer 8+), Firefox, Google Chrome, Safari, Opera PHP Compatibility − PHP 5.4 or higher Text Editors Sublime Text (Mac / Windows/ Linux) Atom (Mac / Windows) Notepad ++ (Windows) Bluefish (Mac / Windows/ Linux) Download Grav Click on this link https://getgrav.org/downloads and follow the steps as shown in the screenshot given below to download Grav. Unzip the downloaded Grav file into your web server. Setup Wizard Installation of Grav is a very simple process. Follow the steps given below for Grav setup. Download the zip file and extract it to your web server or local host. Rename the folder from its current name that you want to use to refer to your site. Open your browser and navigate to localhost/<your_folder_name>, you will be redirected to a screen which shows you have installed Grav successfully as in the following screenshot. Grav comes with a sample page that helps you get started. In the above screenshot, you can see the home link which has displayed a sample page. Grav – Pages In this chapter, let us study about Grav Pages. Pages can be defined as building blocks of the site. Pages combine contents and navigations; this makes work easier even for the inexperienced users. To begin with, let us know how to create a simple page. All user contents will be stored under user/pages/ folder. There will be only one folder called 01.home. The numeric portion of the folder is optional; it expresses the order of your pages (for example, 01 will come before 02) and explicitly informs Grav that this page should be visible in menu. Let us now see how to create a new page. Step 1 − Create a folder under /user/pages/; for example, 02.about as shown in the following screenshot. Step 2 − Create a file called default.md inside the newly created 02.about folder with the following content. — title: About Us — # About Us Page! This is the body of **about us page**. The above code uses some Markdown syntax explained briefly below. You can study in detail about Markdown in Markdown chapter. The content between the — indicators are the Page Headers. # or hashes syntax in Markdown indicates a title which will be converted to <h1> header in HTML. ** markers indicates bold text or <b> in HTML. Step 3 − Reload your browser and you can see new page in menu as shown in the following screenshot. Page Types Grav Pages supports 3 types of pages − Standard Page. Listing Page. Modular Page. Standard Page Standard Pages are most basic type of pages such as blog post, contact form, error page etc. By default, a page is considered as a Standard Page. You are welcomed by a Standard Page as soon as you download and install the Base Grav package. You will see the following page when you install Base Grav package. Listing Page Listing Page is an extension of a standard page which has a reference to a collection of pages. The easiest way to set up the listing page is to create child pages below the listing page. A blog listing page is a fine example for this. A sample Blog Skeleton with Listing Page can be found in the Grav Downloads. A sample one is shown in the following screenshot.
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