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 ”;
Category: grav
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 ”;
Grav – Administration Panel Pages ”; Previous Next In this chapter, we will understand how Administration Panel Pages work in Grav. Pages give an easy access to create, edit or delete the content to your site. In the administrative panel pages, you can view the list of pages created for your site and you can also create new modular or non-modular page for your site. Adding New Pages You can see that there are three buttons present at the top of the pages administrative panel as shown in the following screenshot. Back − This takes back to the dashboard of administrative page. Add Page − This creates a new non-modular content. Add Modular − This creates new modular content. Add Page It creates non modular page for your site which consists of various fields while adding page to your site such as Title, Folder Name, Parent root etc. When you click on the Add Page button, a popup window appears as shown below − It contains the following fields − Page Title − Here you enter the title of the page. Folder Name − This is to enter the folder name for the page or the name will get generated automatically once you enter the title. Parent Page − This sets the parent page for your newly created page. Page File − This displays the selected theme template to the page. Visible − This makes the page visible in the navigation bar by setting it to auto, yes or no. After filling all the information in the fields, click on the Continue button. It will redirect you to the page editor. Add Modular Page Modular page enables to create a single page from its child pages. It has the ability to build complex one page layouts from modular content pages. When you click on the Add Modular button, a popup window appears as shown below − The window contains the following fields − Page Title − Here we enter the title of the modular page. Folder Name − This is to enter the folder name for page or the name gets generated automatically once you enter the title. Page − This sets the parent page for your newly created modular subpage. Modular Template − This selects the particular template to be displayed for your modular pages. After filling all the information in the fields, click on the Continue button. It will redirect you to the page editor. Pages List This displays the list of the pages which are created for the site. Here you can easily access your created pages and edit it. Clicking on any title of the page, it will redirect you to the page editor for editing purpose. The X icon at the right side of the page is used to delete the page. The Filter box is used to find the page you are searching for. It filters the pages according to the types so that only pages like modular, visible and/or routable are displayed in the list. The search box is used to find page when you know the exact name of that page. When you directly hover on the icons on the left side of page, then it will show you the current status, i.e., Page . Routable . Visible . Published, it means that the page is visible via the URL and will be displayed in the navigation menus. When you click on the page which is displayed in the list, you will see the following screen. In the above screen, you have options to edit the page, add content or add images to your page. The Options tab consists of publishing, taxonomies and site map options which we study in Page Editor Options chapter. The Advanced tab contains the advanced options of the page like setting, ordering and overriding which will be covered in the Page Editor Advanced chapter. Print Page Previous Next Advertisements ”;
Grav – Admin Introduction
Grav – Admin Introduction ”; Previous Next Grav Administration Panel plugin is a web graphical user interface (GUI) for Grav. It can easily create and modify pages. It is an optional plugin and to work effectively Grav does not depend on this totally. The Admin provides limited views for easy usage of Grav. Features Following are the features of administration panel − Enable or disable the plugins present in the plugin manager list. You can create, edit, copy and delete the pages easily. List of latest page updates gets displayed on the Dashboard. Latest available updates can be viewed easily by just one click. Find the particular pages from the list by using search box. It consists of functionality of the forget password. Media files can be uploaded by drag-n-drop method. Allows editing via yaml or forms in normal and expert modes. Dashboard consists of site activity, latest page updates and maintenance status. It consists of Ajax powered backup and clear-cache capabilities. It consists of site and system configuration management. New plugins and themes installation powered by GPM. Automatic password encryption feature is provided during user login. It provides code editor that highlights powerful syntax with instant Grav-powered preview. Installed theme listing and configurations can be done by using Theme manager. It also manages the logged-in users. Installation To access the admin plugin, we need to run the latest Grav. You can run the following command in the CLI (command line interface). $ bin/gpm selfupgrade -f The selfupgrade is used to update Grav to the latest version available. -f is used to refresh GPM(Grav Package Manager) index. We need to install the admin, form, email and login plugins to make your admin plugin run properly. As all plugins have dependencies, you need to agree when it prompts you to install other plugins while installing the admin plugin; these plugins are available via GPM (Grav Package Manager). We”ll study more about GPM in the chapter Grav – GPM. Following command is used to install the admin plugin using the command prompt. $ bin/gpm install admin Manual Installation We can install the administration panel manually by downloading the following plugins individually − admin form login email After downloading all the plugins, extract all the zip files and store in the <your_folder_name>/user/plugins folder. In the Plugin folder, you can store plugins with a unique name; the name should be related to the function of the plugin. The folder can be renamed as admin/, email/, form/ and login/. It is necessary to store all the four plugins in the Plugin folder together; otherwise the admin panel won”t work properly. Creating User We can create the user account by using the command line interface. Use the following command to create a user account. $bin/grav newuser Otherwise, you can also create user account manually by writing the following lines of code − email: [email protected] access: admin: login: true super: true site: login: true fullname: ”Tutorials Point” title: tp password: ”Password” Save the above lines in the <your_folder_name>/user/account/admin.yaml file. The name which you have used to save your above code will be the username for your login, i.e., admin. You can edit the email, fullname, title and the password according to your requirements. Usage You can access the administration panel by pointing your browser to the localhost/<your_folder_name>/admin and you will get a screen as shown below. You can set the username and password in yaml file as specified in the creating user section. Print Page Previous Next Advertisements ”;
Grav – Markdown Syntax
Grav – Markdown Syntax ”; Previous Next Markdown syntax is defined as writing plain text in an easy to read and easy to write format, which is later converted into HTML code. Symbols like (*) or (`) are used in markdown syntax. These symbols are used to bold, creating headers and organize your content. To use Markdown syntax, you must create a .md file in your user/pages/02.mypage folder. Enable Markdown Syntax in your userconfigsystem.yaml configuration file. There are many benefits of using Markdown syntax, some of them are as follows. It is easy to learn and has minimum characters. When you use markdown there are very few chances of having errors. Valid XHTML output. Your content and visual display is kept separate so that it does not affect the look of your website. You can use any text editor or markdown application. In the following sections, we will discuss the main elements of HTML that are used in markdown. Headings Each heading tag is created with # for each heading, i.e., from h1 to h6 the number of # increases as shown. #my new Heading ##my new Heading ###my new Heading ####my new Heading #####my new Heading ######my new Heading Open the .md file in a browser as localhost/Grav/mypage; you will receive the following result − Comments You can write comments in the following format. <!— This is my new comment –> Open the .md file in a browser as localhost/Grav/mypage; you will receive the following result − Horizontal rules Horizontal rules are used to create a thematic break in between paragraphs. You can create breaks between paragraphs using any of the following methods. ___ − Three underscores — − Three dashes *** − Three asterisks Open the md file in a browser as localhost/Grav/mypage; you will receive the following result − Body Copy Body copy can be defined as writing text in normal format in markdown syntax, no (p) tag is used Example It is a way of writing your plain text in an easy to read and write format, which later gets converted into HTML code. Open the .md file in a browser as localhost/Grav/mypage; you will receive the following result − Emphasis Emphasis are the writing formats in markdown syntax that are used to bold, italicize or strikethrough a portion of text. Let us discuss them below − Bold A portion of text can be made bold using two (**) signs at either sides. Example The newest articles from **Advance Online Publication (AOP)** and the current issue. In this example, we have to show ‘Advance Online Publication (AOP)’ word as bold. Open the .md file in a browser as localhost/Grav/mypage, you will receive the following result − Italics Use “_” (underscores) sign at either sides of the word to italicize the text. Example The newest articles from _Advance Online Publication_ (AOP) and the current issues. In this example, we have to italicize “Advance Online Publication” (AOP) word. Open the .md file in a browser as localhost/Grav/mypage. This will give you the following result − Strikethrough Use two “~~” (tildes) on either sides of the word to strikethrough the word. Example The newest articles from ~~Advance Online Publication~~ (AOP) and the current issues. In this example, we have to strike “Advance Online Publication” (AOP) word. Open the .md file in a browser as localhost/Grav/mypage. This will give you the following result − Blockquote To create a block quote, you must add an > sign before the sentence or the word. Example >The newest articles from Advance Online Publication (AOP) and the current issues. In this example we have used a > sign before the sentence. Open the .md file in a browser as localhost/Grav/mypage; you will receive the following result − Blockquote can also be used in the following way − >The newest articles from Advance Online Publication (AOP) and the current issues. >>> The newest articles from Advance Online Publication (AOP) and the current issues. Open the .md file in a browser as localhost/Grav/mypage; you will receive the following result − Notices Notices can be used to inform or notify about something important. There are four types of notices − yellow, red, blue and green. Yellow You must use the >>> sign before a yellow notice type that describes !Info or information. Example >>>Neurotransmitter-gated ion channels of the Cys-loop receptor family are essential mediators of fast neurotransmission throughout the nervous system and are implicated in many neurological disorders. Red Use four >>>> signs before a red notice for a Warning. Example >>>>Neurotransmitter-gated ion channels of the Cys-loop receptor family are essential mediators of fast neurotransmission throughout the nervous system and are implicated in many neurological disorders. Blue Use five >>>>> signs for a Blue notice type, this describes a Note. Example >>>>>Neurotransmitter-gated ion channels of the Cys-loop receptor family are essential mediators of fast neurotransmission throughout the nervous system and are implicated in many neurological disorders. Green Use six >>>>>> signs before a Green notice type, this describes a Tip. Example >>>>>>Neurotransmitter-gated ion channels of the Cys-loop receptor family are essential mediators of fast neurotransmission throughout the nervous system and are implicated in many neurological disorders. Open the md file in a browser as localhost/Grav/mypage; you will receive the following result − Lists In this section, we will understand how the unordered and ordered lists work in Grav. Unordered In an unordered list, bullets are used. Use *, – , +. symbols for bullets. Use the symbol with space before any text and the bullet will be displayed. Example + Bullet + Bullet + Bullet -Bullet -Bullet -Bullet *Bullet Open the .md file in a browser as localhost/Grav/mypage; you will receive the following result − Ordered Add the numbers before you list something. Example 1. Coffee 2. Tea 3. Green Tea Open the .md file in a browser as localhost/Grav/mypage. This will give you the following result − Code In this section, we will understand how the Inline and block code “fences” work
Grav – Configuration System
Grav – Configuration System ”; Previous Next In this chapter, we will study about the Configuration System in Grav”s Administration Panel. You can directly configure the settings of your site”s system with the help of the Configuration page. Furthermore, you will see a brief explanation of your server”s properties including PHP, server environment, and other several components that regulate how your site performs. The System tab allows you to modify the settings in the /user/config/system.yaml file. This affects many primary systems related features of Grav”s operation. The settings can be divided into different sections that show you different features of Grav”s performance. Below is a detailed list of the configuration sections that are displayed in the systems tab − Content In this section, you can fix the basic properties of Content handling for your site as shown below. Home Page − Specifies the home page that you want to display for your site. Default Theme − Displays the primary default theme for your site. Process − Controls how pages are processed. Can be set per-page rather than globally. TimeZone − Sets the default timezone in the server. Short Date Format − Displays the short date format. Long Date Format − Displays the long date format. Default Ordering − Pages are displayed in a list using this order. Default Order Direction − Specifies the direction of pages in a list. Default Page Count − Defines the maximum default page count in a list. Date Based Publishing − It automatically publishes posts as per the date. Events − It specifies to enable or disable the events. Disabling will cause damage to the plugin. Redirect Default Route − It defines a default route and automatically redirects to a page. Languages You can set the Multi language features in this area as shown below. Supported − It specifies list of two letter language codes separated with comma, i.e., en, fr, de. Translations Enabled − Enables the translations in Grav, plugins and extensions. Translations Fallback − It specifies the substitute supported translations, if active language is not present. Active Language in Section − You can store the active language in the area. Home Redirect Include Language − It includes language in home redirect (/en) as per the demand. Home redirect Include Route − It specifies redirecting admin home root. Set language from browser − It specifies the language from browser. Override locale − It specifies to override locale. HTTP Headers This section is used to set the HTTP Headers options. This setting helps in the browser based caching and optimization. Expires − Defines the expiry time and sets the value in seconds. Last Modified − Last modified header is set which helps to optimize proxy and browser caching. ETag − Defines the e tag header to identify a modified page. Vary Accept Encoding − You should arrange the Vary: HTTP header to Accept. This will benefit the cache on proxies. Markdown In this section, we will study about how Grav manages Markdown and its features to enable Markdown Extra. It helps the user and makes up the bulk of Grav”s page content. Markdown Extra − It specifies a default support for Markdown Extra. Auto Line Breaks − It specifies line breaks in markdown. Auto URL Links − It specifies conversion of URLs into HTML hyperlinks. Escape Markup − It specifies the markup tabs into HTML objects. Caching In this section, you can configure your site”s primary Caching functions. Grav has combined the caching feature that helps to build the fastest flat-file CMS options for the users. Caching − This specifies to switch ON/OFF globally to enable/disable Grav caching. Cache Check Method − This defines the cache check methods for File, Folder, and None. Cache Driver − This specifies to choose cache driver to the users. Auto Detect cache driver finds to be best. Cache Prefix − This specifies an identifier for part of the Grav key. Change it only if needed or else don”t change it. Lifetime − This defines the cache lifetime in seconds, 0=infinite. Gzip Compression − To increase the performance, enable Gzip compression of the Grav page. Twig Templating In this section, Grav highlights its Twig templating features. You can configure Twig caching, debug and modify tracking down setting here. Twig Caching − This specifies to control the Twig caching system. It gives the best performance, when it is enabled. Twig Debug − This defines the option not to load the Twig Debugger extension. Detect Changes − Any changes done in Twig templates, this will automatically recompile the Twig cache. Autoescape Variables − All variables are autoescapes; this can cause damage to your site. Assets This section is used to handle the assets, including CSS and JavaScript assets as shown below. CSS Pipeline − Integration of multiple CSS resources into a single file. CSS Minify − During the pipelining the CSS is minify. CSS Minify Windows Override − It is set False by default and it defines Minify Override for Windows platforms. CSS Rewrite − CSS relative URL”s are rewritten during pipelining. JavaScript Pipeline − Integration of multiple JavaScript resources into a single file. JavaScript Minify − During the pipelining the JS is minify. Enable Timestamps on Assets − Timestamps on assets are enable. Collections − Assets collection is added individually. Error Handler During the time of site development, this section is very useful to manage the Grav error reporting. Display Error − Full backtrace-style error page is displayed. Log Errors − Log errors are displayed into /logs folder. Debugger This is similar to error handling, the debugging tools are integrated in Grav to locate and troubleshoot errors. Debugger − Debugger and its settings are enabled. Debug Twig − Twig templates debugger is enabled. Shutdown Close Connection − Before calling onShutdown(), you need to close the connection. Media This section is used to manage the media content of Grav. You can configure the Image quality, file upload size and many media handling options here. Default Image Quality −
Grav – Page Editor Options
Grav – Page Editor Options ”; Previous Next In this chapter, we will study about the Page Editor options in Grav administration panel. This is a dynamic text editor that allows you to create the content of your page. In addition, you can add media files in the pages. You can see the features of the options tab as shown below. The Options tab contains two sections − Publishing Taxonomies Publishing This section is used to set the dates and time to publish and unpublish the page. You will have full control over the content to publish or unpublish and you can create the metadata values for the particular page. Following fields are present in the publishing section − Published − By default, the page is set to Yes, i.e., published. By selecting No you can unpublish the page. Date − Set the date and time for the page. Published Date − Set the date and time to publish the page automatically. Unpublished Date − Set the date and time to unpublish the page automatically. Metadata − Set the metadata values that will get displayed on all pages. Taxonomies In this section, you can display categories on the page and configure your page and its structural properties. Following fields are present in the taxonomies section. Category − It sets the categories for the page. It helps in sorting and filtering of the content. Tag − It provides information of what your page is about. It helps in organization and filtering of the content. Print Page Previous Next Advertisements ”;
Grav – Theme Variables
Grav – Theme Variables ”; Previous Next In this chapter, let us understand Theme Variables in Grav. Objects and variables are accessed from twig templates while designing your theme and these objects & variables are read and manipulated by Twig Templating Framework. Core Objects Twig template has many core objects; each object has a set of variables and functions. The following table shows variables with brief description. Sr.No. Variable & Description 1 {{ base_dir }} We can get Grav installations base file directory by using this variable. 2 {{ base_url }} The base url of the Grav site can be accessed by using this variable. 3 {{ base_url_relative }} It returns the relative path of the base url to Grav site. 4 {{ base_url_absolute }} It returns the absolute path of the base url to Grav site. 5 {{ theme_dir }} It is used to return the current theme”s file directory folder. 6 {{ theme_url }} It is used to return current theme”s relative URL. config object In configuration.yaml file, the config object is set to access any Grav configuration setting. {{ config.pages.theme }} It will return the currently configured theme. site object Provides an alias to config.site object, representing the configurations set in the site.yaml file. stylesheets object These objects provide an array for CSS stylesheet assets to get stored, which can be looped to add CSS to templates. scripts object These objects provide an array that consists of JavaScript assets, which is looped over and JavaScripts are added to the templates. page object Since the structure of the Grav is defined in pages/ folder, the page object is responsible for representing each page. The page object contains all the information about the page that you are currently working on. Following table shows methods of the page object. Sr.No. Method & Description Example 1 summary([size]) It gives a gist of the page content with the specified size provided as a parameter. If size is not specified then the value is obtained from summary.size variable in system/config/site.yaml file. You can also delimiter === in your content. The content before the delimiter will be used for summary. {{ page.summary }} Or {{ page.summary(80) }} 2 content() It is used to get the entire HTML content of the page. {{ page.content }} 3 headers() It returns the page headers defined in the YAML front-matter of the page. title: About Us author: Johnson The above headers can be accessed as: The author of this page is: {{ page.header.author }} 4 media() It is used to access all the media files such as images, videos and other files. It will return an array containing all the media associated with a page. {% set first_image = page.media|first %} {% set my_pdf = page.media[”myfile.pdf”] %} {% for image in page.media.images %} {{ image.html }} {% endfor %} 5 title() It is set to return the title of the page which is defined in YAML headers for the page. title: My Page 6 menu() The value of the menu variable is returned which is specified in YAML headers of the page. If the title variable is not set, then it will default to title. title: My Blog menu: my blog page 7 visible() It is used to set the visibility of the page. Usually pages with numeric value followed by period (i.e., 01.foldername) is displayed in menu and the folder name that does not contain numeric value (i.e., foldername) are not visible. We can override it in page header. title: About Us visible: true 8 routable() By using this we can determine whether a page is routable or not routable meaning that whether you can receive content back while pointing your browser to the page. The pages which are not routable can be used in plugins, templates, etc., and these pages cannot be directly accessed. This is set in page headers. title: My Page routable: true 9 slug() By using this variable, we can get direct name as displayed in the URL of the page. my-page 10 url([include_host = false]) It is used to return the page”s URL {{ page.url }} { # could return /myfolder/mypage #} Or {{ page.url(true) }} {# could return http: //mysite.com/ myfolder/mypage #} 11 route() It is used to return the internal routing of the page. 12 home() Using this variable you can determine whether the page is configured as home page or not. This returns true when a page is configured as home page and false when not configured. You can find this setting in system.yaml file. 13 root() It determines whether the current page is the root page of the hierarchy or not. It returns true if it”s a root page or false if it”s not root page. 14 active() You can determine whether the browser is accessing the current page by using this variable. It returns true if browser is accessing this page or false if it”s not. 15 modular() By using this variable, we can determine whether this page is modular or not. If this is a modular page then it returns true and false if it”s not. 16 activeChild() This variable can determine whether this URI”s URL has the URL of the active page; or, in simple words this page”s URL in current URL. This is very useful when you are working on navigations and you want to know that whether the pages are iterating over same parent page. 17 find(url) As specified by the route URL, the page object is returned by this variable. {% include ”modular/author-detail.html.twig” with {”page”: page.find(”/authors/ john-bloggs”)} %} 18 collection() This variable is used to return the group of pages for a context as determined by the collection page headers. {% for child in page.collection %} {% include ”partials /blog_item.html.twig” with {”page”:child, ”truncate”:true} %} {% endfor %} 19 isFirst() If the current page is first of it”s sibling page, then it returns true else returns false. 20 isLast() If the current page is last of it”s sibling page,
Grav – Configuration Site
Grav – Configuration Site ”; Previous Next In this chapter, we will study about how to Configure Site in Grav”s Administration Panel. You can directly configure the settings of your site”s System with the help of the Configuration page. TheSite tab allows you to modify the settings in the /user/config/system.yaml file. This tab allows you to modify the options and the fields that affect site related features such as the name, default author etc. used in your site. Following are the different configuration settings that you can see in the Site tab. Default In this area, you can set the basic properties to manage the content for your site. Here, you can set several content display options such as the home page, default theme and many others. Site Title − This specifies the title for your site. Default Author − This specifies a default author name that is used in themes or page content. Default Email − This specifies a default email in themes or pages. Taxonomy Types − This specifies the taxonomy types that you use in pages. Page Summary A page summary has the ability to present you a small preview of a page”s content. You can define a “cut off” point in the page, between the summary content with the help of delimiter. Enabled − This specifies if the page summary is enabled. Summary Size − This defines the number of characters to be used as content summary in the page. Format − Short uses the first occurrence of delimiter, Long ignores summary delimiter. Delimiter − This specifies the summary delimiter. Default value is default ”===”. You can use this in the page summary and post this after opening a paragraph. Metadata Metadata plays an important role in the pages and improves your SEO. You can set several metadata properties here, so that your links can appear in several search engines and social feeds as per the demand. This specifies the default metadata value, later you can make the modifications. Redirects and Routes This allows you to set redirects and routes to other pages of your site. Custom Redirects − This defines routes to direct to other pages. The replacement of standard regex is valid. Custom Routes − Routes to alias to other pages. The replacement of standard regex is valid. Print Page Previous Next Advertisements ”;