Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-11-28 06:57:08

azw
Member
Registered: 2007-01-29
Posts: 279

How to fix a static home page that still shows other articles?

Hello,

I have a static front page. There is one article in the “home” section, and the “home” section is the only section that is set to display on the front page. The article’s status is set to “sticky”.

But the home page (www.MyDomain.com) still shows articles from the “News” section. That section is set to not display on the front page.

I’ve cleared the cache on two browsers.

Here is the “static_page” article template used:

<txp:output_form form="page_head" />

  <title>
    <txp:output_form form="title_conditional" />
  </title>

  <txp:output_form form="header_bar_sidebar_1_2" />

  <txp:article limit="1" form="static_article" />

<txp:output_form form="page_tail_footer_bar" />

And here is the “static_article” form used:

<h1><txp:title /></h1>

<txp:body />

<txp:comments_invite wraptag="p" />

What am I doing wrong?

Update: I vaguely remember that on the sections tab, I have to set the “Default” section as using the “static_page” template. But when I do that, the page shows no articles, so something is still wrong.

Here’s a partial tag trace, that I think covers the part in question:

<txp:if_category>
	[<txp:if_category>: false]
	<txp:hide>
	</txp:hide>
	<txp:if_section name="">
		[<txp:if_section name="">: true]
		<txp:article_custom status="sticky" section="home" limit="1" form="static_article" />
			[SQL (0.000595): select *, unix_timestamp(Posted) as uPosted from textpattern where 1=1 and Status = 5 and Posted <= now() and Section IN ('home') order by Posted desc limit 0, 1]
			[article 17]
			[SQL (0.000057): select Form from txp_form where name='static_article']
			[Form: static_article]
			<txp:title/>
			<txp:body/>
			<txp:comments_invite wraptag="p" />
		<txp:section name="news" title="1" link="1" />
		<txp:article_custom limit="5" section="news" />
			[SQL (0.000386): select *, unix_timestamp(Posted) as uPosted from textpattern where 1=1 and Status = 4 and Posted <= now() and Section IN ('news') order by Posted desc limit 0, 5]
			[article 29]
			[SQL (0.000059): select Form from txp_form where name='default']
			[Form: default]
			<txp:hide>
			</txp:hide>
			<txp:if_individual_article>
				[<txp:if_individual_article>: false]
				<txp:permlink>
					<txp:title/>
				</txp:permlink>
			</txp:if_individual_article>
			<txp:if_individual_article>
				[<txp:if_individual_article>: false]
				<txp:if_excerpt>
					[<txp:if_excerpt>: true]
					<txp:excerpt/>
					<txp:permlink>
						<txp:text item="read_more" />
					</txp:permlink>
				</txp:if_excerpt>
				<txp:if_last_article>
					[<txp:if_last_article>: false]
					<txp:site_url/>
				</txp:if_last_article>
			</txp:if_individual_article>
			[article 25]
			[Form: default]
			<txp:hide>
			</txp:hide>
			<txp:if_individual_article>
				[<txp:if_individual_article>: false]
				<txp:permlink>
					<txp:title/>
				</txp:permlink>
			</txp:if_individual_article>
			<txp:if_individual_article>
				[<txp:if_individual_article>: false]
				<txp:if_excerpt>
					[<txp:if_excerpt>: false]
					<txp:body/>
				</txp:if_excerpt>
				<txp:if_last_article>
					[<txp:if_last_article>: true]
				</txp:if_last_article>
			</txp:if_individual_article>
	</txp:if_section>
</txp:if_category>
<txp:if_individual_article>
	[<txp:if_individual_article>: false]
	<txp:chh_if_data>
		[<txp:chh_if_data>: true]
		<txp:older>
		</txp:older>
		<txp:newer>
		</txp:newer>
		[<txp:chh_if_data>: false]
	</txp:chh_if_data>
</txp:if_individual_article>

Last edited by azw (2008-11-28 07:15:42)

Offline

#2 2008-11-28 07:21:06

