We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3363
    • 12 Posts
    Hi eveyone,

    I use automatic keyword generator in SMF forum: It converts board name to keywords. The code like this:
    $stop_words=  array(" ben "," sen "," hakkında "," bir "," nerede "," ki "," kim "," nerede "," ve "," com "," de "," en "," için "," tarafından "," nasıl "," ne "," içinde "," ile "," www ","!",".","?","=","-");
    		$keywords_ = str_replace($stop_words," ",$context['page_title']);
    		$keywords_ =  preg_replace ( "/\s\s+/" , " " , $keywords_);
    		$keywords_ = str_replace(" ",", ",trim($keywords_));
    
    
    <meta name="keywords" content="'.$keywords_.'" />


    Is it possible in MODXcms? If you know how to generate automatic keywords with modx cms please help me! I want Long Title in Modx to be converted to keywords. Thanks for your regards.
      • 25663 MODX Staff
      • 12,272 Posts
      That’s a neat request. Please file a bugtracker (Jira) ticket for an improvement. Thanks!
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 3749
        • 24,544 Posts
        Yes, but please don’t double post. wink
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 3363
          • 12 Posts
          Quote from: BobRay at Oct 18, 2008, 05:15 PM

          Yes, but please don’t double post. wink
          Sorry i think, i misunderstood rthrash that is why i post it to In Development category again!

          BobRay i tried to generate code but it is failure smiley

          Can you help me? I have been working on this for three hours but i couldn’t be successful.
            • 27330
            • 884 Posts
            Quote from: bilalnadir at Oct 18, 2008, 11:39 AM

            I want Long Title in Modx to be converted to keywords. Thanks for your regards.

            I love your idea, but here is how you can use your long title as keywords.

            <meta name="keywords" content="[*longtitle*]" />
              • 3749
              • 24,544 Posts
              I don’t know what you have, but maybe this will get you started. This is off the top of my head and there’s probably an easier way but it’s late and I can’t think of it right now.


              <?php
              /* Keywords snippet Version 1.0 */
              
              $pageId = $modx->getDocumentIdentifier('id');
              $pageInfo = $modx->getPageInfo($pageId, 0, 'longtitle');
              $longTitle = $pageInfo['longtitle'];
              
              $stop_words=  array(" ben "," sen "," hakkında "," bir "," nerede "," ki "," kim "," nerede "," ve "," com "," de "," en "," için "," tarafından "," nasıl "," ne "," içinde "," ile "," www ","!",".","?","=","-");
              		$keywords_ = str_replace($stop_words," ",$longTitle);
              		$keywords_ =  preg_replace ( "/\s\s+/" , " " , $keywords_);
              		$keywords_ = str_replace(" ",", ",trim($keywords_));
              $metaCode = '<meta name="keywords" content="'. $keywords_ .  '" />';
              $modx->regClientStartupHTMLBlock($metaCode);
              ?>


              Hope this helps.



                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 3363
                • 12 Posts
                Thanks for your help but it does not work in my site: I saved the snippet and named [[keywords]] then i called the snippet in ModxHost template like this:

                <title>[(site_name)] | [*pagetitle*]</title>
                <meta http-equiv="Content-Type" content="text/html; charset=[(modx_charset)]" />
                [[keywords]]
                <meta name="verify-v1" content="ortc1qbFTGFThsooNGJsvoFTk8c5AlEd4yoFQbjFUNc=" />

                It returns following error:


                ERROR: Too many forward attempts!

                The request could not be completed due to too many unsuccessful forward attempts.


                Did the snippet work in your site? Where did i make wrong ¿

                Thanks!
                  • 3363
                  • 12 Posts
                  Quote from: sinbad at Oct 18, 2008, 10:35 PM

                  <meta name="keywords" content="[*longtitle*]" />

                  This works well but it does not insert comma (,) between words to seperate the words. I think, there must be a Trim code but i could not manage to write true code to true place huh
                    • 3749
                    • 24,544 Posts
                    Put the snippet in the body section of the HTML, not the head.  It will automatically put the meta statement where it belongs.

                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 3363
                      • 12 Posts
                      it does not solve the problem! Did you try this snippet in your site?
                      Thanks.