template modification

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
User avatar
hotze
Forum Members
Forum Members
Posts: 28
Joined: Sun May 07, 2006 4:05 pm

template modification

Post 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:

Code: Select all

{news limit=3 detailpage='news'}

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
User avatar
hotze
Forum Members
Forum Members
Posts: 28
Joined: Sun May 07, 2006 4:05 pm

Re: template modification

Post 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
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: template modification

Post by calguy1000 »

No {news ...} is the way it works in the newest versions of cms.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Pierre M.

Re: template modification

Post by Pierre M. »

Hello,

shall I understand that {news ...} is deprecated and {cms_module module="news" ...} should be used instead ?

Pierre M.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: template modification

Post by calguy1000 »

{news } is merely a shortcut to {cms_module module='News' ...}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
cyberman

Re: template modification

Post 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 ::) ...
nivekiam

Re: template modification

Post 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 ;D :

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 ;D

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.
cyberman

Re: template modification

Post 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.
nivekiam

Re: template modification

Post 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.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: template modification

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
nivekiam

Re: template modification

Post 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.
hexdj
Power Poster
Power Poster
Posts: 415
Joined: Sat Mar 24, 2007 8:28 am

Re: template modification

Post by hexdj »

@Original poster
How is that a Tip or Trick?
Pierre M.

Re: template modification

Post by Pierre M. »

hotze wrote: my website (cmsms 1.0.2).
Hadn't seen this ! One word : upgrade.

Pierre M.
Post Reply

Return to “Tips and Tricks”