Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2024-08-10 16:00:32

skewray
Member
From: Sunny Southern California
Registered: 2013-04-25
Posts: 187
Website

custom_field not working for sticky articles

Everybody’s second-favorite search engine, Bing, says that <title> in the <head> should be 50-70 characters. To get that done, I did:

<title>
  <txp:if_custom_field name="seo_title">
    <txp:custom_field name="seo_title" />
  <txp:else />
    <txp:page_title />
  </txp:if_custom_field>
</title>

It works fine on regular articles, but everything between the <title></title> is empty for sticky articles. How do I make this work for all articles?

Offline

#2 2024-08-11 08:30:33

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

Re: custom_field not working for sticky articles

I can’t remember exactly, but I suspect that if you are on a section landing page which displays the sticky article, your page probably does not know about the article at that point in the page code.

You could try:

  • wrapping the code in if_individual_article
  • wrapping the code in a txp:article tag. That might disrupt other occurrences of the code further down the page.
  • a clever routine by which you output the custom_field in a variable further down the page, and for your page title you test for that variable, but defer the test until after the main article tag has been processed. See this thread for more on that

TXP Builders – finely-crafted code, design and txp

Offline

#3 2024-08-11 14:52:12

skewray
Member
From: Sunny Southern California
Registered: 2013-04-25
Posts: 187
Website

Re: custom_field not working for sticky articles

Thank you, Jakob. I would never have figured this out on my own. I’ll post an update when I pick a solution that works for me.

Offline

#4 2024-08-12 20:24:23

skewray
Member
From: Sunny Southern California
Registered: 2013-04-25
Posts: 187
Website

Re: custom_field not working for sticky articles

In the end, I wrapped the above with if_individual_article and used a list of three if_sections in the else, rather than do something arcane and difficult to maintain with processing and variables.

Offline

#5 2024-08-15 18:21:03

skewray
Member
From: Sunny Southern California
Registered: 2013-04-25
Posts: 187
Website

Re: custom_field not working for sticky articles

I realized that what I did doesn’t work for category listings. However, I can’t figure out how to fix it. So, I put the following into <head> on the page,

  <txp:if_category>
    <!-- TEST -->
  </txp:if_category>

but I don’t get the comment output for a category list. Is this similar, where the page doesn’t know that it is an article listing yet?

Offline

#6 2024-08-16 09:23:47

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,419
Website GitHub

Re: custom_field not working for sticky articles

<txp:if_category> only responds to URLs of the form /category/some-cat-name (or ?c=some-cat-name). If you want to compare individual article category 1 and 2, then you need to use <txp:if_article_category>.

Hope that helps.


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 2024-08-16 15:43:22

skewray
Member
From: Sunny Southern California
Registered: 2013-04-25
Posts: 187
Website

Re: custom_field not working for sticky articles

I think I figured out this (to me) mystery. My category lists are using my landing page. I didn’t realize that site/articles?c=XXX and site/category/XXX use different pages. I recently switched my site from the first to the second and didn’t think about this side effect.

I don’t see a tag to return a category description. Is that possible? I notice that if_description doesn’t have a category context. Or a section context.

Last edited by skewray (2024-08-16 16:02:17)

Offline

#8 2024-08-16 16:34:16

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,419
Website GitHub

Re: custom_field not working for sticky articles

skewray wrote #337648:

My category lists are using my landing page.

Yes. Unless you override it in the tag, the endpoint is the front page, so category and author list handling should go there. I should have mentioned that, sorry. Glad you figured it out.

I don’t see a tag to return a category description. Is that possible?

Look at the meta_description tag.


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

#9 2024-08-17 03:04:23

skewray
Member
From: Sunny Southern California
Registered: 2013-04-25
Posts: 187
Website

Re: custom_field not working for sticky articles

Yes, meta_description is what I was looking for.

I don’t know what “Unless you override it in the tag” means. What tag? The only override I know about is the override on the forms admin panel, and I don’t know what that does either.

Offline

#10 2024-08-17 06:06:58

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,419
Website GitHub

Re: custom_field not working for sticky articles

skewray wrote #337652:

I don’t know what “Unless you override it in the tag” means.

Sorry. Ignore me. I was thinking of search, which can be redirected to a different section. Apologies for the confusion.

The only override I know about is the override on the forms admin panel, and I don’t know what that does either.

If you mean Override form on the Write panel, that just allows you to send a particular article through a specific form, instead of it using default or the form= attribute given in the <txp:article> tag.

So if you had, say, a special article that didn’t follow the normal layout, and required dedicated markup, you could tell Txp to use a different form to render it on the website by specifying the form you want use in the article’s Override form field.


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

#11 2024-08-17 15:20:46

skewray
Member
From: Sunny Southern California
Registered: 2013-04-25
Posts: 187
Website

Re: custom_field not working for sticky articles

I also noticed your Override Form and didn’t know what it did either. I was thinking of the Override in the pull down at the bottom of the admin panel forms page, though.

Offline

Board footer

Powered by FluxBB