azw
Member
Registered: 2007-01-29
Posts: 279

Re: How to fix a static home page that still shows other articles?

One solution is to edit the “default” article template. Here’s a part of that, with the offending part hidden:

   <txp:if_category> 

      <h1 id="main_title">Results of Search by Category</h1>

      <txp:article limit="10" form="category_results" /> 

    <txp:else />

      <txp:hide> if home page or default page </txp:hide>

      <txp:if_section name="">
        <txp:article_custom status="sticky" section="home" limit="1" form="static_article" />


<txp:hide>
        <hr />

        <h1><txp:section name="news" title="1" link="1" /></h1>   
        <txp:article_custom limit="5" section="news" />
</txp:hide>


      </txp:if_section>
    </txp:if_category> 

But I’d still like to know what went wrong with using the “static_page” approach.

I get a blank page even if I try to access the URL:
www.MyDomain.com/home/
or
www.MyDomain.com/home/URL-only-title

[azw: corrected textile for correct display]

Last edited by azw (2008-11-28 17:22:46)

Offline

#3 2008-11-28 07:32:50

azw
Member
Registered: 2007-01-29
Posts: 279

Re: How to fix a static home page that still shows other articles?

Okay, i have to add this to the article tag:
status=“sticky”

But then my other static pages don’t work unless I double up on the article tag. Here’s an example of what the “static_article” template would look like then:

<txp:output_form form="page_head" />

  <title>
    <txp:output_form form="title_conditional" />
  </title>

  <txp:output_form form="header_bar_sidebar_1_2" />

  <txp:article limit="1" form="static_article" />
  <txp:article limit="1" form="static_article" status="sticky" />

<txp:output_form form="page_tail_footer_bar" />

This seems awkward.

Will it cause problems? Am I better off with the first solution in the previous message)?

Offline

#4 2008-11-28 11:49:46

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: How to fix a static home page that still shows other articles?

azw wrote:

But the home page (www.MyDomain.com) still shows articles from the “News” section. That section is set to not display on the front page.

I see this in your tag trace:

<txp:article_custom limit="5" section="news" />

Offline

#5 2008-11-28 17:26:58

azw
Member
Registered: 2007-01-29
Posts: 279

Re: How to fix a static home page that still shows other articles?

Hi, Els, thanks for replying.

After I first posted I realized that I had been stupefied by the setting for “Default” at the top of the sections tab.

So, I changed that to the “static_page” template.

The next problem was that I was confused about whether to use “sticky” status for the article, and by whether or not to add the attribute in the article tag: status=“sticky” in the page template.

I had been following the advice of two pages:
http://textbook.textpattern.net/wiki/index.php?title=Making_an_Article_Static_and_Top-Positioned
http://thresholdstate.com/articles/3667/managing-static-pages

But I had been using the status of “sticky” with some of the static pages and not others. It appears that you don’t have to use “sticky” with a static page that only displays one article, although you can.

Unless you see a problem with this, I think I’ll not use the “sticky” status, and use the “static_page” template with just one article tag:

<txp:output_form form="page_head" />

  <title>
    <txp:output_form form="title_conditional" />
  </title>

  <txp:output_form form="header_bar_sidebar_1_2" />

  <txp:article limit="1" form="static_article" />

<txp:output_form form="page_tail_footer_bar" />

Thanks again!

Offline

#6 2008-11-28 17:40:21

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: How to fix a static home page that still shows other articles?

azw wrote:

But I had been using the status of “sticky” with some of the static pages and not others. It appears that you don’t have to use “sticky” with a static page that only displays one article, although you can.

That’s right, the advantage of sticky articles is mostly for when you need to have both static and dynamic content on one page.
The way you solved it seems to be the cleanest way to do it :)

Offline

#7 2008-11-28 23:02:36

azw
Member
Registered: 2007-01-29
Posts: 279

Re: How to fix a static home page that still shows other articles?

Thanks for the feedback. That helps!

Offline

Board footer

Powered by FluxBB