We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19986
    • 90 Posts
    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
      • 22303 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.
        • 19986
        • 90 Posts
        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
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: steph at Jan 25, 2006, 05:51 PM

          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).

          $modx->getKeywords() will get you the current document’s keywords in an array (or you can specify a document id as a parameter, to get keywords from another document), which you can easily implode(). However, in this case, you can enter a TV tag as a keyword (e.g. [*extra-keywords*]) and it should get processed by the parser. cool

          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.
            • 33114
            • 518 Posts
            I still cannot get this to work. I’ve added metatags in the Resources section. Chose some in the page edit and no result sad


            SOLVED.
            I had my <head> tag in a chunk. Since I get it out and put it into templates - meta tags work!
              http://modx.ru - российская поддержка MODx
              http://newscup.ru - экспериментальный проект
              http://yentsun.com - персональный сайт
              • 7923
              • 4,213 Posts
              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... smiley ..I would like to see a list of all api functions and return types for starters.. rolleyes


                "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                • 15328
                • 2 Posts
                Could I set keywords base on page title automatically??
                How to do ?
                  • 22303 MODX Staff
                  • 10,725 Posts
                  Quote from: kandyghost at May 25, 2006, 10:21 PM

                  Could I set keywords base on page title automatically??
                  How to do ?

                  Very simply add this to the head of your template...
                  <meta name="keywords" content="[*pagetitle*]" />

                  ...and that will work with any modx tag...I often do...
                  <meta name="description" content="[*introtext*]" />

                    • 4273
                    • 356 Posts
                    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
                      SMF Bookmark Mod - check it out
                      http://mods.simplemachines.org/index.php?mod=350
                      • 22303 MODX Staff
                      • 10,725 Posts
                      Quote from: bugsmi0 at Jul 21, 2006, 12:59 PM

                      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
                      You have an outdated 0.9.1 or earlier MODx install that needs to be upgraded. This bug was addressed in 0.9.2+ -- see http://modxcms.com/bugs/task/292