Caching issues?

0 views
Skip to first unread message

Xander

unread,
Sep 14, 2009, 12:52:31 PM9/14/09
to php-outline
Hi,

I've been playing to have php-outline have my current "template"
system for my CMS replaced. Now it seems integrated, but somehow it
seems like caching is messing things up every now and then. I've got a
couple of links in the demonstration (link below), but every now and
then when I click a link the wrong content shows up. Sometimes PHP
code doesn't get parsed the first time, but does get parsed on
refresh.

Is this something that was bound to happen due to my structure? Or
does it have something to do with the Outline script? Take a look at
the link below and see whether you can simulate the problem that wrong
(cached?) content shows up for certain pages. I just tried again and
saw for one page (/testpage.html) three different contents show-up on
every refresh. That's not supposed to happen ;).

If anyone would like to see the source, give me a heads-up and I'll
put an archive online.

Cheers,
Xander.

Xander

unread,
Sep 14, 2009, 12:56:02 PM9/14/09
to php-outline
Whoops.. How about that link, right :)?

Front-end: http://beta.compactcms.nl
Administration: http://beta.compactcms.nl/admin/

Note that this install is using the same DB as the public demo. So
contents may change.

mindplay.dk

unread,
Sep 14, 2009, 9:52:25 PM9/14/09
to php-outline
Looks fine to me? although there is no beta.compactcms.nl/
testpage.html ... but maybe you already solved the problem?

Xander

unread,
Sep 15, 2009, 7:43:09 AM9/15/09
to php-outline
You probably visited pages that used different templates. I resetted
the settings. If you now use the main menu on the default (ccms)
template, you'll see that clicking one link can give you different
pages due to caching.

Is there a way to disable caching but still have PHP code parsed? I
noticed that when I disable caching, PHP coding within pages doesn't
get rendered well anymore (e.g. I see mail(' on the webpage).

Thanks.

Xander

unread,
Sep 15, 2009, 11:25:20 AM9/15/09
to php-outline
Okay, I think it is a restriction on my way of coding. I was
specifying the content (to be loaded from another file) using $var =
get_file_contents(file.php). Then I tried to do {$var} in the template
and expected the content of the PHP file to show. But instead I got
the literal text (not parsed). I'm now looking into using the {include
$var} option. I've defined $var in index.php to be set to:

$var = "./content/showfile.php";

If I however call the template (based on the index.php file) it shows
the text "./content/showfile.php" on the location where I expect the
actual content of that file to be shown. The same holds for when I use
{require $var}.

What am I missing?

mindplay.dk

unread,
Sep 15, 2009, 9:42:13 PM9/15/09
to php-outline
I used nested templates a lot, particularly for layouts - should work
without problems.

Do something like $tpl->assign('subtemplate', 'articles/sports');

And then in the template, do something like {include $subtemplate} in
your template.

Note that {include} is for nested templates, while {require} is for
PHP scripts.

Also note that {include} wants a template-name for the argument, not a
script path - e.g. 'articles/sports', not './articles/sports.php'.

mindplay.dk

unread,
Oct 22, 2009, 7:35:43 PM10/22/09
to php-outline
I am curious, did you manage to integrate Outline with your product?

You might be interested in Outline 2.0, which I am currently building
- it will be simpler and more open-ended, so it should be easier to
integrate with third-party frameworks or CMSes.

Xander

unread,
Oct 25, 2009, 7:15:46 AM10/25/09
to php-outline
I have one build with your project included, but haven't worked on it
recently. You have to know that the actual content for a template is
included from an actual file (no database). A CCMS function sets the
$ccms['content'] variable using "file_get_contents". In the index.php
file (your template handling) a new variable is set ($content=$ccms
['content']) which is used in the lay-out templates ({$content}).

This works fine if the original file to be included is regular html/
text only. However PHP code needs to be parsed along the way
(file_get_contents doesn't do this), which is only possible using
outline with caching enabled. So with caching enabled you get the
correct view (Hello World), but without caching you get <?="Hello
World"?>.

I fully realize this is due to my decision to work with separate
content files (no DB) and want to allow PHP coding as well. Since I've
been having my midterms, I haven't been able to give it a lot of
thought, but I'm very much interested to try out 2.0 and see how this
could possible affect things. Perhaps I should change my own way of
working, because currently I'm making things relatively more difficult
than it could be (e.g.: switch to DB or don't offer templating).

Keep me posted!

mindplay.dk

unread,
Oct 25, 2009, 8:49:25 PM10/25/09
to php-outline
I'm not sure what you mean. Outline templates are always require()'d,
whether you use caching or not - templates are never read using
file_get_contents(), except by the compiler, but the compiler never
outputs anything.

I think there's an endless debate as to whether storing templates in a
DB simplifies or complicates. Of course it depends on the application
as well, but generally, I find that it complicates things. If you're
using templates kind of as a means of content management, it might
make sense - but I would never personally use a template engine for
that purpose anyhow.

On another note, the fact that you need to use PHP in your templates
is probably a sign that you could be getting more out of it than you
are - by adding your own commands to abstract whatever it is you can't
currently do.

These are all subjective opinions based on my own experience, so take
that for what you will :-)
Reply all
Reply to author
Forward
0 new messages