Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2021-01-19 14:12:14

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

if individual article, if category, if section...

all works well until a sticky article – it doesn’t display content inside it.
could anybody help me to solve this?

page:

<txp:if_section name="tooted">
<section class="content-1">
<txp:output_form form="tooted" />
</section>

form tooted:

<txp:if_individual_article>
<div class="container bg-4">
<txp:article form="" limit="1">
<div class="tulbad-2">
<div>
<h1><txp:title /></h1>
<txp:body />
</div><div>
<txp:if_article_image><txp:images auto_detect="article" wraptag="ul" break="" class="article-album">

    <txp:if_first_image>
        <li class="latest">
         <a href="<txp:image_url />" data-fancybox="preview" data-caption='<txp:image_info type="caption" />'>
          <txp:image />
         </a>
        </li>
    <txp:else />
        <li>
          <a href="<txp:image_url />" data-fancybox="preview" data-caption='<txp:image_info type="caption" />'>
           <txp:thumbnail />
          </a>
        </li>
    </txp:if_first_image>

</txp:images>
</txp:if_article_image>
</div></div>
</txp:article>
</div>

<txp:else />

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

<txp:else />

<div class="container bg-4">
<txp:article wraptag="div" break="div" class="tulbad-2 cat" limit="200" sort="Category1 asc">
<h4 class="product-title"><txp:permlink><txp:title /></txp:permlink></h4>
<div class="flex-diff">
<div class="flexbox-small">
<div class="cat-img"><txp:permlink><txp:article_image /></txp:permlink></div>
</div>
<div class="flexbox-big">
<txp:if_excerpt><txp:excerpt /><txp:else /><txp:body /></txp:if_excerpt>
</div>
</div>
</txp:article>
</div>

</txp:if_category>
</txp:if_individual_article>

article with status sticky:

<txp:if_category name="sporditarvikute-konksud">

<div class="tulbad-2">
<div class="toote-bg">

<txp:image id="209" />

</div>
<div>

<txp:article_custom id="25,176,170,182,272" form="title_and_amount"  limit="500" sort="ID asc" wraptag="ul" break="" class="list-icons" />

</div>
</div>

</txp:if_category>

<txp:if_category name="korvid">

<div class="tulbad-2">
<div class="toote-bg">

<txp:image id="214" />

</div>
<div>

<txp:article_custom id="25,176,77,80,92,107,239" form="title_and_amount"  limit="500" sort="ID asc" wraptag="ul" break="" class="list-icons" />

</div>
</div>
</txp:if_category>

<txp:if_category name="tooriistade-konksud">

<div class="tulbad-2">
<div class="toote-bg">

<txp:image id="219" />

</div>
<div>

<txp:article_custom id="25,176,274,140,161,134" form="title_and_amount"  limit="500" sort="ID asc" wraptag="ul" break="" class="list-icons" />

</div>
</div>

</txp:if_category>

Offline

#2 2021-01-19 14:26:02

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,498
Website GitHub

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

I’m confused. A few immediate things:

  1. <txp:if_category">: Why the extra double quote?
  2. The above tag is inside the ‘else’ portion of a <txp:if_individual_article>. In other words, it only runs if the page is an article list (landing page). The URL you posted looks like an individual article.
  3. <txp:if_category> will only display its content if the URL is of type example.org/category/some-cat-name. Again, your URL is an individual article so even if you did have your sticky article tag in the right place, it wouldn’t show up.

The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#3 2021-01-19 14:35:15

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

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

Bloke wrote #328231:

I’m confused. A few immediate things:

  1. <txp:if_category">: Why the extra double quote?
  2. The above tag is inside the ‘else’ portion of a <txp:if_individual_article>. In other words, it only runs if the page is an article list (landing page). The URL you posted looks like an individual article.
  3. <txp:if_category> will only display its content if the URL is of type example.org/category/some-cat-name. Again, your URL is an individual article so even if you did have your sticky article tag in the right place, it wouldn’t show up.

fixed the typo. the url is a category page, stef.

Offline

#4 2021-01-19 14:45:34

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

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

Bloke wrote #328231:

I’m confused. A few immediate things:

  1. <txp:if_category> will only display its content if the URL is of type example.org/category/some-cat-name.

the URL i posted is of type example.org/section/some-cat-name. is this the case?

Last edited by Gallex (2021-01-19 14:46:06)

Offline

#5 2021-01-19 14:56:36

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

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

what if you change

<txp:article_custom id="25,176,274,140,161,134" form="title_and_amount"  limit="500" sort="ID asc" wraptag="ul" break="" class="list-icons" />

to

<txp:article_custom  status="sticky"  id="25,176,274,140,161,134" form="title_and_amount"  limit="500" sort="ID asc" wraptag="ul" break="" class="list-icons" />

?


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

Offline

#6 2021-01-19 15:03:44

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,498
Website GitHub

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

Gallex wrote #328233:

