Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-01-08 08:35:03

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Section meta description tag

Hi – I am looking to use the description meta tag on my section pages, but I cannot seems to be able to find a suitable plug-in.

I found this one “ja_section_driven_meta.zip” – but the download site is dead.

Is there a way to do this without a plug-in?

Offline

#2 2006-01-08 09:33:58

nardo
Member
From: tuvalahiti
Registered: 2004-04-22
Posts: 743

Re: Section meta description tag

could you use article tags to pull out an article that contains the meta description?

for example, if you’re not using “sticky” articles, you could make one for each section… then use chh_article_custom in place of article_custom (as it is section sensitive) with the attribute status="sticky"

e.g. in your document’s head:
<code><txp:if_section name=”“><txp:else />
<meta name=“description” content=”<txp:chh_article_custom status=“sticky” form=“meta-desc” />” />
</txp:if_section>
</code>

your “meta-desc” is obviously an article form with just <txp:body />

haven’t tested this, so syntax might need to be checked…

alternatively, here’s an oldie but a goodie: spc_section_alias … not sure if it works with 4.0.3 but probably

Last edited by nardo (2006-01-08 09:37:25)

Offline

#3 2006-01-23 09:45:36

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: Section meta description tag

Thanks for that info – I was working away, and going pretty well, when I realised that I could do what I wanted using custom fields and sticky articles… or so I thought.

I created 2 new custom fields: keywords, description.

Then I created a new ‘misc’ form called meta which contained the following:

<code><meta name=“description” content=”<txp:custom_field name=“description” />” />
<meta name=“keywords” content=”<txp:custom_field name=“keywords” />” />
<meta name=“description2” content=”<txp:excerpt />” /></code>

(I was using the description2 as a test to see if I could use excerpt as my description field.)

Then in my template I put the following: <code><txp:output_form form=“meta” /></code>

I entered values into the custom fields and excerpt field and tested my page – no data showed.

What am I doing wrong?

Last edited by tye (2006-01-23 09:46:28)

Offline

#4 2006-01-23 11:46:05

nardo
Member
From: tuvalahiti
Registered: 2004-04-22
Posts: 743

Re: Section meta description tag

it’s because you need to use an article tag – like <txp:article form="meta" />

but you also need to tell the article tag what article to display — the latest one, or a sticky one?

investigate chh_article_custom actually – instead of using txp’s article custom or article tags… as it is section-sensitive (i.e. pulls out an article based on your chosen criteria from the current section)

there are a few ways to do what you’re after – maybe give a little more exposition

just recently I worked on a site where the ‘first’ article in a section had custom fields that contained meta info for that section (page title, meta keywords, meta desc, etc) – which meant you didn’t need to create a specific article just for meta data … but that might not be the best solution every time

Offline

#5 2006-01-23 22:42:51

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: Section meta description tag

<quote>just recently I worked on a site where the ‘first’ article in a section had custom fields that contained meta info for that section (page title, meta keywords, meta desc, etc) – which meant you didn’t need to create a specific article just for meta data … but that might not be the best solution every time</quote> This is exactly what I am after – although I would also like to include the meta information for each separate article – as I’ve noticed Google has started using this information “sometimes” again.

What is the best way to acheive this?

I would have thought this would be standard in txp, but I suppose it was orginally made as a blog not a cms.

Offline

#6 2006-01-23 23:07:17

nardo
Member
From: tuvalahiti
Registered: 2004-04-22
Posts: 743

Re: Section meta description tag

tye, I’ll try write it up tonight –

but say you have 1 article per section, which is your ‘web page’ … you could use, in that article:

  • custom field #1 as “custom-title” for your xhtml <title> tag or default to the article’s title if that’s appropriate (just don’t fill in custom field #1)
  • excerpt as meta description
  • keywords field as meta keywords

now you create an article form, call it say “return-meta”, like you did above… e.g. <meta name="description" content="<txp:excerpt />" /> etc etc

then in your head, use an article tag <txp:article limit="1" form="return-meta" />

you only need to get a bit tricky if you’re dealing with some sections that have multiple articles or ‘web pages’, etc – or you’d like to have default values inserted if you provide none – and that’s when you’ll modify the article tag to only call the latest or oldest article, and put conditionals in your “return-meta” form

Offline

#7 2006-01-23 23:50:45

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: Section meta description tag

Thanks nardo

Some of my sections do have multiple articles, some have only 1 – so I suppose mine is going to be tricky.

My site is based on a cms, I would like to display a page for each section which has meta description, keywords a title and also a short article type description which would only be viewed only on the first page.

Then it would list all the articles in that section – which when viewed have their own set of meta tags, title – but the description would be replaced by the actual article.

I’ll keep investigating today to see if I can work something out.

Offline

#8 2006-01-24 00:53:40

nardo
Member
From: tuvalahiti
Registered: 2004-04-22
Posts: 743

Re: Section meta description tag

it’s not too tricky tye -

on your section ‘home page’, you could use the article tag with the attribute status="sticky" – to display your first page – then use another article tag with a different form to output a list of the articles in that section

so when you write articles in txp, your section ‘home page’ article is always set as “sticky” and your section ‘internal pages’ are just set as “live”

keep at it, you’ll work it out … remember the if_article_list and if_individual_article conditional tags will work for you in this situation, as your section ‘home page’ is an article list and internal pages are each individual articles …

keep the tag reference handy

Offline

#9 2006-01-24 01:53:18

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: Section meta description tag

Thanks for the help nardo – I’ll let you know how I go.

Offline

#10 2006-02-07 06:29:45

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: Section meta description tag

nm… I seem to be having a problem with ‘Sticky’ Articles and displaying my custom fields…

I have searched these forums and can’t find anything, although I could be using the wrong keywords.

Here is my code:
<code><!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml” xml:lang=“en”>
<head>

<meta http-equiv=“content-type” content=“text/html; charset=utf-8” />
<txp:article limit=“1” form=“meta” />

<link rel=“stylesheet” href=”<txp:css />” type=“text/css” media=“screen” />

<title><txp:page_title />: <txp:site_slogan /></title>

</head>
<body>
<div id=“container”>

<div id=“banner”>
<txp:output_form form=“navigation” />
<h1><txp:output_form form=“sloggan” /></h1>
</div>

<div id=“sidebar-b”><br /><br /><br />
<h3><txp:article form=“article_list” limit=“6” listform=“article_list” /></h3>
</div>

<div id=“content”>
<txp:article id=“8” form=“static” status=“sticky” />
<txp:article form=“Single” listform=“Single” />
</div>

<div id=“footer”>
<txp:output_form form=“footer” />
</div>

</div>
</body>
</html></code>

What I have is a sticky article at the beginning of my section, then underneath, a list of articles related to that section (in the div id=“content”). What is happening is that the meta data (contained in <code><txp:article limit=“1” form=“meta” /></code>) is displaying the meta data for the first article from the list… not from the sticky article.

I tried adding <code><txp:article limit=“1” id=“8” form=“meta” /></code> – but this messed it all up and displayed the title and body of the static article.

I also noticed that if I change my sticky article into a live article – the custom fields work.

Do I need to do something different for custom fields to work for sticky articles?

Thanks

Offline

Board footer

Powered by FluxBB