3 Replies Latest reply on May 17, 2007 1:48 AM by blackandwhite

    Extracting meta data

    blackandwhite
      Hi All,

      Would it be possible to extract the keywords from a metadata tag:

      <meta name="keywords" content="wheat,uk,farming,agriculture,milling,feed">

      I'm using verity to automatically produce a list of relevant links based on a set of keywords held in a cfparam:

      <cfparam name = "keywords_verity" default = "wheat,uk,farming,agriculture,milling,feed">

      At the moment I have to create the cfparam and copy the keywords, I would like to be able to extract the metadata and populate the variable "keywords_verity" dynamically.

      Is it possible?

      TIA

      Trevor

        • 1. Re: Extracting meta data
          blackandwhite Level 1
          I've found this script which gets the information i need, the problem I have is how do I set that information as a variable that coldfusion can read? My javascript is poor.

          <SCRIPT>
          function checkMeta() {
          var metas = document.getElementsByTagName('META');
          var i;
          for (i = 0; i < metas.length; i++)
          if (metas .getAttribute('NAME') == 'description')
          break;
          var description = metas
          .getAttribute('CONTENT');
          alert(description);
          }

          checkMeta();
          </SCRIPT>

          • 2. Re: Extracting meta data
            Level 7
            blackandwhite wrote:
            > I've found this script which gets the information i need, the problem I have
            > is how do I set that information as a variable that coldfusion can read? My
            > javascript is poor.

            javascript = client-side
            cf = server-side

            cf processes and serves your page BEFORE js is executed.
            for cf to see js vars, they have to be submitted (back) to the server
            (i.e. passed as form or url variables, or thorugh AJAX or similar way),
            so that cf can process them.

            if you are trying to populate your cf var with keywords meta data FROM
            THE SAME PAGE you will have to extract the keywords using js like the
            script you have, then, for example, populate a form field with extracted
            data and submit the form to itself. in cf check for existence of
            specified form variable and populate your cf var with that data.

            your could instead write a cf page that will look through a specified
            directory, read each found .cfm/.htm file in it using cfhttp or cffile
            into a variable, which can then be parsed using regex to extract
            keywords if present, which in turn will be saved into your
            keywords_verity var or anywhere you want.

            --
            Azadi Saryev
            Sabai-dee.com
            Vientiane, Laos
            http://www.sabai-dee.com
            • 3. Re: Extracting meta data
              blackandwhite Level 1
              Hi Azadi,

              I decided to use a "title" param already set up and strip out all words and commas etc to come up with a list of keywords.

              Cheers for the info.

              Trevor