Toggle field not working on live site?

I have this site I’m working on and the toggle field works locally and not on the live site
it should give a filtered list of homepage posts on this page

http://68.183.6.147 (all posts)
http://68.183.6.147/OAOA (only filtered posts)

relevant template:

<section class="masonry">
  <?php foreach ($pages->template('post') as $item) : ?>
    <?php if ($item->toggle()->toBool($default = true)) : ?>
      <figure class="masonry-item">
        <a href="<?= $item->url() ?>">
          <?= $item->images()->sortBy('sort', 'asc')->first()->resize(400) ?>
        </a>
      </figure>
    <?php endif ?>
  <?php endforeach ?>
</section>

Hm, sure your live site has any toggle fields set to false?

It seems like it!

44

And all fields actually have a value stored in the content file (because you are setting empty fields to true)?

just checked the values of the .txt files on the server

for the posts title “photo”

Title: photo


Description: photo


Toggle: false

for the post titled “an olderpost”

Title: an olderpost


Description:


Toggle: true

so it seems the data is correct.
I’ll try and set a default value to see of that helps

And caching is off on the live site?

apache caching? or does kirby have a cache?

Kirby has a caching system, but you have to actively activate it in the config.

Hm, I have no idea why it should work locally but not on the remote server.

Let’s try if it works if you change the code

<section class="masonry">
  <?php foreach ($pages->template('post')->filterBy('toggle', true) as $item) : ?>
 
      <figure class="masonry-item">
        <a href="<?= $item->url() ?>">
          <?= $item->images()->sortBy('sort', 'asc')->first()->resize(400) ?>
        </a>
      </figure>

  <?php endforeach ?>
</section>

Does the page actually use this template? Maybe you made some changes locally but did not deploy them?

I don’t have the kirby cache enabled.

the page uses the template. I’ve added a line of text to it for debugging making the template as follows:

<section class="masonry">
  filtered template
  <?php foreach ($pages->template('post')->filterBy('toggle', true) as $item) : ?>
  <figure class="masonry-item">
        <?= $item->toggle() ?>
        <a href="<?= $item->url() ?>">
          <?= $item->images()->sortBy('sort', 'asc')->first()->resize(400) ?>
        </a>
      </figure>

  <?php endforeach ?>
</section>

for some reason the site isn’t updating after a git pull. I’m thinking perhaps something in apache. going to have a look about that now.

Make sure that permissions and ownership of files and folders is correct. I had to use git hooks to change permissions and ownership after deploying with Git pull in the past.

I’ve set it to 775 of all files in my html/kirby folder. I’ve also tried restarting apache but that doesn’t seem to make a difference.

I’m reading up on other cache that might be there.

I have the same problems a while ago, the only workaround was to use chrome with console active and the “disable cache” option

thanks for the tip! just gave it a try to see if it works. sadly it makes no difference. refreshing with cmd+shift+r also doesn’t seem to matter.

another thing i’ve tried was rebooting the sever. which also didn’t seem to work…

this is my 000-default.conf file in the apache2/sites-available folder. does this seems correct?

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

    <Directory /var/www/html/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <IfModule mod_dir.c>
        DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
</IfModule>

</VirtualHost>

What about PHP caching? On the other hand, if you make any changes to your PHP code elsewhere, does that get reflected?

huh strange. after updating the homepage template like this:

<section class="masonry">
  homepage
  <?php foreach ($pages->template('post') as $item) : ?>
    <figure class="masonry-item">
      <a href="<?= $item->url() ?>">
        <?= $item->images()->sortBy('sort', 'asc')->first()->resize(400) ?>
      </a>
    </figure>
  <?php endforeach ?>
</section>

that change is also reflected on the /oaoa page

So it seems they are using the same template

it seems so. I have a page template (OAOA) which has the route /oaoa. which works locally. though it seems not able to do the route correctly on the server.

@texnixe would it help if I share the git repo with you privately?

Yes, that would help. I’m on vacation and will be on a bike tour now, but will be able to look into this tonight.