Page 1 of 1
template modification
Posted: Thu Jan 18, 2007 9:34 am
by hotze
Hi,
I am using this template
Left simple navigation + 1 column for my website (cmsms 1.0.2).
What I've seen is that the news block in the left column will display ALL news, the line is:
I've slightly modified the block so that it will only display the 3 latest news (assuming you have them in the category "General").
here is the whole block, FYI:
Code: Select all
<!-- Start News -->
<div id="news">
<h2>News</h2>
{news category="General" number="3"}
</div>
<!-- End News -->
hth, martin
Re: template modification
Posted: Thu Jan 10, 2008 5:10 pm
by hotze
in new versions this is:
Code: Select all
<!-- Start News -->
<div id="news">
<h2>News</h2>
{cms_module module="news" number="3"}
</div>
<!-- End News -->
HTH, martin
Re: template modification
Posted: Thu Jan 10, 2008 5:11 pm
by calguy1000
No {news ...} is the way it works in the newest versions of cms.
Re: template modification
Posted: Fri Jan 11, 2008 6:19 pm
by Pierre M.
Hello,
shall I understand that {news ...} is deprecated and {cms_module module="news" ...} should be used instead ?
Pierre M.
Re: template modification
Posted: Fri Jan 11, 2008 6:37 pm
by calguy1000
{news } is merely a shortcut to {cms_module module='News' ...}
Re: template modification
Posted: Fri Jan 11, 2008 8:53 pm
by cyberman
calguy1000 wrote:
{news } is merely a shortcut to {cms_module module='News' ...}
Cause {news} is only a wrapper it seems {cms_module module='News' ...} is the faster alternative

...
Re: template modification
Posted: Tue Jan 15, 2008 10:18 pm
by nivekiam
It is, not by much, but it is. But if you're really looking to eek out some speed use static content.
Highly scientific, realistic test here

:
300 calls to {news} vs 300 calls to {cms_module module="News"} vs 100 static posts (couldn't get all 300 static posts written to the DB without editing the DB table)
{news}
9 full refreshes of the page took on average 4.846897 seconds with 1227 SQL queries each refresh
{cms_module module="News"}
9 full refreshes of the page took on average 4.586229 seconds with 1227 SQL queries each refresh
A savings of 0.26 seconds.
100 static posts, reloaded just once took 0.14677 seconds with 23 SQL queries
I didn't want to hack my DB to store more content and get all 300 static news posts in there, but I seriously doubt it would have taken very much more time.
Personally, I would use {news} for the convience and if anything changed in how the module was called I wouldn't have to edit any templates or pages.
Great, it looks like it blew up something in my DB doing that highly useful test
Oh well I was going to do a full reinstall with a fresh DB here shortly to stop playing with and start porting my site over.
Re: template modification
Posted: Tue Jan 15, 2008 10:35 pm
by cyberman
nivekiam wrote:
with 1227 SQL queries each refresh
Hmm, I'm not a coder for real but it seams that every News entry is read separately from database

... think it should be better done with only one or two requests.
Re: template modification
Posted: Tue Jan 15, 2008 10:52 pm
by nivekiam
I agree, but I made 300 calls to {news} and 300 calls to {cms_module module="News"} so my template looked like this:
{news}
{news}
{news}
{news}
{news}
{news}
...
etc
So I would expect for something like that it would call the database each go around. I was doing this just to see if and how much faster it is to use {news} over {cms_module module="News"}.
I did not have 300 actual news items entered so it wasn't one call to {news} to get 300 news items, but 300 calls to get 300 news items.
When playing around I did notice that each news item displayed on the page added about 2 queries. I'd have to do more testing, which I probably never end up doing, but I think I recall it stopping after there were 3 items displayed on the page (the max number I had setup to display).
I also am no coder. But I would think that you should be able to grab all news items that are published and not expired in 1 or 2 queries instead of having to do additional queries foreach news item. Maybe in the end it's less efficient to make one big call to the database than several smaller ones. I do not know.
Re: template modification
Posted: Tue Jan 15, 2008 10:55 pm
by calguy1000
If I Recall Correctly there are two news queries per summary display.
The first gets the count of the matching news items so that pagination links, etc, can happen
The second gets the actual matching articles...
and I don't think that there's much that can be done about it..... unless you don't want pagination.
Re: template modification
Posted: Tue Jan 15, 2008 11:05 pm
by nivekiam
Thanks for the explanation. I'm not a professional programmer, but I can follow along and understand most explanations, though recursion can make my head explode
I think for the functionality that it provides and the fact that nobody in their right mind would be doing what I did on a live site or having many more than 5 or so summaries on a page is very unlikely. If you have 100 news summaries on a page you're probably using CMSms in a way it wasn't intended and should probably look for a tool that better fits your needs.
Re: template modification
Posted: Tue Jan 15, 2008 11:09 pm
by hexdj
@Original poster
How is that a Tip or Trick?
Re: template modification
Posted: Thu Jan 17, 2008 1:52 pm
by Pierre M.
hotze wrote:
my website (cmsms 1.0.2).
Hadn't seen this ! One word : upgrade.
Pierre M.