Textpattern CMS support forum

You are not logged in. Register | Login | Help

#41 2005-02-17 03:08:53

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: Plugin: ajw_technorati_tags

so on that token, would it make sense to allow for optionally changing the url format? what do you envision?

Alan, what you’re describing is appending the tags to the end of the body html string yes?

Last edited by Andrew (2005-02-17 03:09:56)

Offline

#42 2005-02-17 03:52:26

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: Plugin: ajw_technorati_tags

Ok, so i’ve update 0.7 so that you can specify your own urls (as long as your url ends in [tagname]). Is this helpful for anyone? Is anyone actually using this plugin? ;-)

NOTE – I changed the default delimiter in this version to follow what most tag-based systems use (SPACE)

Last edited by Andrew (2005-02-17 04:03:35)

Offline

#43 2005-02-17 04:05:30

Baseline_Benny
Plugin Author
From: Brisbane, Australia.
Registered: 2004-06-01
Posts: 15
Website

Re: Plugin: ajw_technorati_tags

> Andrew wrote:

> Is anyone actually using this plugin? ;-)

Not yet. But i plan to shortly. Watching this thread with interest.

Ben.


Life is what you make it… if nothing changes, nothing changes.
Web hosting http://dynamicwebhosting.com.au/
Web dev & marketing http://wallishamilton.com/

Offline

#44 2005-02-17 08:01:42

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: Plugin: ajw_technorati_tags

Ok kids, time for more hacks. This one is actually a little sexier, if I do say so myself. It’s sort of a hybrid between the plugin and other rss/atom.php hacks. What it’ll do is add category and dc:subject tags to your rss/atom feeds based on the same criteria that the plugin uses (the contents of the custom field or keywords field).

RSS category tags (rss.php)

Find this:

<blockquote> <pre> $item = tag(strip_tags($Title),‘title’).n. tag($Body,‘description’).n. tag($link,‘link’).n; $out[] = tag($item,‘item’);</pre> </blockquote>

Edit to this:

<blockquote> <pre> $item = tag(strip_tags($Title),‘title’).n. tag($Body,‘description’).n. tag($link,‘link’).n; foreach((array)fetch_tags($ID) as $tag) { $item .= n.tag(htmlspecialchars($tag),‘category’); } $out[] = tag($item,‘item’);</pre> </blockquote>

Atom category tags (atom.php)

Find this:

<blockquote> <pre> $e[‘link’] = ‘<link’.relalt.texthtml.’ href=”’.$elink.’” />’; $e[‘id’] = tag(‘tag:’.$siteurl.’,’.date(“Y-m-d”,$uPosted).’:’.$ID,‘id’); $e[‘subject’] = tag(htmlspecialchars($Category1),‘dc:subject’);</pre> </blockquote>

Edit to this:

<blockquote> <pre> $e[‘link’] = ‘<link’.relalt.texthtml.’ href=”’.$elink.’” />’; $e[‘id’] = tag(‘tag:’.$siteurl.’,’.date(“Y-m-d”,$uPosted).’:’.$ID,‘id’); $e[‘subject’] = tag(htmlspecialchars($Category1),‘dc:subject’); foreach((array)fetch_tags($ID) as $tag) { $e[‘subject’] .= n.tag(htmlspecialchars($tag),‘dc:subject’); } // sorta kludgy but not terrible</pre> </blockquote>

The sorcery

Add this function to the bottom of both rss.php & atom.php (or stick it wherever suits yer fancy)

<blockquote> <pre> // ——————————————————————————————- function fetch_tags($id) { $delim = ‘ ‘; // delimiter used to separate tagnames $field = 1; // custom field used; empty ‘’ if none $keywords = ($field) ? fetch(“custom_$field”, ‘textpattern’, ‘ID’, $id) : fetch(“Keywords”, ‘textpattern’, ‘ID’, $id); if (!empty($keywords)) { $keywords = explode($delim,$keywords); foreach ($keywords as $keyword) { $out[] = trim($keyword); } return $out; } return; }</pre> </blockquote>

Last edited by Andrew (2005-02-17 08:05:01)

Offline

#45 2005-02-17 16:11:34

schussat
Plugin Author
Registered: 2004-02-24
Posts: 101
Website

Re: Plugin: ajw_technorati_tags

> fncll wrote:

