If you want to use a newsbox which shows specific news only in conjunction with specific pages, the newsbox() function is used in combination with a variable. The following code is added to the template at the place where the newsbox is wanted:
<?php echo newsbox($news); ?>
To a page content then a script is added like:
#CMSimple $news = "News1";#
or
#CMSimple $news = "News2";#
or
#CMSimple $news = "News3";#
etc.
“News1”, “News2”, “News3” etc. are created as hidden CMSimple pages (#CMSimple hide#). They will be shown inside the newsbox in connection only with the page which contains the specific CMSimple script.
It is possible to improve the function a bit. Let’s say we don’t have specific news for a specific page, but the place shouldn’t be empty. Then we can show the “Main News”. To do this we change the code of the template.htm file. We say now:
<?php if ($news==''){echo newsbox('mainNews');}else{echo newsbox($news);} ?>
To show these “Main News” a hidden page is created called “mainNews” and the CMSimple script on the page, which is supposed to show no specific news, is omitted.
Discussion