Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-03-16 06:26:18

laptophobo
Member
Registered: 2010-03-01
Posts: 216
Website

Meta Content and Keywords not viewing.

I’m following the advice of the “Textpattern Solutions” book to place dynamic meta Content and Keywords into my template.

I have these meta tags on the template:
<meta name=“description” content=”<txp:custom_field name=“meta_desc” />” />
<meta name=“keywords” content=”<txp:keywords />” />

In my articles, within the content and keywords boxes, I have data. Am I missing some important thing here?

Thanks for your input!


Living the Location-Independent Life: www.NuNomad.com

Offline

#2 2010-03-16 06:45:36

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

Re: Meta Content and Keywords not viewing.

custom_fields are called within an article context. can you post some more of your template here?


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 2010-03-16 06:51:14

whaleen
Member
From: Portland
Registered: 2006-05-11
Posts: 373
Website

Re: Meta Content and Keywords not viewing.

Your quotation styles vary. Try replacing all those with freshly typed ones. Th ones that appear to stand up straight. You’ll notice they are not all the same. Leaners in there.


txtstrap (Textpattern + Twitter Bootstrap + etc…)

Offline

#4 2010-03-16 09:06:14

laptophobo
Member
Registered: 2010-03-01
Posts: 216
Website

Re: Meta Content and Keywords not viewing.

colak, I’m not sure if I’m understanding your question about custom fields correctly (since these are meta data tags they’re in between the <head> tags) but I’ll explain the process that I did take.

1. I went into Admin > Preferences > Advanced and created within the Custom Fields: meta_desc. (I did not create a custom field for “keywords” since its not a custom field).

2. I went into the article (Services) and saw that my custom field “meta_desc” was now available under Advance Options (left sidebar). I placed a description there.

3. I placed some keywords within the “keywords” field.

4. I went to my template page at http://www.dotorgwebworks.org/example.dev/services/ , did a View Source, and I see that the Descriptions and Keywords do not view.

Is this what you were seeking from me?

Thanks for your help!


Living the Location-Independent Life: www.NuNomad.com

Offline

#5 2010-03-16 09:06:53

laptophobo
Member
Registered: 2010-03-01
Posts: 216
Website

Re: Meta Content and Keywords not viewing.

whaleen,

I didn’t see any difference in quote markings (in html, they remain flat) but I went ahead and retyped them as you suggested. No change.

I’m wondering then if there is another way to generate dynamic content and keyword content (pulling from the articles.)


Living the Location-Independent Life: www.NuNomad.com

Offline

#6 2010-03-16 09:11:08

whaleen
Member
From: Portland
Registered: 2006-05-11
Posts: 373
Website

Re: Meta Content and Keywords not viewing.

I didn’t see any difference in quote markings (in html, they remain flat) but I went ahead and retyped them as you suggested. No change.

Ah well. That’s all I saw at a glance. Those can be a problem but it looks like something else.


txtstrap (Textpattern + Twitter Bootstrap + etc…)

Offline

#7 2010-03-16 09:15:46

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

Re: Meta Content and Keywords not viewing.

laptophobo

I think Colak is correct. The example link you supplied looks like a section landing page and not an article. Hence, if there is no article to display, there is no custom field to read, so no meta output. Compare the source code on the landing page with an article and you’ll see that the latter has the meta tags completed for you.

To get meta info on a section landing page there are a variety of techniques you can employ (the rah_metas plugin is one, although you can do it with txp:variables or some other clever methods). I have my own way of doing this but I’m sure someone will let you know how they solve this in a simpler fashion!

Last edited by Bloke (2010-03-16 09:17:43)


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

#8 2010-03-16 09:43:29

laptophobo
Member
Registered: 2010-03-01
Posts: 216
Website

Re: Meta Content and Keywords not viewing.

Well, this is a strange situation. My Services template has a tag to a form called meta-1. Here is where it calls out the meta:
<meta name=“description” content=”<txp:custom_field name=“meta_desc” />” />
<meta name=“keywords” content=”<txp:keywords />” />

The Articles template also uses the meta-1 form. I compared the article used for the Services page to that of the “Auto Show Update” (where meta was visible in View Source) and I don’t see a difference in the settings.

If you have a work around for this, I’d trash my tags in a moment.


Living the Location-Independent Life: www.NuNomad.com

Offline

#9 2010-03-16 10:10:22

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

Re: Meta Content and Keywords not viewing.

laptophobo wrote:

I compared the article used for the Services page to that of the “Auto Show Update” (where meta was visible in View Source) and I don’t see a difference in the settings.

