Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-12-25 18:33:04

csaba
Member
Registered: 2007-12-21
Posts: 28

Need help with sticky

I have about 20 categories on my page, and in each category i would like that one specific article to be displayed on the top of the page (sticky, different article in each category). I understand that i have to insert this code

<txp:if_article_list> <!— display the sticky article —> <txp:article form=“myshortform” status=“sticky” />
</txp:if_article_list>

<!— now the regular article list —>
<txp:article limit=5 />

in my template, but where? I’ve tried in several places but i didn’t managed to find the right place in the xhtml code, because each time it changes the look of the page.

Offline

#2 2007-12-25 18:56:40

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: Need help with sticky

Something like this should do it:

<txp:if_individual_article>
<!-- article page: display the live article -->
<txp:article form="article" limit=1 />
</txp:if_individual_article>

<txp:if_article_list>

<txp:if_category>
<!-- category page: display the sticky article first -->
<txp:article status="sticky" form="myshortform" limit=1 />
<!-- then the rest of the category articles -->
<txp:article form="article" limit="10" />
<txp:else />
<!-- section page: -->
<txp:article form="article" limit="10" />
</txp:if_category>

</txp:if_article_list>

Last edited by jstubbs (2007-12-25 18:56:54)

Offline

#3 2007-12-25 21:08:38

csaba
Member
Registered: 2007-12-21
Posts: 28

Re: Need help with sticky

Thanks but unfortunately still no luck..

This is what i have in my template in the body, until the footer:

<div id="primary-menu"<txp:if_category>class="dontmark"</txp:if_category>>
		<h1>Meniu</h1>
		<txp:ako_nav name="Home,About,Articles,Archive,Contact" url="/,/about,/articles,/archive,/contact" headon="0" divon="0" />
	</div>
	<div id="wrapper">
		<div id="header">
			<div class="rounder">&nbsp;</div>
			<h1><txp:link_to_home>TRANSYLVANIAN COINS</txp:link_to_home></h1><h2><span>MONEDE TRANSILVANIA</span></h2>
			<p><txp:site_slogan /></p>
		</div>
		<div id="intro">
			<div id="intro-inner-wrapper">
				<txp:if_individual_article>

					<txp:article_image />
	        				<h2><txp:title /></h2>
							<p><txp:breadcrumb label="Home" title="1" link="y" wraptag="" /> &raquo; <txp:title /> <br/>
Article category is <txp:category1 class="category" link="1" title="1" wraptag="" /> <br/> 
Posted <txp:posted /></p>
					<txp:if_excerpt>
						<br class="clear" />
						<txp:excerpt />
	        		</txp:if_excerpt>
					<txp:cbs_article_index label="Contents:" labeltag="p" wraptag="ol" break="li" />
       			<txp:else />
					<txp:if_section name="search">
						<img src="<txp:site_url />/images/roowhaline/gulden-php.jpg" alt="Gulden" />
						<h2>Search results</h2>
						<p>Rezultatele cautarii:</p>
					</txp:if_section>
       				<txp:if_section name="default">
						<txp:if_category>
							<img src="<txp:site_url />/images/roowhaline/gulden-php.jpg" alt="Gulden" />
							<h2>Category: <txp:category title="1" /></h2>
						</txp:else />
							<img src="<txp:site_url />images/roowhaline/100ducatAv.jpg" alt="Apafi 100 ducat" />

							<p><br /><br />The coins minted over the one and a half century of independence of Transylvania are considered by many specialists as the most beautiful coins ever minted. Here in this small catalogue I will try to present as many as possible of these great coins. None of the coins you see here is for sale!<br /><br /><br />
