Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-09-16 16:50:13

qp2wd
Member
Registered: 2011-01-11
Posts: 24

No Article tag in default template error

I’ve re-jiggered this code every way I can think of, but TXP is still telling me there’s no <txp:article /> tag when I try and view an individual article. What am I missing?

<section id="content"><!-- #content -->
			<txp:if_section name="default">
				<div id="slideshow">
					<txp:images category="listings"/>
				</div>

				<div>
					<h3>Contact Me</h3>
					Phone: 555.555.5555<br>
					Fax:555.555.5556<br>
					Email: email@example.com<br><br>

					555 Somewhere Pl.<br> 
					Waldorf, MD 20602<br>
				</div>
					<txp:else />					
				<txp:if_category>
					<txp:if_article_list>
						<table id="tlist">
								<thead>
									<tr>
										<th>&nbsp;</th>
										<th>Name</th>
										<th>Location</th>
										<th>Lot Type</th>
										<th>Size</th>
										<th>Price</th>
										<th>More Info</th>
									</tr>
								</thead>
								<tbody>
									<txp:article_custom category='<txp:category />' section="listings" listform="listings"/>
								</tbody>
						</table>
						<txp:else />
							<txp:if_individual_article>
								<txp:article />
							</txp:if_individual_article>
					</txp:if_article_list>
						<txp:else />
					<p>Now Featuring <txp:mdn_count section="listings" /> listings across Southern Maryland.</p>
				</txp:if_category>	
			</txp:if_section>
		</section><!-- end of #content -->

Offline

#2 2011-09-16 19:41:11

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

Re: No Article tag in default template error

You are getting the error because you have an if_individual_article tag inside an if_category tag, and because a category page is always an article list if_individual_article will never return true.
This should work:

<section id="content"><!-- #content -->
	<txp:if_section name="default">
		<!-- front page -->
		<div id="slideshow">
			<txp:images category="listings"/>
		</div>

		<div>
			<h3>Contact Me</h3>
			Phone: 555.555.5555<br>
			Fax:555.555.5556<br>
			Email: email@example.com<br><br>
			555 Somewhere Pl.<br> 
			Waldorf, MD 20602<br>
		</div>
	<txp:else />					
		<txp:if_article_list>
			<txp:if_category>
				<!-- category list page -->
			<txp:else />
				<!-- section/author/search list page -->
				<table id="tlist">
						<thead>
							<tr>
								<th>&nbsp;</th>
								<th>Name</th>
								<th>Location</th>
								<th>Lot Type</th>
								<th>Size</th>
								<th>Price</th>
								<th>More Info</th>
							</tr>
						</thead>
						<tbody>
							<txp:article_custom category='<txp:category />' section="listings" listform="listings"/>
						</tbody>
				</table>
			</txp:if_category>
		<txp:else />
			<!-- individual article page -->
			<txp:article />
		</txp:if_article_list>
	</txp:if_section>
</section><!-- end of #content -->

but I don’t understand where you want this part to be displayed:

<p>Now Featuring <txp:mdn_count section="listings" /> listings across Southern Maryland.</p>

Offline

#3 2011-09-19 20:01:28

qp2wd
Member
Registered: 2011-01-11
Posts: 24

Re: No Article tag in default template error

The line of text you highlighted will serve as the default content for the section when the page is first loaded and a category has not yet been selected. After a category has been selected, the articles in the corresponding category are rendered as a table in the space where that single line used to be.

<p>Now Featuring <txp:mdn_count section="listings" /> listings across Southern Maryland.</p>

I’m thinking what I’ll have to do is make that line of text a sticky article and then use the code you gave me to render the article lists within each category; I can’t figure out a way to do it using if/else that does end in a conflict.

Last edited by qp2wd (2011-09-19 20:17:32)

Offline

#4 2011-09-19 21:02:34

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

Re: No Article tag in default template error

qp2wd wrote:

The line of text you highlighted will serve as the default content for the section when the page is first loaded and a category has not yet been selected. After a category has been selected, the articles in the corresponding category are rendered as a table in the space where that single line used to be.