There won’t be any difference in the tags/settings. I think the problem is that of context. When you view an article — i.e. anything inside <txp:if_individual_article> tags — Textpattern can “see” the current article’s body, excerpt, keywords, custom fields, posted date, and so on. They are all visible and available to be used by the whole template.

When you are on a section landing page, however, the <txp:article /> tag shows a list of articles in that section. In this case, only within the <txp:article /> tag’s form or container can you ‘see’ each individual article’s fields such as keywords, body, excerpt, custom fields, etc.

Hence, ‘outside’ an article tag — e.g. in your <head> tag on the template — TXP has no concept of ‘an article’. It sees “no articles” until it hits an article tag. Therefore it/you cannot access any fields inside any article that may appear later on your page. This means you cannot use any article fields outside of the <txp:article /> (or <txp:article_custom />) tags (well, you can use them but they won’t display anything!)

One way of getting round this is to cheat. In your <head>, you could add a conditional tag, and hard-code the meta info for all landing pages:

<head>
<txp:if_article_list>
   <meta name="description" content="List of articles in the <txp:section /> section" />
<txp:else />
   <meta name="description" content="<txp:custom_field name="meta_desc" />" />
   <meta name="keywords" content="<txp:keywords />" />
</txp:if_article_list>
</head>

You could be more clever here and store all the landing page meta info in a series of txp:variables, perhaps each named after the section. For example in a form called landing_meta:

<txp:variable name="meta_services">Meta info for the services section</txp:variable>
<txp:variable name="keyword_services">list, of, keywords, for, the, services, section</txp:variable>
<txp:variable name="meta_training">Meta info for the training section</txp:variable>
<txp:variable name="keyword_training">list, of, keywords, for, the, training, section</txp:variable>
...
and so on

If you include that form before your <head> tag via <txp:output_form form="landing_meta" />, you can then do this:

<head>
<txp:if_article_list>
   <meta name="description" content="<txp:variable name='meta_<txp:section />' />" />
   <meta name="keywords" content="<txp:variable name='keyword_<txp:section />' />" />
<txp:else />
   <meta name="description" content="<txp:custom_field name="meta_desc" />" />
   <meta name="keywords" content="<txp:keywords />" />
</txp:if_article_list>
</head>

This could be simpler still if you used the excellent adi_variables plugin because you can manage the meta info from the admin-side more visually. Or, as I mentioned earlier, try the rah_metas plugin which allows you to specify a default set of text/keywords to be used in the absence of any actual meta info being found.

Does that get you going forwards again?

Last edited by Bloke (2010-03-16 10:18:05)


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

#10 2010-03-18 03:22:34

laptophobo
Member
Registered: 2010-03-01
Posts: 216
Website

Re: Meta Content and Keywords not viewing.

Wow, this is great. You’ve explained it better than my (near) useless book and TXP guides. I’ll get back to you soon and let you know how it turned out. (I’m buried in other work at the moment. Just wanted to thank you for your promptness.)


Living the Location-Independent Life: www.NuNomad.com

Offline

#11 2010-03-18 04:58:49

laptophobo
Member
Registered: 2010-03-01
Posts: 216
Website

Re: Meta Content and Keywords not viewing.

Hi Bloke,

I was able to get your first tag example to work, but when I combined the 2nd and 3rd, it wouldn’t view: Here’s what I created:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><txp:page_title /></title>
<txp:if_article_list>
   <meta name="description" content="<txp:variable name='meta_<txp:section />' />" />
   <meta name="keywords" content="<txp:variable name='keyword_<txp:section />' />" />
<txp:else />
   <meta name="description" content="<txp:custom_field name="meta_desc" />" />
   <meta name="keywords" content="<txp:keywords />" />
</txp:if_article_list>


<txp:variable name="meta_services">Health and social services and programs for the poor and homeless of Los Angeles, California.</txp:variable>
<txp:variable name="keyword_services">homeless, health care, los angeles</txp:variable>

<txp:variable name="meta_programs">Training programs, etc.</txp:variable>
<txp:variable name="keyword_harm-reduction">keywords for prgrams, l.a., homeless, </txp:variable>

</head>

I can’t spot the error. (help.)

Added bc. -Gocom

Last edited by Gocom (2010-03-18 05:11:37)


Living the Location-Independent Life: www.NuNomad.com

Offline

#12 2010-03-18 05:15:23

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Meta Content and Keywords not viewing.

Where should the set of variables get the data from? You need to define the variable before you can call it. Right now, you are defining the variables after calling.

See the difference:

<txp:variable name="example" />
<txp:variable name="example" value="Dude, you forgot me. Without me you are empty as my tummy." />

And:

<txp:variable name="example" value="I like food. Me no hungry." />
<txp:variable name="example" />

Offline

Board footer

Powered by FluxBB