Skip to content

Commit

Permalink
Updated README.md
Browse files Browse the repository at this point in the history
The README.md has been modified after ekino#130 resolution. It has been difficult to find the solution until seeing this opened issue.

A Twig example has been added as well.
  • Loading branch information
encreinformatique committed Feb 12, 2020
1 parent fbaf851 commit fdfd541
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -82,7 +82,7 @@ ekino_wordpress:
table_prefix: "wp_" # If you have a specific Wordpress table prefix
wordpress_directory: "%kernel.root_dir%/../../wordpress"
load_twig_extension: true # If you want to enable native WordPress functions (ie : get_option() => wp_get_option())
enable_wordpress_listener: false # If you want to disable the WordPress request listener
enable_wordpress_listener: true # If you want to disable the WordPress request listener
security:
firewall_name: "secured_area" # This is the firewall default name
login_url: "/wp-login.php" # Absolute URL to the wordpress login page
Expand Down Expand Up @@ -364,3 +364,5 @@ Twig functions available in this bundle:
{{ wp_get_footer() }}
```

You can see an example for [TwentyTwenty theme](Resources/docs/twig_example.md).
74 changes: 74 additions & 0 deletions Resources/docs/twig_example.md
@@ -0,0 +1,74 @@
# Example for Twig

## Theme Wordpress TwentyTwenty

This is a dummy example for a page controlled by Symfony.

### Twig

```jinja
{{ wp_get_header() }}
<main id="site-content" role="main">
<article class="post-1 page type-page status-publish hentry">
<header class="entry-header has-text-align-center header-footer-group">
<div class="entry-header-inner section-inner medium">
{% if archive_title is defined and archive_title is not empty %}
<h1 class="entry-title">{{ archive_title }}</h1>
{% endif %}
{% if archive_subtitle is defined and archive_subtitle is not empty %}
<div class="entry-subtitle section-inner thin max-percentage intro-text">{{ archive_subtitle|striptags('strong') }}</div>
{% endif %}
</div><!-- .entry-header-inner -->
</header>
<div class="post-inner thin ">
<div class="entry-content">
{{ msg|raw }}
</div>
</div>
</article>
</main>
{{ wp_get_template_part( 'template-parts/footer-menus-widgets' ) }}
{{ wp_get_footer() }}
```

### Controller

The route _/example_ is dealt with Symfony.

```php
<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;

class DefaultController extends AbstractController
{
/**
* @Route("/example", name="sf_example", methods={"GET"})
*/
public function index()
{
return $this->render('index.html.twig', [
'archive_title' => 'Archive title',
'archive_subtitle' => 'Archive subtitle',
'msg' => '<p>Hello world!</p>'
]);
}
}

```

0 comments on commit fdfd541

Please sign in to comment.