the URL i posted is of type example.org/section/some-cat-name. is this the case?

I don’t know. Is section/category a thing on its own? If you want to trigger /section/category without title then you need a trailing slash in your URL.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#7 2021-01-19 18:29:30

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,218
Website GitHub

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

Like Bloke said, your URL must be a category url for it to work. If you haven’t got a custom URL scheme in place try first with the simple approach of your section plus the section as an URL parameter:

https://kenovoeesti.ee/tooted?c=tooriistade-konksud

You also need an article with sticky status in that section and category.

Otherwise, you can avoid some repetition in your code making it easier to debug. Personally, I also find indentation helps immensely to keep track of which if…else condition your code blocks are:

Page:

<txp:if_section name="tooted">
	<section class="content-1">
		<txp:output_form form="tooted" />
	</section>
</txp:if_section>

Form tooted:

<txp:if_individual_article>

	<div class="container bg-4">
		<txp:article limit="1">
			<div class="tulbad-2">
				<div>
					<h1><txp:title /></h1>
					<txp:body />
				</div>
				<div>
				<txp:if_article_image>
					<txp:images auto_detect="article" wraptag="ul" break="" class="article-album">

				        <li<txp:if_first_image> class="latest"</txp:if_first_image>>
				        	<a href="<txp:image_url />" data-fancybox="preview" data-caption='<txp:image_info type="caption" />'>
						 	<txp:if_first_image><txp:image /><txp:else /><txp:thumbnail /></txp:if_first_image>
				        	</a>
				        </li>

					</txp:images>
				</txp:if_article_image>
				</div>
			</div>
		</txp:article>
	</div>

<txp:else />

	<txp:if_category>

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

	<txp:else />

		<div class="container bg-4">
			<txp:article wraptag="div" break="div" class="tulbad-2 cat" limit="200" sort="Category1 asc">
				<h4 class="product-title"><txp:permlink><txp:title /></txp:permlink></h4>
				<div class="flex-diff">
					<div class="flexbox-small">
						<div class="cat-img">
							<txp:permlink><txp:article_image /></txp:permlink>
						</div>
					</div>
					<div class="flexbox-big">
						<txp:if_excerpt><txp:excerpt /><txp:else /><txp:body /></txp:if_excerpt>
					</div>
				</div>
			</txp:article>
		</div>

	</txp:if_category>

</txp:if_individual_article>

Sticky status articles:

<txp:if_category name="sporditarvikute-konksud">
	<txp:variable name="cat_bg_img">209</txp:variable>
	<txp:variable name="cat_article_ids">25,176,170,182,272</txp:variable>
</txp:if_category>

<txp:if_category name="korvid">
	<txp:variable name="cat_bg_img">214</txp:variable>
	<txp:variable name="cat_article_ids">25,176,77,80,92,107,239</txp:variable>
</txp:if_category>

<txp:if_category name="tooriistade-konksud">
	<txp:variable name="cat_bg_img">219</txp:variable>
	<txp:variable name="cat_article_ids">25,176,274,140,161,134</txp:variable>
</txp:if_category>

<div class="tulbad-2">
	<div class="toote-bg">
		<txp:image id='<txp:variable name="cat_bg_img" />' />
	</div>
	<div>
		<txp:article_custom id='<txp:variable name="cat_article_ids" />' form="title_and_amount" sort="ID asc" wraptag="ul" break="" class="list-icons" />
	</div>
</div>

Some comments:

  • If you’re using a txp:article(_custom) tag as a container tag, there’s no need to zero out the form attribute.
  • If you specify particular article id numbers in txp:article_custom, the limit attribute of 500 is not needed when you specify six specific articles
  • You’re going to get empty divs if you have no article image (but that might be intentional). Place them inside the if_article_image if they should not appear.

TXP Builders – finely-crafted code, design and txp

Offline

#8 2021-01-19 20:56:35

etc
Developer
Registered: 2010-11-11
Posts: 5,689
Website GitHub

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

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 />' />

Offline

#9 2021-01-19 21:59:58

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,498
Website GitHub

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

etc wrote #328238:

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

Clever!


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#10 2021-01-20 08:49:05

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

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

colak wrote #328234:

what if you change

<txp:article_custom id="25,176,274,140,161,134" form="title_and_amount" limit="500" sort="ID asc" wraptag="ul" break="" class="list-icons" />...

to

<txp:article_custom status="sticky" id="25,176,274,140,161,134" form="title_and_amount" limit="500" sort="ID asc" wraptag="ul" break="" class="list-icons" />...

?

no change

Offline

#11 2021-01-20 09:31:25

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

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

Gallex wrote #328245:

no change

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


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

Offline

#12 2021-01-20 09:55:38

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

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

jakob wrote #328236:

You also need an article with sticky status in that section and category.

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)?

Offline

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

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

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,395
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: 5,218
Website GitHub

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

Board footer

Powered by FluxBB