Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2021-01-20 09:56:20

Gallex
Member
Registered: 2006-10-08
Posts: 1,289

Re: if individual article, if category, if section...

colak wrote #328246:

Are article ids 25,176,274,140,161,134, sticky articles?

no

Offline

#14 2021-01-20 10:01:04

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: if individual article, if category, if section...

Gallex wrote #328249:

are you saying that i must choose a category to this sticky article too? mine was saved only to section tooted.

i saved it to tooriistad konksud category. now it displays only tooriistad konksud category block. do i need sticky article for each category, i can’t use one for all (like i was hoped)?

You can have a headless section, write an article and save it as sticky in that headless section, and then inlclude

<txp:article_custom id="##" section="your_headless_section" form="your_form" status="sticky" /> in your templates.

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#15 2021-01-20 10:09:33

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: if individual article, if category, if section...

Gallex wrote #328249:

are you saying that i must choose a category to this sticky article too? mine was saved only to section tooted.

i saved it to tooriistad konksud category. now it displays only tooriistad konksud category block. do i need sticky article for each category, i can’t use one for all (like i was hoped)?

That’ll be your problem ;-)

If you look at your code:

...
	<txp:if_category>
		<div class="container bg-4">
			<txp:article status="sticky" form="untitled" />
		</div>
	<txp:else />
...

… you’ll see that this code is only displayed if your URL contains a category (?c=… or an /section/category/ url scheme). txp:article is context-sensitive, so it will automatically filter by that category. That’s why you see it when you assign it to the category (like you did just now) and don’t see it when it’s assigned just to the section.

The solution is easy: swap out the context-sensitive txp:article for txp:article_custom:

...
	<txp:if_category>
		<div class="container bg-4">
			<txp:article_custom id="999" status="sticky" form="untitled" />
		</div>
	<txp:else />
...

replacing 999 with the article id number of the article.

colak wrote #328251:

You can have a headless section, write an article and save it as sticky in that headless section…

That would work too (same basic principle) but a separate hidden/headless/pageless section is not strictly necessary if the sticky article is already hidden from display on that section’s landing page.


TXP Builders – finely-crafted code, design and txp

Offline

#16 2021-01-20 10:15:36

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: if individual article, if category, if section...

etc wrote #328238:

Just for fun, you could (try to) rewrite

<txp:if_first_image><txp:image /><txp:else /><txp:thumbnail /></txp:if_first_image>...

as

<txp:image thumbnail='<txp:if_first_image not />' />...

Just love these little tricks of yours. Nice and succinct, though perhaps not as readable for a beginner to follow.


TXP Builders – finely-crafted code, design and txp

Offline

#17 2021-01-20 10:32:28

Gallex
Member
Registered: 2006-10-08
Posts: 1,289

Re: if individual article, if category, if section...

jakob wrote #328252:

… you’ll see that this code is only displayed if your URL contains a category (?c=… or an /section/category/ url scheme). txp:article is context-sensitive, so it will automatically filter by that category. That’s why you see it when you assign it to the category (like you did just now) and don’t see it when it’s assigned just to the section.

The solution is easy: swap out the context-sensitive txp:article for txp:article_custom:

yess!! thank you jakob and all others!
one more little problem – i get error on each category page:

Tag error:  ->  Textpattern Notice: Page template default does not contain a txp:article tag. while parsing form Ükski on page default
textpattern/publish.php:748 trigger_error()
index.php:74 textpattern()

Offline

#18 2021-01-20 10:48:49

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: if individual article, if category, if section...

Gallex wrote #328256:

one more little problem – i get error on each category page:

Tag error: -> Textpattern Notice: Page template default does not contain a txp:article tag. while parsing form Ükski on page default...

It’s just a notice (you have txp:article_custom there instead) and when you switch to live (and maybe testing too) it will disappear.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB