Ok, this might not be of use for anyone, but then again it might. It’s been a way for me to learn some MODx and PHP things, and if someone wants to test it, it would be nice. It works ok for my purpose and on my site, but I don’t know if it will work for others.
Other solutions can be found in this thread http://modxcms.com/forums/index.php/topic,26691.0.html.
This plugin uses a template variable where you can define which sites to ping, you can have a default value of several sites but also add sites as you write your content. Note though, that this is not a pingback or a trackback thingy, but it can be useful to be able to ping different searchengines.
In my case I use a specific template only for blog posts, so I check the current document template and if it’s my blog post template then execute the pings, otherwise nothing happens.
It would be easy to alter the DBAPI select call to execute ping on all templates that carries the TV, if that’s what you want.
The PHP code might not be the pretteist, since I’m rather new on PHP. There is also a few drawbacks, like saving a document (the plugin is written for "OnDocFormSave") might take some time, if you have a lot of sites to ping.
Also, if a ping returns an error, sometimes you recieve a HTTP 500 error and the plugin might stop pinging remaining sites. This is probably a result of my so far rather poor PHP knowledge, so if anyone knows why and how to correct this please reply.
So this is how you set it up:
1. Create a folder in assets/plugins called "ping", and add the file xmlrpc.inc into the folder.
2. Create a TV called "Ping". It should be a Textarea.
If you want, add some sites to ping as defalut value. The information needed for a site is address, path and port. For example, for Googles blog search the address is blogsearch.google.com the path is /ping/RPC2 and the port i 80. So you add this information, separated with a ";". Like:
If you want to add more, separate them with a ",". Like:
3. Copy the text in blogping.php and add it into a new plugin, call it BlogPing or what you want. Don’t forget to connect it to OnDocFormLoad on the system events tab.
Alter the row
$templateid = 4;
to fit your template.
If you want to make a ping on every template that has the TV, remove that row and alter the row:
$result = $modx->db->select("default_text", $tbl_tv. ’ INNER JOIN ’ . $tbl_tv_temp . ’ ON ’ . $tbl_tv .’.id=’ . $tbl_tv_temp . ’.tmplvarid’,$tbl_tv.’.Name=\’Ping\’ AND ’ . $tbl_tv_temp .’.templateid=$templateid);
$result = $modx->db->select("default_text", $tbl_tv. ’ INNER JOIN ’ . $tbl_tv_temp . ’ ON ’ . $tbl_tv .’.id=’ . $tbl_tv_temp . ’.tmplvarid’,$tbl_tv.’.Name=’Ping’’);
And thats it, I think.
(Errors and successfull pings are recorded in the system eventlog.)