Giter Club home page Giter Club logo

kirby-secrets's Introduction

Kirby Secrets

Unofficial documentation for Kirby CMS. It's is NOT maintained by the Kirby crew.

Changelog

Kirby

Panel 2

External resources

Add a secret

If you have an own secrets, add an issue.

Disclaimer

Kirby Secrets contains unofficial undocumented code. Use the code at your own risk. There is a chance that it will not work with the next version of Kirby.

Credits

The whole community.

kirby-secrets's People

Contributors

jenstornell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kirby-secrets's Issues

Get array with loaded plugins - kirby()->plugins

Tested with: 2.4.1

print_r( kirby()->plugins );

My plugin list looked like this:

Array
(
    [category-checkboxes] => 1
    [controlledlist] => 1
    [kirby-crop-top] => 1
    [kirby-menu-editor] => 1
    [kirby-panel-prevnext] => 1
    [kirby-ratings] => 1
    [kirby-sitemap-query] => 1
    [load-assets] => 1
    [magic-number-format] => 1
    [modules] => 1
    [modules-field] => 1
    [previewer] => 1
)

If a plugin has been loaded

if( a::get( kirby()->plugins, 'modules' ) ) {
	echo 'The Modules plugin has been loaded';
}

Plugin loaded function

function pluginLoaded($plugin_name) {
  if( a::get( kirby()->plugins, 'modules' ) ) {
    return true;
  }
}

Htaccess redirect to https and www

For the page Htaccess redirect to https non www I would like to add a code snippet for Htaccess redirect to https *and* www.

# Redirect http to https and add www.
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Source: http://stackoverflow.com/a/13997498

I agree that the url looks more nice without www, but in some cases adding www is a better option. For example, if using a url without www, all cookies will be sent to all subdomains. This can slow down access to images and js/css if you use a subdomain as a cdn for static content.

More information here: http://www.yes-www.org/why-use-www/

str::replace() - strtr($string, array())

It's nice to be able to search replace with key value pair. It's not possible with a function like str::replace() but in PHP it's possible:

$string = strtr($string,
  array(
    'Search for this' => 'Replace with this',
    'Search something else' => 'Replace with something else'
    )
);

Route - Match all

kirby()->routes(array(
  array(
    'pattern' => '(.+)',
    'action' => function($uri) {
      echo $uri;
    }
  )
));

When a bug is solved you could probably use (:all) instead.

getkirby/kirby#368

Route syntaxes

In the config c::set('routes')

c::set('routes', array(
  array(
    'pattern' => 'my/awesome/(:any)',
    'action'  => function($uid) {
      echo $uid;
    }
  )
));

https://getkirby.com/docs/developer-guide/advanced/routing

In a plugin kirby()->routes()

kirby()->routes(array(
  array(
    'pattern' => 'my/awesome/(:any)',
    'action'  => function($uid) {
      echo $uid;
    }
  )
));

I prefer this version most of the times.

Consistant with registry $kirby->set('route')

$kirby->set('route', array(
  'pattern' => 'my/awesome/(:any)',
  'action'  => function($uid) {
    echo $uid;
  }
));

Internal use $router->register()

In most cases you probably will not need this syntax. Therefor I will not add an example of it here.

https://getkirby.com/docs/developer-guide/toolkit/routing

.htaccess browser cache setup - panel not working properly

Hi! I followed the suggestion how to setup the .htaccess file (enable browser cache, compression etc.). The "Browser cache" part seems to produce some problems for me. I copied and pasted the code into my .htaccess file. The site works fine, but the panel does not. Suddenly, parts of the panel are not translated, I cannot rename pages (well in fact I can, but the change is not visible in the panel, although it is saved in the corresponding .txt file), newly created pages are not visible etc.

Has anybody faced similar issues? Clearing browser cache does not help. I use Kirby 3.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.