Skip to content

kirby-deprecated-plugins/kirby-starthook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Kirby Starthook

Version 0.2

  • You will have access to $page directly from your config.php file.
  • You can pass global data to your templates and snippets.
  • You can do redirects on certain conditions.

How to install Kirby Starthook

Usage

Put your starthook code into the config.php file or in a plugin.

Example 1

Pass global data to templates and snippets

The data that is returned here can later be used in all your templates and snippets:

c::set('starthook', function($page) {
  return array(
    'foo' => 'my first template variable ' . $page->title(),
    'bar' => 'my second template variable'
  );
});

Note: This plugin only provides access to the $page object, whereas $site and $pages may be accessed with site() and site()->children().

Example 2

Redirect on condition

On a condition, redirect to another page.

c::set('starthook', function($page) {
  if($page->title() == 'Project A') {
    go(page('projects'), 301);
  }
});

Changelog

0.2

  • Changed from using hooks to using config instead.

0.1

  • Initial release

Requirements

Disclaimer

This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.

License

MIT

It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.

Credits

About

A Kirby CMS plugin. Pass global data to your templates and snippets.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages