Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-07-24 22:10:50

Infi
Member
Registered: 2005-05-28
Posts: 75

Show a sticky first for every section, cat, chapter & verse...

It’s a software manual. I haven’t experimented much with custom fields or advanced setups, so please bear with me.

The introduction, chapter 1, chapter 2, etc. will all have one post that should be shown first when that section is hit (no matter how it’s hit or from where) and setting a sticky for each chapter (section) would be the best way to do it, I would think, except…

Sticky works by removing it from the article flow altogether when all I want is for one in the flow to be on top at the section level and each category article shown by itself. Also, the instructions of each chapter aren’t entered or modified in any particular order.

If I use:
<code><txp:if_article_list>
<txp:article status=“sticky” limit=1 />
<txp:else />
<txp:article limit=1 />
</txp:if_article_list></code>
…the sticky always shows – period – and I can’t get to the rest via a menu link. (They’re in the same section, but a different category.)

So, I thought a custom field sort order would help, but that’s not working too well, either. I’ve experimented with On Front Page/Not On Front Page and that’s a nightmare I’d sooner forget. Perhaps, there’s a better way to go about it than using a sticky at all?

I know someone has done this before; that it’s really, really simple; and I just can’t get my head around it. Overworking the problem. Now, I’m fried.

Pointers?

Offline

#2 2006-07-24 22:36:08

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

Re: Show a sticky first for every section, cat, chapter & verse...

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

	<txp:article />
<txp:else />
	<txp:article />
</txp:if_article_list>

?

Offline

#3 2006-07-24 23:52:38

Infi
Member
Registered: 2005-05-28
Posts: 75

Re: Show a sticky first for every section, cat, chapter & verse...

Yeah, that’s what I tried first, but when I click to another category (same section) the sticky is there because it’s the right section and can’t get anywhere else and… this is probably all in the setup of sections and categories, some of which have the same name. Gah. (Lot of chapters and verses.)

I have to get my head out of print ….

Offline

#4 2006-07-25 03:54:31

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

Re: Show a sticky first for every section, cat, chapter & verse...

Yeah, that’s what I tried first…

Er, I don’t think you did – my posted code is different than what you posted. For one thing, it shows more than the sticky.

…the sticky is there because it’s the right section…

You don’t want the sticky to show at all?

…and can’t get anywhere else…

What does that mean? Do you mean you don’t get navigation links? Add older and newer tags.

Offline

#5 2006-07-25 12:35:05

Infi
Member
Registered: 2005-05-28
Posts: 75

Re: Show a sticky first for every section, cat, chapter & verse...

That’s what I tried first…

Mary wrote:

Er, I don’t think you did – my posted code is different than what you posted. For one thing, it shows more than the sticky.

Right. But this shows two articles on the page: The sticky and the first in the regular flow. What I need is for the sticky to show when the section is hit and articles assigned to the same section in various categories to show when the category is hit.

So, when the menu item “Introduction” is clicked, one (of four) introductory “articles” will be sticky. When the categories of the other three are chosen, those “live” articles will show, each by themselves.

The wow_menu is on the left. Intro, chapters are all sections. Click “Introduction” and the first article of intro (sticky) shows. The next menu item “C Applications” is also an intro section article, but a different category. It won’t show up because the intro’s sticky is there. It will show up with your code, but I never want two articles on one page.

That’s the dilemma. And what got me thinking I needed a sort order, rather than sticky to do this. Can’t really imagine custom fielding a sort order on every article in this 8 chapter “book”, but that’s the only other thing I can think of. :/ Must be a better way.

Interior nav works fine and will have to find a way to sort those in some kind of order, but I’m sure that’s what I’ll be tackling today. :)

Offline

#6 2006-07-25 15:04:19

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Show a sticky first for every section, cat, chapter & verse...

Hi Infi,

I’m not sure if I understand your question, but maybe this can help you:

http://forum.textpattern.com/viewtopic.php?id=12784

bye!


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#7 2006-07-25 15:42:25

Infi
Member
Registered: 2005-05-28
Posts: 75

Re: Show a sticky first for every section, cat, chapter & verse...

Um, not really. But thanks for a good tip!

<code><txp:article form=“default” listform=“listado” status=“sticky” />
<txp:article form=“default” listform=“listado” status=“live” /></code>

…is essentially the same as:

<code>
<txp:article status=“sticky” limit=“1” />
<txp:article limit=“1” />
</code>

Shows two articles (a sticky and a live) on one page.

Individual articles (the problem resolved on that thread) are not an issue at all. I guess what I’m looking for is a kind of “sort” that will show one article that I specify first in a list of regular flow articles, but not interfere with others in the flow when a category is clicked.

EDIT

Aside: I’ve often wished for an “order of display” field on the article list in admin. Each section’s articles could then be numbered in the specific order the user wants them displayed, much as wow_menu’s manual ordering works for menus. (Would make it much easier to build a static site, too.) Any left blank, would be randomized.

Is this already possible in TXP? If not, do you think it is a viable feature request?

Last edited by Infi (2006-07-25 18:43:51)

Offline

#8 2006-07-25 18:41:18

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

Re: Show a sticky first for every section, cat, chapter & verse...

Don’t know if I understand this, but is something like this what you are looking for?
<code>
<txp:if_article_list>
<txp:if_category>
<txp:article limit=“xx” />
<txp:else />
<txp:article status=“sticky” limit=1 />
</txp:if_category>
</txp:if_article_list>
<txp:if_individual_article>
<txp:article limit=1 />
</txp:if_individual_article>
</code>
I added <txp:if_individual_article> because I’m not sure you can have two <txp:else />’s.

Offline

#9 2006-07-25 18:50:46

Infi
Member
Registered: 2005-05-28
Posts: 75

Re: Show a sticky first for every section, cat, chapter & verse...

Bless Pat, I think that’ll work. Thanks, Els!

Offline

#10 2006-07-25 19:04:53

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

Re: Show a sticky first for every section, cat, chapter & verse...

Could you use the

<txp:if_category>
<txp:else />
</txp:if_category>

Tags to give you that functionality?

(Edit: updated so your code would display properly. :) -Mary)

Last edited by Mary (2006-07-26 00:54:23)


Offline

#11 2006-07-26 21:10:59

Infi
Member
Registered: 2005-05-28
Posts: 75

Re: Show a sticky first for every section, cat, chapter & verse...

Well… I ran into the same issue when accessing a third level category on the tree: The document didn’t show. Nothing showed. After much midnight oil and in utter frustration, I threw in a <code><txp:if_different></code>, thinking that would accomplish nothing at all.

It did: The third showed up. What’s “different” about it, I don’t know. :) Combining elements from all your suggestions, I wound up with this:

<code>
<txp:if_article_list>
<txp:if_category>
<txp:article limit=“1” status=“sticky” />
</txp:else />
<txp:article limit=“1” />
</txp:if_category>
<txp:if_different>
<txp:article limit=“1” />
</txp:if_different>
</txp:if_article_list>
</code>
<br />

If the articles are categorized from the lowest level to the next highest (rather than top > down), it does actually work. I do get a duplicate – a sticky + an if_different on second-level clicks. (At the tip-top level, it’s the exact same article.)

If anyone could please explain to me why that worked to bring up the third level, it may get me headed in the right direction to solve that problem.

In sum, category menu clicks result in this:

  • First level Cat = One nice sticky article
  • Second Level Cat = One sticky + one if_different<br />
  • Third Level Cat = One regular article

P.S. Moving the if_different in between the if_category tags made my nice, little third-level article go bye-bye. So, that’s not the answer. :) I’ll probably wind up building the nav manually and using category name, then an article list to get around as this doesn’t appear likely to work, but it may give somebody ideas for getting to those pesky lower level categories.

EDIT

Duh moment of the day: I’m guessing the third level appeared because it didn’t strictly fall within the typical two-category TXP norm. Maybe…

Last edited by Infi (2006-07-27 00:19:58)

Offline

#12 2006-07-28 23:31:31

Infi
Member
Registered: 2005-05-28
Posts: 75

Re: Show a sticky first for every section, cat, chapter & verse...

Got it.

To designate an introductory article for every single category you’ve got (without interfering with the regular flow), don’t use stickies at all, but a custom field.

Final Solution:

<code>
<txp:if_article_list>
<txp:if_category>
<txp:article limit=“1” sortby=“custom_1” sortdir=“desc” />
<txp:else />
<txp:article_custom category=“introduction” intro=“1” />
</txp:if_category>
</txp:if_article_list>

<txp:if_individual_article>
<txp:article limit=“1” />
</txp:if_individual_article>
</code>

  • Field custom_1 (“intro”) takes a “1” to indicate an article is to be at the top of a list of regular flow articles. (Other articles require no entry, so no need to order every one. Only one article per category should be designated by the user as an introduction at write time, o’ course.)
  • To show each category’s intro first every time their respective menu items are chosen, sort the articles in descending order.
  • The “else” covers the root directory. With no section or category specified in the URL (www.yourdomain.com/), TXP will serve up the first it sees. Specifying the top level document, takes care of that problem.

Using this, I’m able to categorize top > down, backward/forward or inside > out (makes no difference) and specify an introduction to every chapter of the book. I’m also able to use the automatically generated wow_menu to order the categories according to chapter and verse. :)

Thanks for all the help guys!

Last edited by Infi (2006-07-29 00:27:55)

Offline

Board footer

Powered by FluxBB