Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#13 2021-01-20 09:56:20
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,289
Re: if individual article, if category, if section...
Offline
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
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
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
fortxp: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
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