<i>Monedele batute de Transilvania ca principat independent de-a lungul unui secol si jumatate sunt considerate de multi specialisti din intreaga lume ca cele mai frumoase monede batute vreodata. Aici in acest mic catalog voi incerca sa prezint cat mai multe dintre aceste monede deosebite. Monedele prezentate aici nu sunt de vanzare!</i></p>
						</txp:if_category>	
       				</txp:if_section>
       				<txp:if_section name="about">
       					<img src="<txp:site_url />/images/roowhaline/100ducatAv.jpg" alt="Mushroom Photo" />
						<h2>About</h2>
						<p>Description goes here</p>
       				</txp:if_section>
       				<txp:if_section name="articles">
       					<img src="<txp:site_url />/images/roowhaline/gulden-php.jpg" alt="Gulden" />
						<h2>Articles</h2>
						<p>Description goes here</p>
       				</txp:if_section>
       				<txp:if_section name="archive">
       					<img src="<txp:site_url />/images/roowhaline/gulden-php.jpg" alt="Gulden" />
						<h2>Archive</h2>
						<p>Description goes here</p>
       				</txp:if_section>
       				<txp:if_section name="contact">
       					<img src="<txp:site_url />/images/roowhaline/gulden-php.jpg" alt="Gulden" />
						<h2>Contact</h2>
						<p>Send us a message</p>
       				</txp:if_section>
				</txp:if_individual_article>

			</div>
		</div>
		<div class="poddon">
			<div class="poddon-small"></div>
		</div>		

		<div id="content_wrapper">
			<div id="container">
				<div id="content">
					<txp:if_section name="search">
						<h3>Search results</h3>
						<ul>
							<txp:article form="search_results" />
						</ul>
						<p><txp:search_result_count />.</p>
					</txp:if_section>
					<txp:if_individual_article>
						<txp:article />
					</txp:if_individual_article>
					<txp:if_section name="archive">
						<txp:article_custom limit=99999 section="articles" />
					</txp:if_section>
					<txp:if_section name="contact">
						<h3>Contact</h3>
						<p>You can send me a message through the following contact form.</p>
						<txp:zem_contact to="info@webgrower.ru" label="" subject="Regarding your blog">
							<p><txp:zem_contact_text label="Name:" break="" /></p>
							<p><txp:zem_contact_email label="E-Mail:" break="" /></p>
							<p><txp:zem_contact_textarea cols="25" rows="5" label="Message:" break="" /></p>
							<txp:zem_contact_submit />
						</txp:zem_contact>
					</txp:if_section>
					<txp:if_section name="default">
						<txp:article limit="2" />
						<p>
							<txp:older>&laquo; Older</txp:older>
							<txp:newer>Newer &raquo;</txp:newer>
						</p>
					</txp:if_section>
					<txp:if_section name="articles">
						<txp:article limit="5" />
						<p>
							<txp:older>&laquo; Older</txp:older>
							<txp:newer>Newer &raquo;</txp:newer>
						</p>
					</txp:if_section>
				</div>

				<div id="sidebar">
					<form id="search" action="<txp:site_url/>search/" method="get">
						<label id="sl" for="s">Search </label>
						<input type="text" id="s" name="q" />
						<input type="submit" id="ss" value="&raquo;" />
					</form>

				<txp:category_list wraptag="ul" break="li" class="" label="Categories" labeltag="h3" />
				<txp:recent_articles limit="10" break="li" wraptag="ul" sortby="Posted" sortdir="desc" class="" label="Recent articles" labeltag="h3" />
				<txp:recent_comments limit="10" break="li" wraptag="ul" class="" label="Recent comments" labeltag="h3" />
				<txp:linklist wraptag="ul" break="li" class="" label="Favorite links" labeltag="h3" />

				</div>

				<br class="clear" />

			</div>
		</div>

P.S.
sorry, i can’t find the right way to paste the code..

(Edited to display code properly. -Els. P.S. use bc..)

Last edited by els (2007-12-25 22:40:12)

Offline

#4 2007-12-25 21:31:40

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: Need help with sticky

Which part is not working as you expect it to? And can you condense the code, its a lot to read. Just the pertinent code would be helpful.

Offline

#5 2007-12-25 21:56:24

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Need help with sticky

csaba,

You can use bc. to show code in here at forum, as it uses textile.

To notice:

  • Only one h1, main header is allowed per page. I removed the menu’s h1 and converted it to h2.
  • i-tag is deprecated, use em instead. I converted it also.
  • Frontpage is actually "" (empty) not default as at ie. <txp:if_section name="">
  • Added category based article listing inside frontpage-conditionals, so it should work now.

And here is the corrected code:

<div id="primary-menu"<txp:if_category> class="dontmark"</txp:if_category>>
		<h2 id="menuheader">Meniu</h2>
		<txp:ako_nav name="Home,About,Articles,Archive,Contact" url="/,/about,/articles,/archive,/contact" headon="0" divon="0" />
	</div>
	<div id="wrapper">
		<div id="header">
			<div class="rounder">&nbsp;</div>
			<h1><txp:link_to_home>TRANSYLVANIAN COINS</txp:link_to_home></h1>
			<h2><span>MONEDE TRANSILVANIA</span></h2>
			<p><txp:site_slogan /></p>
		</div>
		<div id="intro">
			<div id="intro-inner-wrapper">
				<txp:if_individual_article>
					<txp:article_image />
	        		<h2><txp:title /></h2>
					<p><txp:breadcrumb label="Home" title="1" link="y" wraptag="" /> &raquo; <txp:title /><br/>Article category is <txp:category1 class="category" link="1" title="1" wraptag="" /><br/>Posted <txp:posted /></p>
					<txp:if_excerpt><br class="clear" /><txp:excerpt /></txp:if_excerpt>
					<txp:cbs_article_index label="Contents:" labeltag="p" wraptag="ol" break="li" />
       			<txp:else />

					<txp:if_section name="search">
						<img src="<txp:site_url />/images/roowhaline/gulden-php.jpg" alt="Gulden" />
						<h2>Search results</h2>
						<p>Rezultatele cautarii:</p>
					</txp:if_section>

	       			<txp:if_section name="">
						<txp:if_category>
							<img src="<txp:site_url />/images/roowhaline/gulden-php.jpg" alt="Gulden" />
							<h2>Category: <txp:category title="1" /></h2>
						</txp:else />
							<img src="<txp:site_url />images/roowhaline/100ducatAv.jpg" alt="Apafi 100 ducat" />
							<p><br /><br />The coins minted over the one and a half century of independence of Transylvania are considered by many specialists as the most beautiful coins ever minted. Here in this small catalogue I will try to present as many as possible of these great coins. None of the coins you see here is for sale!<br /><br /><br /><em>Monedele batute de Transilvania ca principat independent de-a lungul unui secol si jumatate sunt considerate de multi specialisti din intreaga lume ca cele mai frumoase monede batute vreodata. Aici in acest mic catalog voi incerca sa prezint cat mai multe dintre aceste monede deosebite. Monedele prezentate aici nu sunt de vanzare!</em></p>
						</txp:if_category>	
	       			</txp:if_section>

	       			<txp:if_section name="about">
	       				<img src="<txp:site_url />/images/roowhaline/100ducatAv.jpg" alt="Mushroom Photo" />
						<h2>About</h2>
						<p>Description goes here</p>
	       			</txp:if_section>

	       			<txp:if_section name="articles">
	       				<img src="<txp:site_url />/images/roowhaline/gulden-php.jpg" alt="Gulden" />
						<h2>Articles</h2>
						<p>Description goes here</p>
	       			</txp:if_section>

	       			<txp:if_section name="archive">
	       				<img src="<txp:site_url />/images/roowhaline/gulden-php.jpg" alt="Gulden" />
						<h2>Archive</h2>
						<p>Description goes here</p>
	       			</txp:if_section>

					<txp:if_section name="contact">
	       				<img src="<txp:site_url />/images/roowhaline/gulden-php.jpg" alt="Gulden" />
						<h2>Contact</h2>
						<p>Send us a message</p>
	       			</txp:if_section>

				</txp:if_individual_article>

			</div>
		</div>
		<div class="poddon">
			<div class="poddon-small"></div>
		</div>		

		<div id="content_wrapper">
			<div id="container">
				<div id="content">
					<txp:if_section name="search">
						<txp:if_search>
							<h3>Search results</h3>
							<ul><txp:article form="search_results" /></ul>
							<p><txp:search_result_count />.</p>
						</txp:if_search>
					</txp:if_section>

					<txp:if_individual_article>
						<txp:article />
					</txp:if_individual_article>

					<txp:if_section name="archive">
						<txp:article_custom limit="99999" section="articles" />
					</txp:if_section>

					<txp:if_section name="contact">
						<h3>Contact</h3>
						<p>You can send me a message through the following contact form.</p>
						<txp:zem_contact to="info@webgrower.ru" label="" subject="Regarding your blog">
							<p><txp:zem_contact_text label="Name:" break="" /></p>
							<p><txp:zem_contact_email label="E-Mail:" break="" /></p>
							<p><txp:zem_contact_textarea cols="25" rows="5" label="Message:" break="" /></p>
							<txp:zem_contact_submit />
						</txp:zem_contact>
					</txp:if_section>

					<txp:if_section name="">
						<txp:if_category>
							<txp:if_article_list>
								<txp:article form="myshortform" status="sticky" limit="1" />
								<txp:article limit="5" />
							</txp:if_article_list>
						<txp:else />
							<txp:if_article_list>
								<txp:article limit="2" />
							</txp:if_article_list>
						</txp:if_category>
						<p><txp:older>&laquo; Older</txp:older> <txp:newer>Newer &raquo;</txp:newer></p>
					</txp:if_section>

					<txp:if_section name="articles">
						<txp:article limit="5" />
						<p><txp:older>&laquo; Older</txp:older> <txp:newer>Newer &raquo;</txp:newer></p>
					</txp:if_section>
				</div>

				<div id="sidebar">
					<form id="search" action="<txp:site_url/>search/" method="get">
						<label id="sl" for="s">Search </label>
						<input type="text" id="s" name="q" />
						<input type="submit" id="ss" value="&raquo;" />
					</form>
					<txp:category_list wraptag="ul" break="li" class="" label="Categories" labeltag="h3" />
					<txp:recent_articles limit="10" break="li" wraptag="ul" sortby="Posted" sortdir="desc" class="" label="Recent articles" labeltag="h3" />
					<txp:recent_comments limit="10" break="li" wraptag="ul" class="" label="Recent comments" labeltag="h3" />
					<txp:linklist wraptag="ul" break="li" class="" label="Favorite links" labeltag="h3" />
				</div>
				<br class="clear" />
			</div>
		</div>

