Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-04-09 16:52:36

Kushman
New Member
Registered: 2006-04-09
Posts: 8

Tag unavailable in form

Hi, I’ve been looking ariund for some time now and cannot find a solution to my problem. Although I imagine it must be quite a common problem.

I have a sidebar form in my template and when I call the tag <txp:category1 /> on a article page, nothing is echoed.

If I call the same tag on the form that actually displays the article it echos the category name correctly.

To note: The sidebar form is called on the page after the article display tag.

Any ideas?

(edited to show code. How do I post tags and code on the forum? -Els)

Last edited by els (2006-04-09 18:11:08)

Offline

#2 2006-04-09 17:40:44

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Tag unavailable in form

We would need to see how you are calling it. You can display code here wrapped in < code>< /code> tags (without the spaces).


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#3 2006-04-09 17:57:55

Kushman
New Member
Registered: 2006-04-09
Posts: 8

Re: Tag unavailable in form

No problem…

This is the code for the static_article form:

<code>
<h3><txp:title /></h3>
<txp:body />

<p> cat:</p>
<p><txp:category1 /></p>
</code>

This is the code for the Sidebar form:

<code>
<!— Sidebar ====================================== —>
<div id=“sidebar”>
<div class=“column”>

<form id=“search” action=”“ method=“get”>
<p><label for=“s”>Search </label>
<input type=“text” id=“s” name=“q” /></p>
</form>

<h3>Services</h3> <div class=“web_chip”><a href=“category/Web-design/”></a></div> <div class=“market_chip”><a href=“category/Web-marketing/”></a></div> <div class=“brand_chip”><a href=“category/branding/”></a></div> <div class=“host_chip”><a href=“category/hosting/”></a></div>

<!— <txp:category_list wraptag=“ul” break=“li” class=”“ /> —>
<h3>Information</h3><ul>
<li><a href=”/new/contact”>Contact Us</a></li>
<li><a href=”/new/about”>About Us</a></li>
</ul>
<p> cat:</p>
<p><txp:category1 /></p>

<txp:if_article_category name=“Web-design” number=“1”>
<h3>Available reading</h3>
<ul>
<txp:article_custom form=“sub” category=“web-design” sortby=“Posted” sortdir=“asc” />
</ul>
</txp:if_article_category>

<h3>Recent articles</h3>
<txp:recent_articles limit=“10” break=“li” wraptag=“ul” sortby=“Posted” sortdir=“desc” class=”“ />

<h3>Recent comments</h3>
<txp:recent_comments limit=“10” break=“li” wraptag=“ul” class=”“ />

<h3>Links</h3>
<txp:linklist wraptag=“ul” break=“li” class=”“ />

</div>
<div class=“column”>

<h3>Feeds</h3>
<ul><txp:feed_link label=“RSS Feed” section=“article” flavor=“rss” wraptag=“li” />
<txp:feed_link label=“Atom Feed” section=“article” flavor=“atom” wraptag=“li” />
<txp:link_feed_link label=“Links RSS Feed” wraptag=“li” /></ul>

<h3>Metadata</h3>
<ul>
<li><a href=“http://textpattern.com”>Textpattern 4.0.3</a></li>
<li><a href=“http://validator.w3.org/check?uri=referer”>XHTML 1.0 Stict</a></li>
<li><a href=“http://jigsaw.w3.org/css-validator/check/referer”>CSS
</a></li>
</ul>
</div>
</div><!— end #sidebar —> </code>

Finally, this is the code for the default ‘page’:

<code>
<txp:output_form form=“head” />

<body>
<div id=“wrap”><div id=“wrap2”>

<txp:output_form form=“header” />

<!— Content ====================================== —>
<div id=“main”>

<txp:glx_if_frontpage> <txp:article id=1 form=“static_article” />
<txp:else />

<txp:if_search>
<h3>Search results</h3>
<ul>
<txp:article />
</ul>
<p><txp:search_result_count />.</p>
<txp:else />
<txp:article listform=“excerpt” />
</txp:if_search>

<!—
<txp:if_article_list>
<p><txp:older>Previous</txp:older> <txp:newer>Next</txp:newer></p>
</txp:if_article_list>
—>

</txp:glx_if_frontpage>

</div><!— end #main —>
</div><!— end #wrap2 —>

<txp:output_form form=“sidebar” />
</div><!— end #wrap —>
</body>
</html>
</code>

You will notice that both forms have the code:
<code>
<p> cat:</p>
<p><txp:category1 /></p> </code>

The result is that the static_article form will echo the cat variable value, but the sidebar wont!

I hope that makes things clearer. Any advice?

Last edited by Kushman (2006-04-09 17:59:55)

Offline

#4 2006-04-09 18:16:52

tranquillo
Archived Plugin Author
Registered: 2005-03-07
Posts: 127
Website

Re: Tag unavailable in form

The <code><txp:category1 /></code> tag returns the name of a category to which a given article might be associated. Thus you can’t use it in a page template, but only in a article form. In a page template, the article from which it should fetch the category, is not defined.

“To note: The sidebar form is called on the page after the article display tag.”
That doesn’t change anything, because the article values are unset at the end of the article generating function.

Last edited by tranquillo (2006-04-09 18:18:42)

Offline

#5 2006-04-09 23:19:45

Kushman
New Member
Registered: 2006-04-09
Posts: 8

Re: Tag unavailable in form

dam! I wondered if I could globally scope the variable or something but it looks as if I’m going to have to rethink what I’m attempting to do.

Based on the above template structure is there a way to find out what category the article belongs to and use this information in a conditional tag in form Sidebar?

Much obliged.

Offline

#6 2006-04-10 04:57:06

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Tag unavailable in form

It has to be called from an article tag.

Offline

#7 2006-04-10 08:09:51

Kushman
New Member
Registered: 2006-04-09
Posts: 8

Re: Tag unavailable in form

OK. I’ll have to try it another way. Thanks for your Help tranquillo, Bombsite and Mary.

Offline

Board footer

Powered by FluxBB