stef
September 18, 2019, 3:52pm
1
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>
texnixe
September 18, 2019, 4:26pm
2
Hm, sure your live site has any toggle fields set to false
?
texnixe
September 18, 2019, 4:46pm
4
And all fields actually have a value stored in the content file (because you are setting empty fields to true)?
stef
September 19, 2019, 8:23am
5
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
texnixe
September 19, 2019, 8:35am
6
And caching is off on the live site?
stef
September 19, 2019, 8:38am
7
apache caching? or does kirby have a cache?
texnixe
September 19, 2019, 8:40am
8
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>
texnixe
September 19, 2019, 8:44am
9
Does the page actually use this template? Maybe you made some changes locally but did not deploy them?
stef
September 19, 2019, 8:56am
10
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.
texnixe
September 19, 2019, 8:58am
11
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.
stef
September 19, 2019, 9:19am
12
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.
Oli1
September 19, 2019, 9:36am
13
I have the same problems a while ago, the only workaround was to use chrome with console active and the “disable cache” option
stef
September 19, 2019, 9:44am
14
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…
stef
September 19, 2019, 9:48am
15
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>
texnixe
September 19, 2019, 9:55am
16
What about PHP caching? On the other hand, if you make any changes to your PHP code elsewhere, does that get reflected?
stef
September 19, 2019, 10:02am
17
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
texnixe
September 19, 2019, 10:08am
18
So it seems they are using the same template
stef
September 19, 2019, 10:22am
19
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?
texnixe
September 19, 2019, 10:25am
20
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.