Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

64
Visualizações
Prevent reload when URL is changed

I am currently building a website with Kirby CMS and are using Parameters in the URL to filter my articles. At the same time i have a very basic css switcher implemented, which enables me to switch between list and gallery view without any reloads (I assumed). But when I am in gallery view (the css only loaded when the switcher is used) and the url changes to pass the parameters for the filter, the site reverts to the initial css (list view). How can i prevent that from happening?

My humble CSS Switcher

function list() {
  var theme = document.getElementById('css');
  theme.href = "/assets/css/templates/works.css";
}

function gallery() {
  var theme = document.getElementById('css');
  theme.href = "/assets/css/templates/works-gallery.css";
}

Filter

<filter class="filter">
  <a href="<?= $page->url() ?>?filter=">All</a>
  <?php foreach ($filters as $filter): ?>
  <a href="?filter=<?= $filter ?>"><?= $filter ?></a>
  <?php endforeach ?>
</filter>

Respective Page Controller

return function ($page) {

  $filterBy   = get('filter');
  $unfiltered = $page->children()->listed();
  $works      = $unfiltered
  ->when($filterBy, function($filterBy) {
    return $this->filterBy('category', $filterBy);
  });
  $filters    = $unfiltered->pluck('category', null, true);

  return [
    'filterBy'    => $filterBy,
    'unfiltered'  => $unfiltered,
    'works'       => $works,
    'filters'     => $filters
  ];

};
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda