M
M
magary42016-05-23 12:48:18
symfony
magary4, 2016-05-23 12:48:18

How to switch between displaying content of grid type and list type?

there are some search results that need to be displayed in the form of a list and in the form of a grid (let's say 3 cells in one line
)

<div class="list-item">..</div>
<div class="grid-item">..</div>
<div class="list-item">..</div>
<div class="grid-item">..</div>
...

and styles hide either even or odd numbers.
but somehow not ice it seemed to me
what is a beautiful solution for this?
mind - page reload with render in another twig template

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anton Shamanov, 2016-05-23
@SilenceOfWinter

tympanus.net/Blueprints/ViewModeSwitch if this is it, then above is a link to the article.

A
Andrey, 2016-05-23
@AndreyMyagkov

wrap the output in a block and, depending on the selected output type, add the results--grid or results--item modifier class to it and, as you wrote, hide unnecessary elements in the styles:
.results--grid .list-item {
display:none;
}
.results--list .grid-item {
display:none;
}

A
Andrey Shakhtarin, 2016-10-26
@AndreyShakhtarin

devacademy.ru/posts/symfony-2-joboard-rss
you can take logic from here, in particular, you can use magic

public function indexAction()
{
   $format = $this->getRequest()->getRequestFormat();

   return $this->render('AcmeBlogBundle:Blog:index.'.$format.'.twig');
}

And the path to the content
maybe this is what the above
option was looking for, simple style switching using js
without unnecessary requests to the server

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question