In that case, just switch the content:

<section id="content"><!-- #content -->
	<txp:if_section name="default">
		<!-- front page -->
		<div id="slideshow">
			<txp:images category="listings"/>
		</div>

		<div>
			<h3>Contact Me</h3>
			Phone: 555.555.5555<br>
			Fax:555.555.5556<br>
			Email: email@example.com<br><br>
			555 Somewhere Pl.<br> 
			Waldorf, MD 20602<br>
		</div>
	<txp:else />					
		<txp:if_article_list>
			<txp:if_category>
				<!-- category list page -->
				<table id="tlist">
						<thead>
							<tr>
								<th>&nbsp;</th>
								<th>Name</th>
								<th>Location</th>
								<th>Lot Type</th>
								<th>Size</th>
								<th>Price</th>
								<th>More Info</th>
							</tr>
						</thead>
						<tbody>
							<txp:article_custom category='<txp:category />' section="listings" listform="listings"/>
						</tbody>
				</table>
			<txp:else />
				<!-- section landing page -->
				<p>Now Featuring <txp:mdn_count section="listings" /> listings across Southern Maryland.</p>
			</txp:if_category>
		<txp:else />
			<!-- individual article page -->
			<txp:article />
		</txp:if_article_list>
	</txp:if_section>
</section><!-- end of #content -->

Offline

#5 2011-09-22 13:30:28

qp2wd
Member
Registered: 2011-01-11
Posts: 24

Re: No Article tag in default template error

It still gives me a “page template does not contain…” error when I enter a category.

Edit: With the following script I was able to get rid of the error message, but when I enter an individual article’s page the article itself still doesn’t show, even though the debug information shows that TXP is correctly recognizing that the page should be outputting <txp:article/>

<txp:variable name="landing"><txp:article status="sticky"/></txp:variable>
							<txp:if_variable name="landing" value="">
										<txp:if_article_list>
											<txp:if_category>
												<table id="tlist">
													<thead>
														<tr>
															<th>&nbsp;</th>
															<th>Name</th>
															<th>Location</th>
															<th>Lot Type</th>
															<th>Size</th>
															<th>Price</th>
															<th>More Info</th>
														</tr>
													</thead>
													<tbody>
														<txp:article_custom category='<txp:category />' section="listings" listform="listings"/>
													</tbody>
												</table>
											</txp:if_category>
										<txp:else />
											<txp:article />
									</txp:if_article_list>
							<txp:else />
								<txp:article status="sticky"/>
						</txp:if_variable>

Last edited by qp2wd (2011-09-22 13:54:43)

Offline

#6 2011-09-22 19:44:38

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

Re: No Article tag in default template error

qp2wd wrote:

even though the debug information shows that TXP is correctly recognizing that the page should be outputting <txp:article/>

Can you post a tag trace of that page please?

Offline

#7 2011-09-23 12:42:49

qp2wd
Member
Registered: 2011-01-11
Posts: 24

Re: No Article tag in default template error

Sure thing.

