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,202

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: 10,310
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.

Txp Builders – finely-crafted code, design and Txp

Online

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

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

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,202

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: 8,618
Website GitHub 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.org | hblack.net | State Machines | NeMe @ github
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: 10,310
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.

Txp Builders – finely-crafted code, design and Txp

Online

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

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

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: 4,279
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: 10,310
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.

Txp Builders – finely-crafted code, design and Txp

Online

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

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

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: 8,618
Website GitHub 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.org | hblack.net | State Machines | NeMe @ github
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,202

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

Board footer

Powered by FluxBB