By SupaDucta on
I am trying to modify an xtemplate based theme on Drupal 4.42 to work with nodewords module. The module itself is operational, provides an additional field in page administration, and writes into database neatly.
If I do the following:
function nodewords ($nodewords) {
$nodewords = module_invoke("nodewords", "get", $nid);
$xtemplate->template->assign("nodewords", $nodewords);
$xtemplate->template->parse("nodewords");
return $nodewords;
} and put this into xtmpl's head:
meta name="keywords" content="{nodewords}"
I am getting no output, ie. content="".
What am I doing wrong? Please guys give me a hand here :(
Thanks :)
Comments
Can any one help?
I'd really like to get nodewords to work on my site too - the module installs ok, but I've got no idea what code I require on xtemplate theme to call the module.
Can anyone help? Seems daft to have such a cool module posted with no real instructions for non coders.
E
Nodewords in xtemplate
I have added the nodewords module into Drupal, but have a really rough idea on how xtemplate works. You probably need something like this to xtemplate.xtpl (to the HTML head part):
And then search for
xtemplate_page()in xtemplate.theme, and after the big assign call, add something like this:This will set the nodewords if the current page is a node display page. If you don't want xtemplate to break when you disable the nodewords module, you can use module_invoke to call nodewords_get, with
module_invoke("nodewords", "get", $tmp_nid[1]).yea.. it works!
Thanks Goba, you so cool..
How much £$€ do you want to sort out the rest of my website? :-D
E
I'll second that!
Thanks A LOT ;)
How to set non-empty default?
Goba, works perfectly ;) Thanks again.
I am looking at nodewords module and I am trying to figure how to insert a case where if no keywords are set, the default site-wide keywords are output.
Is there a simple solution to that? Any advices on the ELSE approach?
Default keywords
Thanks!
You don't know how thankful I am ;) I asked for an advice, and you have given me a full solution. Thank you, thank you, THANK YOU. ;)
Now I'm more confused
I came here to find out where to insert the code that is in the 'README' file that comes with the keywords module.
$nodewords = module_invoke("nodewords", "get", $nid);Now I see you and others suggesting more code.
Can you lay out for me exactly what code I need to insert, and exactly which file I need to put it in? Is the code suggested by the poster above also needed? What about the code in the 'README' file? Is that needed if I use the code you laid out? I'm using the Interlaced theme.
As I'm sure you've gathered, I'm clueless, so please be specific. Thanks.
1) get the words; 2) put them into HTML
The first is to get the nodewords. The suggested code does just this. Then the second is to inject the words you got into the template. Interlaced is a PHP theme, so search for the line ending the head part in the HTML, and add these two lines before it:
You see how you can add nodewords into your theme differs from theme to theme, so it is not possible to document in the nodewords readme. The only thing the readme can document is how you get the words for one node...
Default Keywords
I cant not get this to work in 4.5 using Marvin theme.
if I insert the line"
$output .= '<' . 'meta name="keywords" content="' . $nodewords . '">';I get the output on all nodes that have nodewords in the database. When the string in enclosed with the rest of the code I get noting not event the “keywords content =”
Marvin is a PHP theme so I just left off the “
and”Can you help
Thanks
Ron