Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-09-11 15:23:32

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

4.6 How do we use the <txp:meta_description /> tag?

Hi all, Great work on 4.6.

I just needed to clarify something so as to be able to respond to future questions.

4.6 How do we use the <txp:meta_description /> tag? To clarify. Do we need to treat it in the same way as we did for custom_fields?

<txp:if_individual_article>
<txp:article>
<txp:if_description><txp:meta_description /></txp:if_description>
</txp:article>
<txp:else /><txp:hide>This is an article list</txp:hide>
<txp:article>
<txp:if_description><txp:meta_description /></txp:if_description>
</txp:article>
</txp:if_individual_article>

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

Offline

#2 2016-09-11 16:03:05

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

Re: 4.6 How do we use the <txp:meta_description /> tag?

On testing, I think that the answer is that we can just have:

<txp:if_description><txp:meta_description /></txp:if_description>

but is this a bug or a feature?


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

Offline

#3 2016-09-11 16:15:53

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

Re: 4.6 How do we use the <txp:meta_description /> tag?

colak wrote #301325:

<txp:if_description><txp:meta_description /></txp:if_description>... but is this a bug or a feature?

Feature :-)

The <meta_description /> tag is context aware and tries to be smart about what description it pulls. If you’re on a section landing page it uses the section description, if you’re on an individual article it uses the article’s meta description. If you want to alter the default, use the type attribute to override it.

meta_description documentation

And, for completeness:

All the docs need tidying up yet as they’re being converted from textile to markdown, so the formatting’s a bit off and some of the internal links don’t work, sorry.

Edit: there’s also this post I made which goes into things in a bit more detail. Some of the specifics may have changed as things were tweaked and the keywords were aligned with the new tag, but that should be fairly close to how it works.

Last edited by Bloke (2016-09-11 16:19:33)


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

#4 2016-09-11 17:02:13

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

Re: 4.6 How do we use the <txp:meta_description /> tag?

Thanks so much stef. I love the simplicity of the new tags.


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

Offline

#5 2016-09-11 17:52:47

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

Re: 4.6 How do we use the <txp:meta_description /> tag?

Just thought I’ll say that I did way with all the lines below in favour of the one liner meta_description tags which work like a dream. Thanks soo much guys!

<txp:glx_if_frontpage><meta name="description" content="meta description here." /></txp:glx_if_frontpage>

<txp:if_individual_article>
<txp:article><txp:if_custom_field name="metad"><meta name="description" content="<txp:custom_field name="metad" escape="" />" /></txp:if_custom_field></txp:article>
</txp:if_individual_article>

<txp:if_section name="about">
<meta name="description" content="<txp:article_custom id="1"><txp:custom_field name="metad" /></txp:article_custom>" /></txp:if_section>

<txp:if_section name="nac">
<meta name="description" content="<txp:article_custom id="44"><txp:custom_field name="metad" /></txp:article_custom>" /></txp:if_section>

<txp:if_section name="workshops">
<meta name="description" content="<txp:article_custom id="2"><txp:custom_field name="metad" /></txp:article_custom>" /></txp:if_section>

<txp:if_section name="neme">
<meta name="description" content="meta description here." /></txp:if_section>

<txp:if_section name="related-links">
<meta name="description" content="meta description here." /></txp:if_section>

<txp:if_section name="events">
<meta name="description" content="meta description here." /></txp:if_section>

<txp:if_section name="participations">
<meta name="description" content="meta description here." /></txp:if_section>

<txp:if_section name="publications">
<meta name="description" content="meta description here." /></txp:if_section>

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 2016-09-11 18:05:42

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

Re: 4.6 How do we use the <txp:meta_description /> tag?

Sweet! And you’re welcome. All tags should be built this way, imho :-)


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

#7 2016-10-06 08:15:04

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

Re: 4.6 How do we use the <txp:meta_description /> tag?

my solution:

<txp:if_description><txp:meta_description /><txp:else /><txp:rah_metas description_from="body" description_replacement="1" /></txp:if_description>

this way it outputs meta descriptions in individual article page, automatically

Offline

#8 2016-10-06 12:15:26

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: 4.6 How do we use the <txp:meta_description /> tag?

I know that <txp:if_description> exists, but in the documentation it doesn’t exist.

Offline

Board footer

Powered by FluxBB