Page 1 of 1

Show news on home page without separate template for home page?

Posted: Wed Sep 27, 2006 1:50 pm
by skypanther
Is there a way to show news summaries on the home page without creating a separate template for my home page? I've been looking all over for some sort of smarty syntax that will let me do some sort of "if pagealias equals home then show {news}" test.

Thanks,
Tim

Re: Show news on home page without separate template for home page?

Posted: Wed Sep 27, 2006 4:07 pm
by cyberman
Are you meaning something like this

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<__html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- Change lang="en" to the language of your site -->

<head>

<title>{sitename} - {title}</title>
<!-- The sitename is changed in Site Admin/Global settings. {title} is the name of each page -->

{metadata}
<!-- Don't remove this! Metadata is entered in Site Admin/Global settings. -->

{stylesheet}
<!-- This is how all the stylesheets attached to this template are linked to -->

{cms_selflink dir="start" rellink=1}
{cms_selflink dir="prev" rellink=1}
{cms_selflink dir="next" rellink=1}
<!-- Relational links for interconnections between pages, good for accessibility and Search Engine Optmization -->


{literal}
<__script__ type="text/JavaScript">
<!--
//pass min and max -measured against window width
function P7_MinMaxW(a,b){
	var nw="auto",w=document.documentElement.clientWidth;
	if(w>=b){nw=b+"px";}if(w<=a){nw=a+"px";}return nw;
}
//-->
</__script>
<!--[if lte IE 6]>
<style type="text/css">
#pagewrapper {width:expression(P7_MinMaxW(720,950));}
#container {height: 1%;}
</style>
<![endif]-->
{/literal}
<!-- The min and max page width for Internet Explorer is set here. For other browsers it's in the stylesheet "Layout: Left sidebar + 1 column" -->


<!--[if IE]>
<__script__ type="text/javascript" src="modules/MenuManager/CSSMenu.js"></__script>
<![endif]-->
<!-- The above JavaScript is required for CSSMenu to work in IE -->

</head>

</__body>

<div id="pagewrapper">

   <!-- Start Content (Navigation and Content columns) -->
   <div id="content">

         {news'}
     
   </div>
   <!-- End Content -->


</div><!-- end pagewrapper -->
<__body>
</__html>

Re: Show news on home page without separate template for home page?

Posted: Wed Sep 27, 2006 7:03 pm
by skypanther
No, I was thinking like this (pardon the PHP syntax, I don't smarty all that well):

Code: Select all

   <!-- Start Content (Navigation and Content columns) -->
   <div id="content">
         {content}

         if($pagealias = 'Home') {
           {news number="3" category="General"}
         }

   </div>
   <!-- End Content -->


Re: Show news on home page without separate template for home page?

Posted: Wed Sep 27, 2006 7:06 pm
by skypanther
I guess I should have said why I'm looking to do this...I want to be able to export the theme. Therefore, I want everything in one template. Perhaps that doesn't matter.

Tim

Re: Show news on home page without separate template for home page?

Posted: Wed Sep 27, 2006 8:37 pm
by calguy1000
I think you're missing the point of templates and content.

If something is only to be on one page, then it falls under content, and you'd put the news tag in the Home page only.  If you want something on every page, then you'd put it in the template.

If I was receiving a theme from somebody that had hard coded things in it like this, I might be a little miffed.

Re: Show news on home page without separate template for home page?

Posted: Thu Sep 28, 2006 8:30 pm
by skypanther
The default templates include the {news} output in them. So, perhaps your comment should be directed at the CMS authors and not me.  ;D

That said, I don't see a problem with wanting news headlines to appear on only the home page and not others, yet wanting everything on the site share the same look and feel. I can accomplish that by having separate templates for the various pages. But, that becomes a bit of a confusion point for non-technical users adding pages later who will have to choose which templates to apply and so forth.

I also don't want the {news} tag in the content of the home page. If it's there, it's likely to be accidentally removed or changed by one of my users who won't have a clue why it's there.

I want to construct the site with a single template that embeds the {news} tag to avoid all such problems. This is for my own use and not distribution anyway. So, you won't have to worry about being miffed by this.  :D

Tim

Re: Show news on home page without separate template for home page?

Posted: Thu Sep 28, 2006 9:00 pm
by calguy1000
Okay, I see your point now, fair enough..... you want to use the {get_template_vars} plugin, to show you exactly which variable to put your condition on, and then something like the syntax you mentioned below should work just fine.