I made some changes and updates to the nodewords module (I named it "node_metatags"). Users can add metatag description and keywords to a node, and have them printed as META tags in the HEAD section.

The database table is named "node_metatags" and has the following fields: nid, description, keywords.

CREATE TABLE node_metatags (
  nid int(11) NOT NULL default '0',
  description varchar(250) default NULL,
  keywords varchar(250) default NULL,
  PRIMARY KEY  (nid)
) TYPE=MyISAM;

Comments

stefano73’s picture

StatusFileSize
new3.2 KB

Fixed two bugs on the previous module, the attached file is updated.

Replace line 79 with the following code:

 _node_metatags_delete($node);

The function _node_metatags_delete() has a bug too, this is the updated code:

function _node_metatags_delete(&$node) {
  db_query("DELETE FROM {node_metatags} WHERE nid = %d", $node->nid);
  unset($node->meta_description);
  unset($node->meta_keywords);
}
Anonymous’s picture

Thats awesome thanks! (I couldn't get the other one to work in my theme)

mikeryan’s picture

Category: bug » feature
StatusFileSize
new7.55 KB

Well, I had some META ideas in mind and zeroed in on the nodewords module, then found this which was a step closer... Now I've got (almost) everything I want in meta tag management in the attached version of your module:

  • Automatic generation (when the user leaves it blank) of the description from the node teaser
  • Automatic generation of keywords by expanding a list of abbreviations. I.e., I have a lot of nodes which only reference the Museum of Fine Arts by the abbreviation "MFA", and I'd like search engines to find them when searching the full name. By finding the abbreviation in the text and adding the expansion to the meta keywords, I hope to give the search engines a little hint...
  • A bulk update action to apply the above to all existing un-meta'd nodes

I made a couple of other tweaks to the module as written - replacing quotation marks with ", and expanding the keywords field (the recommendations I've seen generally suggest limits of 250 on description length and 1024 on keywords, although I personally would never go near that limit).

Feedback? It can certainly be a bit smarter in both the description and keyword generation, but the glaring omission at the moment is a UI for managing the translation table (we've all got phpMyAdmin for that, right?:-).

gábor hojtsy’s picture

The nodewords module released for 4.6 has some of these features: ie. it sets the meta keywords automatically. Expanding abbreviations is quite special and should not be handled by this module. (No I don't have phpmyadmin :). The glossary module has such lists, and so if you desire this feature, it might be a lot simpler to reuse that module and plug it into nodewords.

jbernat’s picture

Version: » 4.6.x-1.x-dev

Hi. I'm new to Drupal and PHP. I just saved the node_metatags_1.module to the modules directory of my 4.6.0 installation and ran the SQL contained within to create the tables successfully.

Has anyone seen this message when using the node_metatags_1.module? This is not a Drupal 4.5/4.6 compatibility issue, it it? Looks like a PHP thing.

Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in d:\apache\ssr\modules\node_metatags.module on line 78

Also on lines 91, 107, 161, 166

What is the best way to fix this, other than enabling the deprecated feature in PHP.INI?

Thank you!
Jim

jbernat’s picture

Title: node_metatags.module: adds meta-description and meta-keywords to nodes. » A good fix? node_metatags.module: adds meta-description and meta-keywords to nodes.
StatusFileSize
new8.17 KB

This appears to function OK and does not require the PHP.INI be modified to enable the deprecated use of the pass by reference mentioned in my earlier post.

I will attach the file. The old source line is commended with JMB2005521 and the revised line immediately follows.

Is this the proper way to fix the aforementioned error? If so, I hope others will find the modification useful.

I welcome any advice you may have to offer.

Thanks,
Jim

webseo’s picture

Category: feature » bug

I tried your node_metatags.module and all went well until I tried to update all my pages with the bulk update function. I received several of these error messages:

Location /admin/settings/node_metatags?PHPSESSID=abcf9ca68ba0cdd14b81cac9c673f4a8 
Message Table 'carni3_drupal.node_metatags_xlattable' doesn't exist query: SELECT abbrev,expansion FROM node_metatags_xlattable in /home/carni3/public_html/includes/database.mysql.inc on line 66. 

Did I do something wrong? Or does this module not function correctly? I tried nodewords, but had the problem with duplicate keywords and the patch didn't fix that (sorry - off topic here).

Thanks!

martin
webseo

henk@sharewareblogs.com’s picture

Title: A good fix? node_metatags.module: adds meta-description and meta-keywords to nodes. » How to disable on subset of pages

I like this module, but it can not be used as it is, because it works on every page on the site, instead of just the pages where it is needed.
One effect is that all RSS feeds are broken.
Another effect is that many pages give an error (can not modify header).
I'm not experienced in drupal module development, so I don't know how this can be fixed.
But it sounds easy to me, as certain other modules have the capability to select on which pages they are active.
Can anyone help?

henk@sharewareblogs.com’s picture

Title: How to disable on subset of pages » Never mind

Never mind my previous remark, I found the problem.
While copying node_metatags, somehow a space was inserted after the closing ?>, which caused the html output to start with a space right there.

Robrecht Jacques’s picture

Title: Never mind » Integrate node_metatags module??
Assigned: Unassigned » Robrecht Jacques
Category: bug » task
Priority: Normal » Minor

I will check out this node_metatags module and maybe incorporate some of it's features in nodewords. AFAICS node_metatags differs from nodewords in following points:

  1. a seperate "description" field (and a variable that says wheter to use the teaser if no description provided)
  2. expandable aliases
  3. bulk update ??

I remember seeing a module for setting a seperate teaser ("excerpt"), different from the beginning of the body-text. I'll look into how that module works and whether things "just work" if both modules are enabled. If both modules don't work together well, I might add seperate "description" support to this module (I prefer not to do this though if I can avoid it).

Expandable aliases seems a bit special purpose to me. Also, there doesn't seem to be a gui for setting them. On the other hand, if no aliases are set, nothing happens I suppose.
I suppose the bulk update is related to these expandable aliases.

I also want to investigate whether "taxonomy" or "folksonomy (free tagging)" could be used to input the keywords.

druvision’s picture

Hi Robrechtj,

On july 17, you wrote:

I remember seeing a module for setting a seperate teaser ("excerpt"), different from the beginning of the body-text. I'll look into how that module works and whether things "just work" if both modules are enabled. If both modules don't work together well, I might add seperate "description" support to this module (I prefer not to do this though if I can avoid it).

I want to comment that description is much different from teaser:

  • A description is limited to 250 characters. It can't contain HTML, only plain text.
  • A teaser, as implemented by the excerpt module, can be much larger. Alsi, it might contain atribitary HTML, references to images, etc...

Hence, description must be a separate field.

We might ease the user's work by setting the teaser to be equal to the description, if no teaser was entered. But that contradicts the current implementation where the teaser is equal to the 1st paragraphs of the body text and might create certain incompatibilities.

Robrecht Jacques’s picture

I get your point levavie, or at least I think I do :-)

  • I'll will implement a description field to be set seperately on each node (in the next week or so).
  • Maybe we'll need a seperate global description field too, after all, the site mission is not unlike a teaser for the front page. This global description would only be used on the front page itself (no spamming).
  • Fallback to teaser if no description is provided. I don't think we can do it the other way (let $teaser be $description when teaser is not set) - that would break too much. Maybe provide a global option ("Use teaser if description is not set") for that?
  • Both body and teaser can include some non-description stuff. Eg if you enable "event.module" for that node type, then the start and end date are part of the body/teaser while they don't make too much sense in a description. I'm not sure how I can get rid of that.

Would that be ok?

cmsn00b’s picture

I'll will implement a description field to be set seperately on each node (in the next week or so).

That sounds great. I think it would be quite helpful to have seperate metatags for "title," "keywords" and "description" for each node.

druvision’s picture

Hi robert,

Yes, it is enough to set the description field as a separate field. That would be great.
Defaults are much lower priority. No harm is node if the SEO has to enter it himself.

All search-engines except Google use the keywords and description fields, so they are needed. They use them to test your integrity against the links from outside sites.

Also, please allow to enter an ABSTRACT meta tag. This tag, gives further advantage in the search engines.

" The Abstract META tag is very similar to the description Meta tag, except its an abstraction or a brief summary of the description META tag. Generally the Abstract META tag is a one line sentence which gives an overview of the entire webpage. Although search engines do not as often use this tag, it is a useful complement to search engines that read the first few lines of text of your webpages."

SQL may be changed as follows:

CREATE TABLE nodewords (
  nid int NOT NULL,
  nodewords varchar(250) NULL,
  description varchar(250) NULL,
  abstract varchar(250) NULL,
  PRIMARY KEY (nid)
);
Robrecht Jacques’s picture

Version: 4.6.x-1.x-dev » master
Category: task » feature
Status: Active » Fixed

nodewords.module now has a seperate DESCRIPTION and ABSTRACT tag in CVS-HEAD.

The other feature of node_metatags.module (expandable aliases) will not be implemented.

Note that the "nodewords" table has changed! Please read "README.txt" carefully!

Note that this is a large amount of new code. Please test and see if you encounter any bugs. Please open a new issue if you do!!

Anonymous’s picture

Anonymous’s picture

kindafun’s picture

Marc Bijl’s picture

Version: master » 4.6.x-1.x-dev
Category: feature » support
Priority: Minor » Normal
Status: Fixed » Active

Hi,

In this topic I just read the last comment, which told me:

nodewords.module now has a seperate DESCRIPTION and ABSTRACT tag in CVS-HEAD

So I downloaded the module. But, both nodewords.mysql and README.TXT do not give the suggestion these files are up to date. I.e. no databasefiled for description, and nothing about it in the readme.

Technically I am not very skilled (a real newbie), so I might think wrong somewhere :-D

Cheers,
Marc

ron_mahon’s picture

You need to look in the CVS section of downloads.
It a place where developers put thing so that testers and other brave people can find and test new code.
Ron

Marc Bijl’s picture

Status: Active » Fixed

Hi,

Indeed! I had some e-mail exchange with Robrecht Jacques, and found out what CVS means. Got the latest CVS release and it seems to be pretty promising so far!

Cheers,
Marc

Anonymous’s picture

Status: Fixed » Closed (fixed)
jbernat’s picture

Is the node_metatags module referenced in this post supported as an official contribution, or are these the only releases published?

jim.bernatowicz.net

Robrecht Jacques’s picture

As far as i know, node_metatags.module is only available as the attachments to this issue. It is not available on the drupal CVS repository.

This issue dates from before I took maintenance of nodewords.module and I think most of the improvements of node_metatags.module has been incorporated into nodewords now. So tell me why you want this node_metatags.module, and maybe I will incorporate the features you want into nodewords.

BTW nodewords works in 4.6 too, so if that is the problem... then there is no problem :-)

jbernat’s picture

I see. I believe this is a non-issue, then. It has been some time since I have worked with either module, and just referred someone to the node_metatags module (which I was using sometime back.) I will also advise them to evaluate the nodewords module for their needs.

Thank you,
jim.bernatowicz.net