Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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
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
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
Re: How about newsletter
Yay !! You’re the best :D
And you don’t need the type=category"
either.
Offline
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
Re: How about newsletter
Oh, great !Thanks :)
Offline
Re: How about newsletter
colak wrote #330040:
You can also have
bc. txp
,bc. js
, orbc. 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
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
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