<!-- Runtime:    0.0509 -->
<!-- Query time: 0.025938 -->
<!-- Queries: 21 -->
<!-- Memory: 3874Kb, <txp:custom_field name="price" /> -->
<!-- txp tag trace: 
[SQL (0.014526844024658): select name, data from txp_lang where lang='en-us' AND ( event='public' OR event='common')]
[SQL (0.0018529891967773): select name, code, version from txp_plugin where status = 1 AND type IN (0,1) order by load_order]
[SQL (0.00035619735717773): select * from smd_macro where 1=1]
[SQL (0.00091314315795898): select ID,Section from textpattern where url_title like 'commercial-property-12' AND Section='listings' and Status >= 4 limit 1]
[SQL (0.0003199577331543): select page, css from txp_section where name = 'listings' limit 1]
[SQL (0.00049304962158203): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where ID=29 and Status in (4,5)]
[article 29]
[SQL (0.00054097175598145): select ID, Title, url_title, unix_timestamp(Posted) as uposted
			from textpattern where Posted > '2011-09-22 11:07:30' and Section = 'listings' and Status=4 and Posted < now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') order by Posted asc limit 1]
[SQL (0.00058603286743164): select ID, Title, url_title, unix_timestamp(Posted) as uposted
			from textpattern where Posted < '2011-09-22 11:07:30' and Section = 'listings' and Status=4 and Posted < now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') order by Posted desc limit 1]
[SQL (0.00039410591125488): select host from txp_log where ip='127.0.0.1' limit 1]
[SQL (0.00043487548828125): insert into txp_log set `time`=now(),page='/listings/commercial-property-12',ip='127.0.0.1',host='localhost',refer='',status='200',method='GET']
[SQL (0.00046420097351074): select name,type,IFNULL(unix_timestamp(file_mod_time), 0) as mod_time from txp_form where 1=1]
[SQL (0.00036382675170898): select name,IFNULL(unix_timestamp(file_mod_time), 0) as mod_time from txp_page where 1=1]
[SQL (0.00029993057250977): select name,IFNULL(unix_timestamp(file_mod_time), 0) as mod_time from txp_css where 1=1]
[SQL (0.00032997131347656): select user_html from txp_page where name='default']
[Page: default]
<txp:output_form form="head"/>
	[SQL (0.00041890144348145): select Form from txp_form where name='head']
	[Form: head]
	<txp:site_name />
	<txp:site_url/>
	<txp:site_url/>
	<txp:section/>
<txp:if_section name="default">
	[<txp:if_section name="default">: false]
	<txp:variable name="landing">
		<txp:article status="sticky"/>
	</txp:variable>
	<txp:if_variable name="landing" value="">
		[<txp:if_variable name="landing" value="">: true]
		<txp:if_article_list>
			[<txp:if_article_list>: false]
			<txp:article />
		</txp:if_article_list>
	</txp:if_variable>
</txp:if_section>
<txp:if_section name="default">
	[<txp:if_section name="default">: false]
	<txp:category_list section="listings" wraptag="ul" break="li"/>
		[SQL (0.00049185752868652): select name, title from txp_category where type = 'article' and name not in('default','root')   order by name ASC]
	<txp:smd_featured section="listings" wraptag="article">
		[SQL (0.00028204917907715): select feat_id from smd_featured where 1=1]
		[SQL (0.00066590309143066): SELECT *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod FROM textpattern AS txp LEFT JOIN smd_featured AS smdfeat ON txp.ID=smdfeat.feat_id WHERE smdfeat.feat_id IN ('3') AND Posted <= now() AND (now() <= Expires OR Expires = '0000-00-00 00:00:00') AND Status IN (4,5) AND Section IN ('listings') LIMIT 10]
		[<txp:smd_featured section="listings" wraptag="article">: true]
		[<txp:smd_featured section="listings" wraptag="article">: false]
		[SQL (0.00075197219848633): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where 1=1 and Status >= 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and ID IN (3) order by Posted desc limit 0, 10]
		[article 3]
		<txp:article_image/>
		<txp:title />
		<txp:custom_field name="location" />
		<txp:custom_field name="size" />
		<txp:custom_field name="status" />
		<txp:custom_field name="price" />
	</txp:smd_featured>
</txp:if_section>
<txp:if_section name="default">
	[<txp:if_section name="default">: false]
</txp:if_section>
<txp:output_form form="foot"/>
	[SQL (0.00037503242492676): select Form from txp_form where name='foot']
	[Form: foot]
[ ~~~ secondpass ~~~ ]
 -->

Offline

#8 2011-09-23 18:55:58

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

Re: No Article tag in default template error

qp2wd wrote:

It still gives me a “page template does not contain…” error when I enter a category.

Yes, of course. There is no article tag, only an article_custom tag. Either you can replace it with an article tag, or add <txp:article limit="1" pgonly="1" /> just after the opening <txp:if_category> tag.

Edit: With the following script I was able to get rid of the error message, but when I enter an individual article’s page the article itself still doesn’t show, even though the debug information shows that TXP is correctly recognizing that the page should be outputting <txp:article/>

Your closing </txp:if_category> tag is in the wrong place. But first you can give my code here another try with the abovementioned addition.

Offline

#9 2011-09-23 19:42:37

qp2wd
Member
Registered: 2011-01-11
Posts: 24

Re: No Article tag in default template error

Yes, of course. There is no article tag, only an article_custom tag. Either you can replace it with an article tag, or add <txp:article limit=“1” pgonly=“1” /> just after the opening <txp:if_category> tag.

I tried your original code with a <txp:article /> tag after <txp:if_category> with the same result: while I didn’t get an error message, the article body didn’t show.

To give you some context, here’s what I’m trying to accomplish: When a visitor opens the “landing” section, they see a main content area containing a paragraph saying something along the lines of “x number of listings in the southern maryland area.” To the left, in a sidebar, is a list of categories. When a visitor clicks a category in the sidebar, a list of that category’s articles rendered as a table appears in the content area. When they click on the “more info” button in the rendered table, they’re taken to an individual article page for the corresponding article.

I swear, this is the most trouble I’ve ever had getting an article to render. I know the logic is flawed somewhere, but I’m having the darndest time figuring it out.

Offline

#10 2011-09-23 22:13:47

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

Re: No Article tag in default template error

Going back to your original code here, looking at the tag trace there doesn’t seem to be a problem with the conditionals. Like you said, this part

		<txp:if_article_list>
			[<txp:if_article_list>: false]
			<txp:article />
		</txp:if_article_list>

shows that the individual article context is detected. If no article is displayed, the only reason I can think of is that there is no (live) article in the current section. Is that possible?
What happens if you change <txp:article /> to <txp:article>Yes, an article!</txp:article>?

Last edited by els (2011-09-23 22:14:56)

Offline

#11 2011-09-26 13:36:45

qp2wd
Member
Registered: 2011-01-11
Posts: 24

Re: No Article tag in default template error

I’ve double-checked all the articles. They’re live, and using <txp:article>Yes, an article!</txp:article> came up blank as well. I’m officially stumped. I may end up having to split the landing page and listing pages into two separate sections to make this work, though I’d hate to do it.

Edit: Fixed it! It turns out that TXP just really, really hated my using <txp:article />. Instead, I took the contents of the article form and plopped it directly onto my page template. Voila!

<txp:if_article_list>
					<txp:if_category>
						<table id="tlist">
								<thead>
									<tr>
										<th>&nbsp;</th>
										<th>Name</th>
										<th>Location</th>
										<th>Lot Type</th>
										<th>Size</th>
										<th>Price</th>
										<th>More Info</th>
									</tr>
								</thead>
								<tbody>
									<txp:article_custom category='<txp:category />' section="listings" listform="listings"/>
								</tbody>
						</table>
						<txp:else />
						<p>Now Featuring <txp:mdn_count section="listings" /> listings across Southern Maryland.</p>
					</txp:if_category>
					<txp:else />
					<txp:article_image />
<h1><txp:title/></h1>
<h3><txp:custom_field name="location" /></h3>
<txp:body />
<txp:custom_field name="location" /><br>
<txp:custom_field name="lot_type" /><br>
<txp:custom_field name="size" /><br>
<txp:custom_field name="price" /><br>


					<txp:article form="default" />
				</txp:if_article_list>

I still have no idea why it wasn’t accepting my <txp:article>, though.

Last edited by qp2wd (2011-09-26 13:54:49)

Offline

#12 2011-09-26 20:16:41

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

Re: No Article tag in default template error

qp2wd wrote:

Edit: Fixed it! It turns out that TXP just really, really hated my using <txp:article />. Instead, I took the contents of the article form and plopped it directly onto my page template. Voila!

I still have no idea why it wasn’t accepting my <txp:article>, though.

Neither do I. I read and re-read the tag trace and I still don’t see what could be wrong… Glad you solved it though!

Offline

Board footer

Powered by FluxBB