> Update: Alan— have you posted your changes anywhere?

I haven’t so far, but I’d be happy to. I have a long day of teaching and meetings today, and I’ll try to package up my changes this evening.

&gt; Andrew:

&gt; Alan, what you’re describing is appending the tags to the end of the body html string yes?

This is what I did originally, but found that it didn’t have any effects because Technorati only pays attention to the feed, so I moved the code to rss.php and atom.php. I think it’s probably about the same as the new hack that you posted. I’ll have a chance to take a closer look tonight. For what it’s worth, it seems to have worked great for the last couple of weeks of use.


-Alan

Offline

#46 2005-02-18 19:43:02

schussat
Plugin Author
Registered: 2004-02-24
Posts: 101
Website

Re: Plugin: ajw_technorati_tags

I pulled up my code and compared it with Andrew’s and I think that functionally we’re doing the same thing, though his code is elegant and mine is … not. I thought I’d post my code for the sake of comparison, but every attempt I have ever made to post code here has gone awry. What’s the proper markup to post code?


-Alan

Offline

#47 2005-02-18 19:57:42

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: Plugin: ajw_technorati_tags

<em>let’s see if this works… (describing in textile how I post code in textile sorta reminds me of Mcsweeney’s E-mail Addresses It Would Be Really Annoying to Give Out Over the Phone) </em>

the way i did that up there ^^ is sorta a hack from the [SPACE] bug/feature in textile. this is how i enter the code into the textarea:

NOTE – replace <code>[]</code> with <code>< ></code> and <code>[SPACE]</code> with an actual space (or spaces). The blockquote is optional, I just like it that way ;-)

<code>[blockquote]</code>
<code>[SPACE][pre]</code>
<code>[SPACE]echo “hello world”;</code>
<code>[SPACE][SPACE][SPACE][SPACE]echo “indented hello world”;</code>
<code>[SPACE][/pre]</code>
<code>[blockquote]</code>

Last edited by Andrew (2005-02-18 20:57:44)

Offline

#48 2005-02-18 20:51:49

schussat
Plugin Author
Registered: 2004-02-24
Posts: 101
Website

Re: Plugin: ajw_technorati_tags

Yowza. Okay, here goes.

In atom.php, before the line <code>// encode and entify</code>, add this block:
<blockquote> <pre> $keywords = “”; $keywords = $Keywords; $tagout = “”; if (!empty($keywords)) { $keywords = explode(’ ‘,$keywords); foreach ($keywords as $keyword) { $keyword = trim($keyword); $tagout = $tagout.”<a href=\“http://technorati.com/tag/”.$keyword.”\” rel=\“tag\”>”.$keyword.”</a> “; } $tagout = “<p>[ tags: “.$tagout.” ]</p>”; $Body = $Body.$tagout; } </pre>
</blockquote>

In rss.php, before the line <code>$Body = htmlspecialchars($Body,ENT_NOQUOTES);</code>, add this block:

<blockquote> <pre> $keywords = “”; $keywords = $Keywords; $tagout = “”; if (!empty($keywords)) { $keywords = explode(’ ‘,$keywords); foreach ($keywords as $keyword) { $keyword = trim($keyword); $tagout = $tagout.”<a href=\“http://technorati.com/tag/”.$keyword.”\” rel=\“tag\”>”.$keyword.”</a> “; } $tagout = “<p>[ tags: “.$tagout.” ]</p>”; $Body = $Body.$tagout; }
</pre>
</blockquote>

All of this is basically just moving the plugin code, and in my case I hardcoded a space as the delimiter (in the $keywords=explode... line). For all I know, the way this puts tags into the feed violates all sorts of treaty obligations, but I based it on the existing look of the feed and wrapped the tags in a paragraph. And it seems to work, too.

Edit: With some minor formatting tweaking, that seems to have worked. Thanks, Andrew (and I loved the McSweeny’s bit)!

Last edited by schussat (2005-02-18 20:57:14)


-Alan

Offline

#49 2005-02-18 20:59:15

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: Plugin: ajw_technorati_tags

And that about wraps it up – I’d say this is about as complete a thread on adding Technorati tags to Txp as you could possibly have.

Offline

#50 2005-02-18 20:59:49

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: Plugin: ajw_technorati_tags

(until an easier method comes about in future versions)

Offline

Board footer

Powered by FluxBB