mirror of
https://github.com/flextype/flextype.git
synced 2025-08-15 09:34:14 +02:00
Flextype Slim Integration - next round of integration
This commit is contained in:
@@ -213,12 +213,14 @@ $flextype['view'] = function ($container) {
|
||||
$uri = \Slim\Http\Uri::createFromEnvironment(new \Slim\Http\Environment($_SERVER));
|
||||
|
||||
$view->addExtension(new \Slim\Views\TwigExtension($router, $uri));
|
||||
$view->addExtension(new EntriesTwigExtension());
|
||||
$view->addExtension(new RegistryTwigExtension());
|
||||
|
||||
return $view;
|
||||
};
|
||||
|
||||
$flextype['view']->addExtension(new EntriesTwigExtension($flextype));
|
||||
$flextype['view']->addExtension(new RegistryTwigExtension());
|
||||
|
||||
|
||||
/**
|
||||
* Init plugins
|
||||
*/
|
||||
|
@@ -10,6 +10,20 @@ namespace Flextype;
|
||||
|
||||
class EntriesTwigExtension extends \Twig_Extension
|
||||
{
|
||||
|
||||
/**
|
||||
* Flextype Dependency Container
|
||||
*/
|
||||
private $flextype;
|
||||
|
||||
/**
|
||||
* __construct
|
||||
*/
|
||||
public function __construct($flextype)
|
||||
{
|
||||
$this->flextype = $flextype;
|
||||
}
|
||||
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
@@ -20,11 +34,11 @@ class EntriesTwigExtension extends \Twig_Extension
|
||||
|
||||
public function fetch(string $entry)
|
||||
{
|
||||
return Entries::fetch($entry);
|
||||
return $this->flextype['entries']->fetch($entry);
|
||||
}
|
||||
|
||||
public function fetchAll(string $entry, string $order_by = 'date', string $order_type = 'DESC', int $offset = null, int $length = null) : array
|
||||
{
|
||||
return Entries::fetchAll($entry, $order_by, $order_type, $offset, $length);
|
||||
return $this->flextype['entries']->fetchAll($entry, $order_by, $order_type, $offset, $length);
|
||||
}
|
||||
}
|
||||
|
@@ -19,7 +19,4 @@ include 'ATwigExtension.php';
|
||||
|
||||
//Flextype::container()['view']->addExtension(new ATwigExtension());
|
||||
|
||||
echo '@@@';
|
||||
|
||||
|
||||
//Flextype::flextype()->version();
|
||||
|
@@ -56,7 +56,7 @@ $app->get('{uri:.+}', function (Request $request, Response $response, array $arg
|
||||
$entry['template'] = Registry::get('settings.entries.error404.template');
|
||||
}
|
||||
|
||||
$path = 'themes/' . Registry::get('settings.theme') . '/' . (empty($entry['template']) ? 'templates/default' : 'templates/' . $entry['template']) . '.twig';
|
||||
$path = 'themes/' . Registry::get('settings.theme') . '/' . (empty($entry['template']) ? 'templates/default' : 'templates/' . $entry['template']) . '.html';
|
||||
|
||||
return $this->view->render($response,
|
||||
$path, [
|
||||
|
@@ -1,6 +1,4 @@
|
||||
{% extends "partials/base.twig" %}
|
||||
|
||||
{% block title %}{{ entry.title }}{% endblock %}
|
||||
{% extends "themes/default/templates/partials/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ entry.title }}</h1>
|
13
site/themes/default/templates/home.html
Normal file
13
site/themes/default/templates/home.html
Normal file
@@ -0,0 +1,13 @@
|
||||
{% extends "themes/default/templates/partials/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{{ entry.content|raw }}
|
||||
|
||||
{% for entry in entries_fetch_all('blog', 'date', 'DESC', 0, 3) %}
|
||||
<h3>{{ entry.title }}</h3>
|
||||
<p>{{ entry.summary|raw }}</p>
|
||||
<div>{{ entry.date }}</div>
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
@@ -1,8 +0,0 @@
|
||||
{% extends "themes/default/templates/partials/base.twig" %}
|
||||
|
||||
{% block title %}{{ entry.title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ entry.title }}</h1>
|
||||
{{ entry.content|raw }}
|
||||
{% endblock %}
|
Reference in New Issue
Block a user