add new demo symfony files
This commit is contained in:
8
app/templates/admin/blog/_delete_form.html.twig
Normal file
8
app/templates/admin/blog/_delete_form.html.twig
Normal file
@@ -0,0 +1,8 @@
|
||||
{{ include('blog/_delete_post_confirmation.html.twig') }}
|
||||
<form action="{{ url('admin_post_delete', {id: post.id}) }}" method="post" data-confirmation="true" id="delete-form">
|
||||
<input type="hidden" name="token" value="{{ csrf_token('delete') }}" />
|
||||
<button type="submit" class="btn btn-lg btn-block btn-danger">
|
||||
<i class="fa fa-trash" aria-hidden="true"></i>
|
||||
{{ 'action.delete_post'|trans }}
|
||||
</button>
|
||||
</form>
|
26
app/templates/admin/blog/_form.html.twig
Normal file
26
app/templates/admin/blog/_form.html.twig
Normal file
@@ -0,0 +1,26 @@
|
||||
{#
|
||||
By default, forms enable client-side validation. This means that you can't
|
||||
test the server-side validation errors from the browser. To temporarily
|
||||
disable this validation, add the 'novalidate' attribute:
|
||||
|
||||
{{ form_start(form, {attr: {novalidate: 'novalidate'}}) }}
|
||||
#}
|
||||
|
||||
{% if show_confirmation|default(false) %}
|
||||
{% set attr = {'data-confirmation': 'true'} %}
|
||||
{{ include('blog/_delete_post_confirmation.html.twig') }}
|
||||
{% endif %}
|
||||
|
||||
{{ form_start(form, {attr: attr|default({})}) }}
|
||||
{{ form_widget(form) }}
|
||||
|
||||
<button type="submit" class="{{ button_css|default("btn btn-primary") }}">
|
||||
<i class="fa fa-save" aria-hidden="true"></i> {{ button_label|default('label.create_post'|trans) }}
|
||||
</button>
|
||||
|
||||
{% if include_back_to_home_link|default(false) %}
|
||||
<a href="{{ path('admin_post_index') }}" class="btn btn-link">
|
||||
<i class="fa fa-list-alt" aria-hidden="true"></i> {{ 'action.back_to_list'|trans }}
|
||||
</a>
|
||||
{% endif %}
|
||||
{{ form_end(form) }}
|
29
app/templates/admin/blog/edit.html.twig
Normal file
29
app/templates/admin/blog/edit.html.twig
Normal file
@@ -0,0 +1,29 @@
|
||||
{% extends 'admin/layout.html.twig' %}
|
||||
|
||||
{% block body_id 'admin_post_edit' %}
|
||||
|
||||
{% block main %}
|
||||
<h1>{{ 'title.edit_post'|trans({'%id%': post.id}) }}</h1>
|
||||
|
||||
{{ include('admin/blog/_form.html.twig', {
|
||||
form: form,
|
||||
button_label: 'action.save'|trans,
|
||||
include_back_to_home_link: true,
|
||||
}, with_context = false) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
<div class="section">
|
||||
<a href="{{ path('admin_post_show', {id: post.id}) }}" class="btn btn-lg btn-block btn-success">
|
||||
<i class="fa fa-eye" aria-hidden="true"></i> {{ 'action.show_post'|trans }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="section actions">
|
||||
{{ include('admin/blog/_delete_form.html.twig', {post: post}, with_context = false) }}
|
||||
</div>
|
||||
|
||||
{{ parent() }}
|
||||
|
||||
{{ show_source_code(_self) }}
|
||||
{% endblock %}
|
55
app/templates/admin/blog/index.html.twig
Normal file
55
app/templates/admin/blog/index.html.twig
Normal file
@@ -0,0 +1,55 @@
|
||||
{% extends 'admin/layout.html.twig' %}
|
||||
|
||||
{% block body_id 'admin_post_index' %}
|
||||
|
||||
{% block main %}
|
||||
<h1>{{ 'title.post_list'|trans }}</h1>
|
||||
|
||||
<table class="table table-striped table-middle-aligned">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{{ 'label.title'|trans }}</th>
|
||||
<th scope="col"><i class="fa fa-calendar" aria-hidden="true"></i> {{ 'label.published_at'|trans }}</th>
|
||||
<th scope="col" class="text-center"><i class="fa fa-cogs" aria-hidden="true"></i> {{ 'label.actions'|trans }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for post in posts %}
|
||||
<tr>
|
||||
<td>{{ post.title }}</td>
|
||||
{# it's not mandatory to set the timezone in localizeddate(). This is done to
|
||||
avoid errors when the 'intl' PHP extension is not available and the application
|
||||
is forced to use the limited "intl polyfill", which only supports UTC and GMT #}
|
||||
<td>{{ post.publishedAt|format_datetime('medium', 'short', '', 'UTC') }}</td>
|
||||
<td class="text-right">
|
||||
<div class="item-actions">
|
||||
<a href="{{ path('admin_post_show', {id: post.id}) }}" class="btn btn-sm btn-default">
|
||||
<i class="fa fa-eye" aria-hidden="true"></i> {{ 'action.show'|trans }}
|
||||
</a>
|
||||
|
||||
<a href="{{ path('admin_post_edit', {id: post.id}) }}" class="btn btn-sm btn-primary">
|
||||
<i class="fa fa-edit" aria-hidden="true"></i> {{ 'action.edit'|trans }}
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="4" align="center">{{ 'post.no_posts_found'|trans }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
<div class="section actions">
|
||||
<a href="{{ path('admin_post_new') }}" class="btn btn-lg btn-block btn-success">
|
||||
<i class="fa fa-plus" aria-hidden="true"></i> {{ 'action.create_post'|trans }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{{ parent() }}
|
||||
|
||||
{{ show_source_code(_self) }}
|
||||
{% endblock %}
|
29
app/templates/admin/blog/new.html.twig
Normal file
29
app/templates/admin/blog/new.html.twig
Normal file
@@ -0,0 +1,29 @@
|
||||
{% extends 'admin/layout.html.twig' %}
|
||||
|
||||
{% block body_id 'admin_post_new' %}
|
||||
|
||||
{% block main %}
|
||||
<h1>{{ 'title.post_new'|trans }}</h1>
|
||||
|
||||
{{ form_start(form) }}
|
||||
{{ form_row(form.title) }}
|
||||
{{ form_row(form.summary) }}
|
||||
{{ form_row(form.content) }}
|
||||
{{ form_row(form.publishedAt) }}
|
||||
{{ form_row(form.tags) }}
|
||||
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fa fa-save" aria-hidden="true"></i> {{ 'label.create_post'|trans }}
|
||||
</button>
|
||||
{{ form_widget(form.saveAndCreateNew, {label: 'label.save_and_create_new', attr: {class: 'btn btn-primary'}}) }}
|
||||
<a href="{{ path('admin_post_index') }}" class="btn btn-link">
|
||||
<i class="fa fa-list-alt" aria-hidden="true"></i> {{ 'action.back_to_list'|trans }}
|
||||
</a>
|
||||
{{ form_end(form) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{{ parent() }}
|
||||
|
||||
{{ show_source_code(_self) }}
|
||||
{% endblock %}
|
36
app/templates/admin/blog/show.html.twig
Normal file
36
app/templates/admin/blog/show.html.twig
Normal file
@@ -0,0 +1,36 @@
|
||||
{% extends 'admin/layout.html.twig' %}
|
||||
|
||||
{% block body_id 'admin_post_show' %}
|
||||
|
||||
{% block main %}
|
||||
<h1>{{ post.title }}</h1>
|
||||
|
||||
<p class="post-metadata">
|
||||
<span class="metadata"><i class="fa fa-calendar"></i> {{ post.publishedAt|format_datetime('long', 'medium', '', 'UTC') }}</span>
|
||||
<span class="metadata"><i class="fa fa-user"></i> {{ post.author.fullName }}</span>
|
||||
</p>
|
||||
|
||||
<div class="well">
|
||||
<p class="m-b-0"><strong>{{ 'label.summary'|trans }}</strong>: {{ post.summary }}</p>
|
||||
</div>
|
||||
|
||||
{{ post.content|markdown_to_html|sanitize_html }}
|
||||
|
||||
{{ include('blog/_post_tags.html.twig') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
<div class="section">
|
||||
<a href="{{ path('admin_post_edit', {id: post.id}) }}" class="btn btn-lg btn-block btn-success">
|
||||
<i class="fa fa-edit" aria-hidden="true"></i> {{ 'action.edit_contents'|trans }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
{{ include('admin/blog/_delete_form.html.twig', {post: post}, with_context = false) }}
|
||||
</div>
|
||||
|
||||
{{ parent() }}
|
||||
|
||||
{{ show_source_code(_self) }}
|
||||
{% endblock %}
|
31
app/templates/admin/layout.html.twig
Normal file
31
app/templates/admin/layout.html.twig
Normal file
@@ -0,0 +1,31 @@
|
||||
{#
|
||||
This is the base template of the all backend pages. Since this layout is similar
|
||||
to the global layout, we inherit from it to just change the contents of some
|
||||
blocks. In practice, backend templates are using a three-level inheritance,
|
||||
showing how powerful, yet easy to use, is Twig's inheritance mechanism.
|
||||
See https://symfony.com/doc/current/templates.html#template-inheritance-and-layouts
|
||||
#}
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block stylesheets %}
|
||||
{{ parent() }}
|
||||
{{ encore_entry_link_tags('admin') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block header_navigation_links %}
|
||||
<li>
|
||||
<a href="{{ path('admin_post_index') }}">
|
||||
<i class="fa fa-list-alt" aria-hidden="true"></i> {{ 'menu.post_list'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ path('blog_index') }}">
|
||||
<i class="fa fa-home" aria-hidden="true"></i> {{ 'menu.back_to_blog'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
{% endblock %}
|
||||
|
||||
{% block javascripts %}
|
||||
{{ parent() }}
|
||||
{{ encore_entry_script_tags('admin') }}
|
||||
{% endblock %}
|
Reference in New Issue
Block a user