Bot link, a tiny yet powerful Joomla! plugin Print E-mail
Sunday, 06 January 2008 21:11
Article Index
Bot link, a tiny yet powerful Joomla! plugin
Examples and changelog
All Pages

I'm very pleased to release my first Joomla! extension! I named it "Bot link". As its name indicates, it is a plugin which automatically places links on pieces of text of your choice in your Joomla! articles. You may use it with a simple text expression or a more advanced perl regular expression. An additional nice feature is that It does not introduce links in places already containing one...

Bot link is still under heavy development and I would not qualify any version as beta, alpha, release candidate or anything. The bot is already relatively stable but requires probably too much the use of regex to be really practical for users which don't like perl regular expressions (Are there any?). My goal is to polish everything for 1.0.0. Anyway, I advise users to check regularly for new versions as Bot link will still improve in the near future...

Syntax

{%bot_link (text="text"|regex="pattern" [text="text"]) link="url" [class="class" alt="text" title="text" html="1" case="1" popup="1"]}

The "%" character after "{" is only here so that the bot is ignored on this page...

Arguments

text

If used alone, means the text to search for. Used in combination with the regex argument, means the text to replace the regular expression matches (optional).

regex

A perl-style regular expression to search for. If used, the "case" argument will be ignored.

The expression inside the delimiters has to be set in parenthesese (Have a look at the examples). If a second set of parentheses is used, only its content will be linked by the bot leaving the rest untouched. If a third set is used, the middle set delimits a text portion that will be replaced by the expression delimited by the third (and most inner set) The link will be placed around this last text portion. Any other set of parenthesis should be commented.

For deeper documentation, look at PHP manual's chapter about Pattern syntax.

link

A valid url. Internal urls are processed through the sefRelToAbs() function.

class

Specifies a class for the links markups of this specific bot. Overrides the default "class" parameter of the plugin.

alt

The alt attribute of the links markups

title

The tooltip displayed by the link

case

Optional. Ignored if the regex argument is used

0 - Case insensitive (default)

1 - Case sensitive

html

0 - The bot will ignore the HTML markups of your content and translate the HTML special characters (e.g. " will be translated to "). (default)

1 - The bot will treat the HTML markups and special characters as normal text.

In both cases, links already present in the text will not be affected by Bot link.

popup

Optional.

0 - Open link in the same window (default)

1 - Open link in a popup window



Examples

The "%" characters after "{" are only present in those examples so that the bot is ignored on this page... All the example bots are also present whithout "%" in this article. The links introduced around the example expressions are thereby genuine Bot link's links...

Use with text

{%bot_link text="Homepage" link="index.php" case="1" popup="1"}

homepage

Homepage.

Here the bot will place links around each occurences of "Homepage" but not "homepage" and the link will be opened in a new window... Note that the bot does not care about the context (quotes) of each occurence.

Use with regex

{%bot_link regex="/(whateverurl\.ext[^\/:])/i" link="http://www.whateverurl.ext/"}

whateverurl.ext?

http://www.whateverurl.ext/

http://www.whateverurl.ext:97/

In this example, using "regex" allows to select the context where whateverurl.ext is linked. Note that the question mark in whateverurl.ext? is also linked as it is part of the expression. The expression in the regex delimiter "/"needs to be put in parentheses.

Use of additional parentheses in regex

{%bot_link regex="/((otherurl\.ext)[^\/:])/i" link="http://www.otherurl.ext/"}

otherurl.ext?

http://www.otherrurl.ext/

Here the second set of parenthesis (inside the outermost parentheses) delimits the expression that will be linked by the bot. The question mark in "otherurl.ext?" will not be linked.

It is possible to use a third set of parenthesis. The best explanation is given through the following example:

{%bot_link regex="/(((yetanotherone\.ext)%l))/i" link="http://www.yetanotherone.ext/"}

yetanotherone.ext (Here "%l" has been introduced after yetanotherone.ext)

