Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2021-05-05 09:29:46

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

Re: How about newsletter

What about these two untested methods

<txp:if_article_category>
<txp:meta-description />
</txp:if_article_category>

or

<txp:evaluate test="category1">
<txp:meta-description />
</txp:evaluate>

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

Offline

#14 2021-05-05 11:14:22

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

Re: How about newsletter

planeth wrote #330033:

Each category has a description field, so I tried to use the meta_description tag but this does not work :(

Does it not work if you ‘force’ the context? Combined with what colak suggested:

<txp:if_article_category>
   <txp:meta-description type="category" format="" />
</txp:if_article_category>

Without that, Txp will assume you want the article meta description as that’s the context that’s in scope. Not sure if it’s possible to get the category description this way because it’s tied to the /category URL structure, but it might work.

EDIT: drat, looks like it still relies on the URL category. So it’d require further fudging to match the article category. Untested but something like this:

<txp:if_article_category number="1">
   <txp:category_list categories='<txp:category1 />'>
      <txp:meta_description format="" />
   </txp:category_list>
</txp:if_article_category>

That should temporarily load the $c global by manually calling up the category that matches category1, and then asking for its meta_description. You might still need the type="category" but from memory it checks that context first so it might just work as-is.

You’d need trickery – possibly via <txp:evaluate> – if you want to consider both category1 and category2.

Last edited by Bloke (2021-05-05 11:42:57)


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

Offline

#15 2021-05-05 11:20:23

planeth
Plugin Author
From: Nantes, France
Registered: 2009-03-19
Posts: 215
Website

Re: How about newsletter

Hello Yiannis, thanks. I’ve just tried and it’s not working :/

I suspect that you can’t use this tag outside a category_list context.

Oh and BTW and not at all related: how do you format your block code to have it syntax highlighted?

Offline

#16 2021-05-05 11:26:00

planeth
Plugin Author
From: Nantes, France
Registered: 2009-03-19
Posts: 215
Website

Re: How about newsletter

Sorry Stef, did not see your message :/
I tried your suggestion, with no luck.
The <txp:if_article_category> is working, but it won’t spit out the meta :(

Offline

#17 2021-05-05 11:26:44

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

Re: How about newsletter

See my edit above :)

And syntax highlighting is done by using bc. html then a newline, then your code. or bc. php if it’s PHP code. There are others available.


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

Offline

#18 2021-05-05 11:48:38

planeth
Plugin Author
From: Nantes, France
Registered: 2009-03-19
Posts: 215
Website

Re: How about newsletter

Yay !! You’re the best :D
And you don’t need the type=category" either.

Offline

#19 2021-05-05 14:58:31

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

Re: How about newsletter

planeth wrote #330036:

Oh and BTW and not at all related: how do you format your block code to have it syntax highlighted?

As Stef said. You can also have bc. txp, bc. js, or bc. css. I’m not sure which other ones are supported


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

Offline

#20 2021-05-05 15:35:47

planeth
Plugin Author
From: Nantes, France
Registered: 2009-03-19
Posts: 215
Website

Re: How about newsletter

Oh, great !Thanks :)

Offline

#21 2021-05-05 22:54:53

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,058
Website

Re: How about newsletter

colak wrote #330040:

You can also have bc. txp, bc. js, or bc. css. I’m not sure which other ones are supported

Full list of supported formats under the heading “Displaying code blocks” on the forum help page.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#22 2021-05-06 13:32:16

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

Re: How about newsletter

Bloke wrote #330035:

You’d need trickery – possibly via <txp:evaluate> – if you want to consider both category1 and category2.

Probably no trickery is needed:

<txp:category_list categories='<txp:category1 />,<txp:category2 />'>
    <txp:meta_description format="" />
</txp:category_list>

Offline

#23 2021-05-06 13:45:20

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

Re: How about newsletter

Oops, bad choice of phrase. I meant either sorry. For those situations where you don’t want to display both sets of metadata but want to choose one of them – whichever had metadata filled in first or was from a given parent or something.

It’s all very well telling a site’s authors to choose cat x, y, or z for category1 and cat a, b, or c for category2 when they create an article, but people will forget and assign the wrong one. Coding around that isn’t trivial.

Anyway, yep, if you want both to be output, that’s just the ticket.

Last edited by Bloke (2021-05-06 13:45:49)


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

Offline

Board footer

Powered by FluxBB