bilalnadir
Jr. Member

Posts: 12
|
 |
« on: Oct 18, 2008, 11:39 AM » |
|
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.
|
|
|
|
|
Logged
|
|
|
|
rthrash
Foundation

Posts: 10,471
|
 |
« Reply #1 on: Oct 18, 2008, 01:17 PM » |
|
That's a neat request. Please file a bugtracker (Jira) ticket for an improvement. Thanks!
|
|
|
|
|
Logged
|
MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
|
|
|
BobRay
Coding Team

Posts: 3,177
|
 |
« Reply #2 on: Oct 18, 2008, 05:15 PM » |
|
Yes, but please don't double post. 
|
|
|
|
|
Logged
|
|
|
|
bilalnadir
Jr. Member

Posts: 12
|
 |
« Reply #3 on: Oct 18, 2008, 06:29 PM » |
|
Yes, but please don't double post.  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 Can you help me? I have been working on this for three hours but i couldn't be successful.
|
|
|
|
|
Logged
|
|
|
|
|
sinbad
|
 |
« Reply #4 on: Oct 18, 2008, 10:35 PM » |
|
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*]" />
|
|
|
|
|
Logged
|
|
|
|
BobRay
Coding Team

Posts: 3,177
|
 |
« Reply #5 on: Oct 18, 2008, 11:43 PM » |
|
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.
|
|
|
|
|
Logged
|
|
|
|
bilalnadir
Jr. Member

Posts: 12
|
 |
« Reply #6 on: Oct 19, 2008, 01:55 AM » |
|
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="ortc1qbFTGFThsooNGJsvoFTk8c5AlEd4yoFQbj FUNc=" /> 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!
|
|
|
|
|
Logged
|
|
|
|
bilalnadir
Jr. Member

Posts: 12
|
 |
« Reply #7 on: Oct 19, 2008, 08:10 AM » |
|
<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 
|
|
|
|
|
Logged
|
|
|
|
BobRay
Coding Team

Posts: 3,177
|
 |
« Reply #8 on: Oct 19, 2008, 04:57 PM » |
|
Put the snippet in the body section of the HTML, not the head. It will automatically put the meta statement where it belongs.
|
|
|
|
|
Logged
|
|
|
|
bilalnadir
Jr. Member

Posts: 12
|
 |
« Reply #9 on: Oct 20, 2008, 05:46 PM » |
|
it does not solve the problem! Did you try this snippet in your site? Thanks.
|
|
|
|
|
Logged
|
|
|
|
BobRay
Coding Team

Posts: 3,177
|
 |
« Reply #10 on: Oct 20, 2008, 06:35 PM » |
|
Sort of.  I tested it in a page where it worked perfectly, but didn't try putting it in the template. I just put it in the template and it's working perfectly there too (I just pasted it from my message above). Be sure the chunkname is spelled the same way in all places. I'm testing it in MODx Revolution but it should work just as well in 0.9.6. I'll try it there if I get a chance later.
|
|
|
|
|
Logged
|
|
|
|
BobRay
Coding Team

Posts: 3,177
|
 |
« Reply #11 on: Oct 21, 2008, 12:20 AM » |
|
Ok, I tested it in 0.9.6 and you're right -- it doesn't work. Sorry, I have no idea why and can't see any reason why it shouldn't.
Possibly it would work as a plugin.
Someone else may be able to suggest a way to make it work as a snippet.
|
|
|
|
|
Logged
|
|
|
|
bilalnadir
Jr. Member

Posts: 12
|
 |
« Reply #12 on: Oct 21, 2008, 12:39 AM » |
|
i hope so, thanks for your interest.  Take it easy.
|
|
|
|
|
Logged
|
|
|
|
|