Hi all.
I was wondering how to get the keywords for a page.
I’ve tried using a [[GetKeywords]] snippet call, on the off chance that it’s some kind of built in snippet (I don’t have the snippet in the Manage resources -> Snippets section of the backend). I’ve tried using [*keywords*], as suggested on a different post, but that doesn’t work (I guess because it’s not a field in the modx_site_content table).
Looking around the forums it seems that some people are getting a set of metatags automatically set by modx, one of which is the keywords metadata. I am not getting this. I’ve modified my template from the default, but I’ve done a comparison with the original and there doesn’t seem to be anything missing from the header.
Any ideas anyone?
Steph
-
MODX Staff
- 10,725 Posts
You need to define your keywords for the site and then assign them to each page, if you want to use the built in keywords system. These facilities are available under Manage Resources --> META Tags and Keywords, and the META Keywords tab when editing a document, respectively.
Once you select a keyword from a specific document and save, the keyword meta tag will automatically be inserted at the top of the HEAD tag in your document.
Thanks for your quick reply.
You’re absolutely right, it is output properly. God knows why I didn’t see that, I’ve gone code blind!
Is there any way I can retrieve these keywords for use in other parts of the template? I would like to have a list of keywords that is populated from both the built in keywords system and from a template variable. This would allow me to have a set of default keywords supplied by the admin (via the built in keywords system) and also allow users to add their own (via the TV).
I’ve modified the DropMenu snippet (and other code) to allow it to filter the items, including weblinks, by keywords or by a regexp on a TV. Ultimately I would like to have more control over keywords and bring together the two methods of creating them. I will post my changes when they’re complete.
Thanks again.
Steph
I still cannot get this to work. I’ve added metatags in the Resources section. Chose some in the page edit and no result
SOLVED.
I had my <head> tag in a chunk. Since I get it out and put it into templates - meta tags work!
Quote from: OpenGeek at Jan 25, 2006, 09:44 PM
NOTE: $modx->getKeywords($id) and $modx->getMETATags($id) both need to be added to the API quick reference documentation. I’ll see what I can do.
And lots of others too...

..I would like to see a list of all api functions and return types for starters..
"He can have a lollipop any time he wants to. That's what it means to be a programmer."
Could I set keywords base on page title automatically??
How to do ?
Is there a difference between these two ?
<meta http-equiv="keywords" content=
<meta name="keywords" content=
the first one is generated when adding the keyword to doc,
do we need both ?
also are the keywords in the list words we should already have inside the doc or does it matter since they will be in the meta