Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Commit

Permalink
add example for category listing + most recent question - component
Browse files Browse the repository at this point in the history
  • Loading branch information
slaubi committed Apr 24, 2017
1 parent 3efb1eb commit 2a37ff7
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 11 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ Run composer install and follow instructions
```
$ composer install
```



## ToDo

* enable GenjFaqAdminBundle
*
27 changes: 24 additions & 3 deletions app/Resources/views/default/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,31 @@
This is a demonstration of the <a href="https://github.com/genj/GenjFaqBundle" rel="nowfollow" target="_blank">GenjFaqBundle</a>
within a standard <a href="http://symfony.com/download" rel="nofollow" target="_blank">Symfony {{ constant('Symfony\\Component\\HttpKernel\\Kernel::VERSION')[:5] }} project</a>.
</p>
<p>
The Bundle comes with just one page:<br>
<a href="{{path('genj_faq_faq_index') }}">list of all active categories and questions</a>.
<p>
The Bundle comes with a handful of (sub)actions like:
</p>
<ul>
<li><a href="{{path('genj_faq_faq_index') }}">list of all active categories and questions</a></li>
<li>list most recent questions</li>
<li>list of active categories</li>
</ul>
<p>
All available actions and subactions will be demonstrated in the projects
default app/Resources/views/default/index.html.twig
</p>
</div>
</div>

<div class="container">
<div class="row">

<div class="col-sm-8 blog-main">
{{ render(controller('GenjFaqBundle:Question:listMostRecent', { max:5 })) }}
</div>

<div class="col-sm-3 offset-sm-1 blog-sidebar">
{{ render(controller('GenjFaqBundle:Category:listActive')) }}
</div>
</div>
</div>
{% endblock %}
10 changes: 9 additions & 1 deletion app/config/routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@ homepage:
type: annotation

genj_faq_faq_index:
path: /faq/{categorySlug}/{questionSlug}
path: /all-questions/{categorySlug}/{questionSlug}
defaults: { _controller: GenjFaqBundle:Faq:index, categorySlug: null, questionSlug: null }

genj_faq_category_show:
path: /faq/{slug}
defaults: { _controller: GenjFaqBundle:Category:show }

genj_faq_question_show:
path: /faq/{categorySlug}/{slug}
defaults: { _controller: GenjFaqBundle:Question:show }
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

"doctrine/doctrine-fixtures-bundle": "~2.2",
"gedmo/doctrine-extensions": ">=2.4.10",
"genj/faq-bundle": "3.2.x-dev"
"genj/faq-bundle": "dev-master"
},
"require-dev": {
"sensio/generator-bundle": "^3.0",
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Demo/FaqBundle/Resources/views/Category/list_active.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="sidebar-module sidebar-module-inset">
<h4>Categories</h4>

<ul>
{% for category in categories %}
<li><a href="{{ path(category.routeName, category.routeParameters) }}">{{ category.headline }}</a></li>
{% endfor %}
</ul>

</div>
24 changes: 24 additions & 0 deletions src/Demo/FaqBundle/Resources/views/Category/show.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% extends 'base.html.twig' %}

{% block title %}{{ category.headline }} FAQ{% endblock %}

{% block body %}

<div class="blog-header">
<div class="container">
<h1 class="blog-title">{{ category.headline }}</h1>
<p class="lead blog-description">{{ category.body }}</p>
</div>
</div>

<div class="container">
<ul>
{% for question in category.sortedQuestions %}
<li>
<a href="{{ path(question.routeName, question.routeParameters) }}">{{ question.headline|e }}</a>
</li>
{% endfor %}
</ul>
</div>

{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="blog-post">
<h2 class="blog-post-title">Most recent questions</h2>

<ul>
{% for question in questions %}
<li><a href="{{ path(question.routeName, question.routeParameters) }}">{{ question.headline }}</a></li>
{% endfor %}
</ul>

</div>
18 changes: 18 additions & 0 deletions src/Demo/FaqBundle/Resources/views/Question/show.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% extends 'base.html.twig' %}

{% block title %}{{ question.headline }} - FAQ{% endblock %}

{% block body %}

<div class="blog-header">
<div class="container">
<h1 class="blog-title">{{ question.headline }}</h1>
<p class="lead blog-description">{{ question.category.headline }}</p>
</div>
</div>

<div class="container">
{{ question.body|raw }}
</div>

{% endblock %}

0 comments on commit 2a37ff7

Please sign in to comment.