yetanotherone.ext (While here it was not)

The first set of parenthesis delimits, as in the other examples, the whole expression in the "/" regex delimiters. The second set delimits the expression that will be removed from the text and replaced by the expression inside the third set of parenthesis around which the link will be placed. In our example this results in the removal of "%l" after "yetanotherone.ext".

This allows to easily direct Bot link at specific occurences of your regular expression whithout changing the final output of your text.

Changelog

1.0.0 (My goal...)

  • Error handling for regular expressions. So that everything does not crash for a tiny (yet powerful) plugin...
  • User friendliness (Right now, Bot link is already user friendly. It is just very selective about who is its friend...)

0.2.0 (24/01/2008)

  • Avoidance of HTML markups and special characters (activated by default and options to disable).
  • Support for escaped quotes (\") in arguments.
  • Implementation of the "alt" argument.
  • Implementation of tooltips.
  • Improved processing of the default bots.

0.1.3 (10/01/2008)

  • Minor bugs fixed.

0.1.2 (10/01/2008)

  • Introduction of the "class" argument.

0.1.1 (09/01/2008)

  • Implementation of PHP4 unsupported functions.

0.1.0 (06/01/2008)

First release

P.S.

I hope every user will like this tiny plugin. I offer no warranty of the fitness of my code and you must use it at your own risks... Don't hesitate to contact me about whatever bug you might find or whatever improvement you think I could bring to this bit of code...

Comments
Search
nefar  - Like it   |2008-01-10 00:53:21
Good timing -- I was looking for something like this and you released it same day I was on the hunt. My only suggestion would be to dumb down the explanation a little for us non program gurus. I mean it's very easy to understand the 0/1 to shut off and popups and where to insert your url et cetera but the paragraph talking about expressions and parenthesese had me totally confused.

I would also be curious about one thing -- I would like to have the links actually hidden. Ie.. No underline of links it inserts is there anyway to do this?
molgyk  - Thanks for the comment   |2008-01-10 08:40:06
I will maybe put more detailed examples about the regex argument usage.
As for the hidden links. I will put a "class" argument that will be applied to the link so that its style may be modified through CSS. (For Bot_link 0.1.2?). Thanks again for the very useful suggestions.
wortspiel  - Error   |2008-01-10 11:09:59
Hi,

i think it would be very nice bot. But if i enable the bot, my webside does not work. I get this errormessage:
Fatal error: Call to undefined function: array_combine() in /xxx/home/mambots/content/bot_link.php on line 90

Do you have any ideas?
The default bot entry is:
{bot_link regex="/((moleculargeek\.net)[^\/])/i" link="http://www.moleculargeek.net/"}

thx
Wortspiel
molgyk  - What version did you download?   |2008-01-10 12:01:57
What exact version did you download?. This should be fixed since 0.1.1... But I could not test this myself since I use PHP5 on my server...
wortspiel  - Now it Works   |2008-01-10 13:36:38
Hi,

with Version 0.1.2 it works. But every Link has a '$' at the end of the URL.

Wortspiel
wortspiel  - Usage   |2008-01-10 13:40:03
How i have to seperate more then one entrys in Default bots?
Do you have a description for this?
molgyk  - Usage   |2008-01-10 14:14:09
There is no description. Just put the bots one after each other as what you enter will just be added to the text of your article before the plugin is processed.

Could you give me examples of your bots which add a '$'?
wortspiel  - Example   |2008-01-10 15:40:53
{bot_link regex="/((Word)[^\/])/i" link="http://www.link.com/" popup="1"}

I thought i can add some "Bot Links" in the "default Bot" area. So I can generate diffrent links from diffrent keywords. Is it not possible?
If not, i think it would be very nice, that this is possible.
molgyk   |2008-01-10 16:06:52
The "$" issue should be fixed in 0.1.3.

You may enter multiple bots one after each other in the backend "default bot" area. Do not separate them with any ";" or anything. The string you enter there is introduced directly in your content before the Bot_link plugin will process it.

You may also put bots directly in all your content items. Each of those will only modify their own article.

I hope this helps. Otherwise, give me an example of what you would like...
wortspiel  - Very nice   |2008-01-10 16:15:38
Hi,

and thanks for this very fast support. Now everything works fine.
I can add some Bot-URL's as default bot. Therfore i had the special character '/' in one keyword. With this character the bot crashed. But in my opinion it's not a big problem.

Thank you for this nice work.

Wortspiel
molgyk  - "/" crash   |2008-01-10 16:52:51
The crash is in fact expected if your regular expression delimiters are "/" you should escape the inner "/" with "\".
Otherwise, using the "text" argument instead of "regex" should do the trick too, if you don't need regular expressions...
nefar  - little help if anyone is able   |2008-01-10 22:28:31
I have never worked with CSS before so for the past couple hours I've been doing the google hunt for how to setup a class for this. Right now I'm using joomlart Ja_mercury free template. I'm fairly certain that the area I need to edit / add to is their template_css.css file. After my google searching I've come across a section on making a no underline link class and it shows the code as :

.nounder a {
text-decoration: none;
}

So I opened the template_css.css file and found :

/* Normal link */

a {
color: #404040;
text-decoration: underline;
}

a:hover, a:active {
color: #000000;
text-decoration: underline;
}

I added this to the section so it now reads :

/* Normal link */

a {
color: #404040;
text-decoration: underline;
}

a:hover, a:active {
color: #000000;
text-decoration: none;
}

.nounder a {
text-decoration: none;
}

I then formated the bot line to read : {bot_link regex="/((No Underline Test)[^\...
molgyk  - Class argument usage   |2008-01-11 08:13:32
I think you should correct the following line:
.nounder a {

to:
a.nounder {

or:
.nounder {

to specify that it is the link markup that contains the "nounder" class. Otherwise everything is in the right order... Hope this helps!
Wiggy  - Multiple Default Bots   |2008-04-11 21:30:36
Hi, first want to say great addition to the Joomla world. Only problem I seem to be having is adding multiple default bots to return links to different pages.

For example I have:

{bot_link regex="/((item1)[^\/])/i" link="http://item1page.html" popup="1"}{bot_link regex="/((item2)[^\/])/i" link="http://item2page.html" popup="1"}

etc.

Is this correct usage? For some reason it only lists item1 as a link, item2 never is linked, so I guess it halfway works?
molgyk  - Works for me   |2008-04-14 21:53:17
Hi,
Thanks for the comment. I tested your bots on my local site and it works for me as expected both inside an article or in the default bot parameter... I see no obvious mistake in your bots so I cannot really help. Maybe check whether you have the latest version (0.2.0) of Bot link? But I'm sure that's fine too...
merlyn5  - only in static content   |2010-01-03 16:52:30
Thank you for the bot!
Is there a way to make it work only in all static content? I want to use default bots but want they to work only in static contents (otherwise I've to write all the default bots in each static content and everytime a new bot is added I've to rewrite in each static content)

regards

merlyn
molgyk   |2010-01-04 07:52:51
Hi Merlyn,

The answer is no sadly. I did not include any such option in the bot... But, that's a good suggestion for the next version (of pluglink, the joomla 1.5 plugin replacing bot link)...

Thanks for the comment!
merlyn5   |2010-01-04 23:04:26
Unfortunately I don't have the joomla 1.5, I'm using the previous version. Maybe I can change the code to reach my scope?
molgyk   |2010-01-05 00:12:30
No problem. The changes should be simple. Just another parameter and some lines to discriminate static from other articles. Please let me know if you make such changes. We could diffuse it as a new version. Cheers!
Only registered users can write comments!

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."

Last Updated on Wednesday, 15 July 2009 19:35