mirror of
https://github.com/flextype/flextype.git
synced 2025-08-17 18:36:39 +02:00
@@ -316,6 +316,9 @@ $flextype['view'] = function ($container) {
|
||||
// Add Global Vars Twig Extension
|
||||
$view->addExtension(new GlobalVarsTwigExtension($container));
|
||||
|
||||
// Add Global Shortcodes Twig Extension
|
||||
$view->addExtension(new ShortcodesTwigExtension($container));
|
||||
|
||||
// Return view
|
||||
return $view;
|
||||
};
|
||||
|
47
flextype/twig/ShortcodesTwigExtension.php
Normal file
47
flextype/twig/ShortcodesTwigExtension.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Flextype
|
||||
*
|
||||
* @author Sergey Romanenko <hello@romanenko.digital>
|
||||
* @link http://romanenko.digital
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
class ShortcodesTwigExtension extends \Twig_Extension
|
||||
{
|
||||
|
||||
/**
|
||||
* Flextype Dependency Container
|
||||
*/
|
||||
private $flextype;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct($flextype)
|
||||
{
|
||||
$this->flextype = $flextype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for twig.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return [
|
||||
new \Twig_SimpleFilter('shortcode', [$this, 'shortcode']),
|
||||
];
|
||||
}
|
||||
|
||||
public function shortcode(string $value) : string
|
||||
{
|
||||
return $this->flextype->shortcodes->process($value);
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
{% extends "themes/default/templates/partials/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
{{ entry.content|raw }}
|
||||
{{ entry.content|shortcode|raw}}
|
||||
<img src="image/{{ entry.slug }}/{{ entry.image }}?w=670&dpr=2" alt="">
|
||||
{% endblock %}
|
||||
|
@@ -3,6 +3,6 @@
|
||||
{% block content %}
|
||||
<h1>{{ entry.title }}</h1>
|
||||
<div class="blog-post">
|
||||
{{ entry.content|raw }}
|
||||
{{ entry.content|shortcode|raw}}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@@ -9,7 +9,7 @@
|
||||
{% for entry in entries_fetch_all('blog', 'date', 'DESC') %}
|
||||
<a href="{{ entry.slug }}" class="blog-post">
|
||||
<h3>{{ entry.title }}</h3>
|
||||
<p>{{ entry.summary|raw }}</p>
|
||||
<p>{{ entry.summary|shortcode|raw}}</p>
|
||||
<div>{{ entry.date }}</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
{% extends "themes/default/templates/partials/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
{{ entry.content|raw }}
|
||||
{{ entry.content|shortcode|raw}}
|
||||
{% endblock %}
|
||||
|
@@ -2,12 +2,12 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
{{ entry.content|raw }}
|
||||
{{ entry.content|shortcode|raw}}
|
||||
|
||||
{% for entry in entries_fetch_all('blog', 'date', 'DESC', 0, 3) %}
|
||||
<a href="{{ entry.slug }}" class="blog-post">
|
||||
<h3>{{ entry.title }}</h3>
|
||||
<p>{{ entry.summary|raw }}</p>
|
||||
<p>{{ entry.summary|shortcode|raw}}</p>
|
||||
<div>{{ entry.date }}</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
Reference in New Issue
Block a user