Cheers!

Last edited by Gocom (2007-12-25 21:58:31)

Offline

#6 2007-12-26 14:45:21

csaba
Member
Registered: 2007-12-21
Posts: 28

Re: Need help with sticky

Thanks for your help.
But the articles which i select “sticky” are still not displayed on the top of the page in the categories. They disappear from the list of articles, but they are not displayed anywhere.

Offline

#7 2007-12-26 15:43:56

csaba
Member
Registered: 2007-12-21
Posts: 28

Re: Need help with sticky

In Gocom’s code i’ve changed this part

bc..
<txp:if_article_list> <txp:article form=“myshortform” status=“sticky” limit=“1” /> <txp:article limit=“5” />
</txp:if_article_list>

i removed the
bc..
form=“myshortform”
part, and now the sticky articles are displayed on top of the page in each category, but none of the main (home) page. Also if i click on “continue reading” at one article which is marked as sticky, then on the next page the article is not displayed, i get only an empty page.

What’s that form=“myshortform” ?
I have no such form installed..

Offline

#8 2007-12-26 16:02:15

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

Re: Need help with sticky

The article form ‘myshortform’ that Gocom mentioned is just an example. You have to create article forms to be used by your various articles. Something like this:

Form ‘yourstickyform’ for sticky articles:

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

Form ‘yourshortform’ for article lists:

<h3><txp:permlink><txp:title /></txp:permlink></h3>
<txp:excerpt />

Form ‘yoursingleform’ for individual articles:

<h3><txp:permlink><txp:title /></txp:permlink></h3>
<p>Posted by: <txp:author /> on <txp:posted /> in category <txp:category1 title="1" link="1" /></p>
<txp:body />

If you also want a sticky article to be displayed on the home page, you should change your code to something like this.

<txp:if_section name="">
	<txp:if_category>
		<txp:article form="yourstickyform" status="sticky" limit="1" />
                <!-- create a sticky article for each category -->
		<txp:article listform="yourshortform" limit="5" />
	<txp:else />
                <txp:article_custom id="123" form="yourstickyform" />
                <!-- article #123 is your sticky article for the home page -->
		<txp:article listform="yourshortform" limit="2" />
	</txp:if_category>
	<p><txp:older>&laquo; Older</txp:older> <txp:newer>Newer &raquo;</txp:newer></p>
</txp:if_section>

Because section default (section="") is always an article list (either a category list or the home page) you don’t need the if_article_list tags.

Last edited by els (2007-12-26 16:03:21)

Offline

#9 2007-12-27 21:47:56

csaba
Member
Registered: 2007-12-21
Posts: 28

Re: Need help with sticky

Thanks Els for your help.. all is fine after i created a form for the “sticky” articles.

Offline

Board footer

Powered by FluxBB