news only on frontpage

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
kengu

news only on frontpage

Post by kengu »

I feel a bit stupid because I know there is some kind of simple way of doing this but I just cannot figure out where.

I have CMSMS 1.0.4 and I would like to use only one template on all pages and for that I need a way to put news items from NEWS-module (2.2) only on frontpage. The functionality I am looking for is something as described below

Code: Select all

if (page == frontpage) {

  echo '<div id="extras">\n';
  {cms_module module="news" number="2"}
  echo '</div>\n';
} else {
  echo '<div id="zip"></div>';
}
The problem is that where and how do I get the "frontpage" to figure out which page is the frontpage and with what to compare it.
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: news only on frontpage

Post by RonnyK »

Code: Select all

{if $node->id == 1}
  //lyour logic
{/if}
based on your pageid .

Ronny
kengu

Re: news only on frontpage

Post by kengu »

Well actually that didn't work because it took the last node from my menu but inspired by that I figured out a way:

Code: Select all

{if $friendly_position == 1}

<div id="extras">
{cms_module module="news" number="2"}
</div>

{/if}
And {get_template_vars} is a good way to figure out the variables available in template. I could have used also some other variable in comparation but well.. that friendly_position one works just fine.
Locked

Return to “CMSMS Core”