Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix contextual blog settings unavailable #142

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions Bundle/BlogBundle/Controller/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Victoire\Bundle\BlogBundle\Entity\Blog;
use Victoire\Bundle\BlogBundle\Repository\BlogRepository;
use Victoire\Bundle\BusinessEntityPageBundle\Entity\BusinessEntityPagePattern;
use Victoire\Bundle\PageBundle\Controller\BasePageController;
use Victoire\Bundle\PageBundle\Entity\BasePage;
use Victoire\Bundle\BlogBundle\Form\ChooseBlogType;
Expand Down Expand Up @@ -42,16 +44,21 @@ public function __construct()
/**
* New page
*
* @Route("/", name="victoire_blog_index")
* @Route("/{blogId}/{tab}", name="victoire_blog_index", defaults={"blogId" = null, "tab" = "articles"})
* @param Request $request
* @param integer|null $id
*
* @return JsonResponse
*/
public function indexAction(Request $request, $isHomepage = false)
public function indexAction(Request $request, $blogId = null, $tab = 'articles')
{
$blogRepo = $this->get('doctrine.orm.entity_manager')
->getRepository('VictoireBlogBundle:Blog');
/** @var BlogRepository $blogRepo */
$blogRepo = $this->get('doctrine.orm.entity_manager')->getRepository('VictoireBlogBundle:Blog');
$blogs = $blogRepo->getAll()->run();
$blog = reset($blogs);
if (is_numeric($blogId)) {
$blog = $blogRepo->find($blogId);
}
$options['blog'] = $blog;
$template = $this->getBaseTemplatePath().':index.html.twig';
$chooseBlogForm = $this->createForm(new ChooseBlogType(), null, $options);
Expand All @@ -75,9 +82,10 @@ public function indexAction(Request $request, $isHomepage = false)
'html' => $this->container->get('victoire_templating')->render(
$template,
array(
'blog' => $blog,
'tabs' => array('articles', 'settings', 'category'),
'chooseBlogForm' => $chooseBlogForm->createView(),
'blog' => $blog,
'currentTab' => $tab,
'tabs' => array('articles', 'settings', 'category'),
'chooseBlogForm' => $chooseBlogForm->createView(),
'businessProperties' => $businessProperties,
)
),
Expand Down
9 changes: 6 additions & 3 deletions Bundle/BlogBundle/Listener/BlogMenuListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,12 @@ public function addBlogContextual($event)

$mainItem->addChild('menu.blog.settings',
array(
'route' => 'victoire_blog_settings',
'routeParameters' => array('id' => $event->getPage()->getId()),
)
'route' => 'victoire_blog_index',
'routeParameters' => array(
'blogId' => $event->getPage()->getId(),
'tab' => 'settings'
),
)
)->setLinkAttribute('data-toggle', 'vic-modal');

$mainItem->addChild('menu.blog.translate',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@
</div>
</div>


<button type="submit" href="#" class="vic-btn vic-btn-success vic-pull-right" title="{{ ('modal.button.settings.title')|trans({}, 'victoire') }}"><i class="fa fa-check-circle"></i> {{ ('modal.button.settings.title')|trans({}, 'victoire') }}</submit>
<button type="submit" href="#" class="vic-btn vic-btn-success vic-pull-right" title="{{ ('modal.button.settings.title')|trans({}, 'victoire') }}"><i class="fa fa-check-circle"></i> {{ ('modal.button.settings.title')|trans({}, 'victoire') }}</button>
</form>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="vic-tab-content vic-modal-tab-content">
{% for tab in tabs %}
<div class="vic-tab-pane{% if loop.first %} vic-active{% endif %}" id="victoire-blog-{{tab}}">
<div class="vic-tab-pane{% if tab == currentTab %} vic-active{% endif %}" id="victoire-blog-{{tab}}">
{{ render(controller('VictoireBlogBundle:Blog:' ~ tab, {'id' : blog.id})) }}
</div>
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion Bundle/BlogBundle/Resources/views/Blog/Tabs/nav.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<ul class="vic-nav vic-nav-tabs vic-modal-nav-tabs">
{% for tab in tabs %}
<li{% if loop.first %} class="vic-active"{% endif %}>
<li{% if tab == currentTab %} class="vic-active"{% endif %}>
<a class="offer-tab-nav-anchor" href="#victoire-blog-{{tab}}" role="vic-tab" data-toggle="vic-tab">
{% spaceless %}
<span class="icon victoire-blog-tab-nav-icons victoire-blog-tab-nav-icons-{{ tab }}"></span>
Expand Down