spacer.png, 0 kB
 
Downloads - Bot link
 
Bot link, a tiny yet powerful Joomla! plugin - Examples and changelog Print E-mail
Written by molgyk   
Sunday, 06 January 2008
   
 
Article index
Syntax and arguments
Examples and changelog
 
   

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...


Add to favourites (0) | Quote this article on your site | Views: 3636

Comments (15)
10-01-2008 00:53
 
Like it
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?
 
nefar
10-01-2008 08:40
 
Thanks for the comment
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.
 
molgyk
10-01-2008 11:09
 
Error
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
 
wortspiel
10-01-2008 12:01
 
What version did you download?
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...
 
molgyk
10-01-2008 13:36
 
Now it Works
Hi, 
 
with Version 0.1.2 it works. But every Link has a '$' at the end of the URL. 
 
Wortspiel
 
wortspiel
10-01-2008 13:40
 
Usage
How i have to seperate more then one entrys in Default bots? 
Do you have a description for this?
 
wortspiel
10-01-2008 14:14
 
Usage
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 '$'?
 
molgyk
10-01-2008 15:40
 
Example
{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.
 
wortspiel
10-01-2008 16:06
 
Example
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...
 
molgyk
10-01-2008 16:15
 
Very nice
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
 
wortspiel
10-01-2008 16:52
 
"/" crash
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...
 
molgyk
10-01-2008 22:28
 
little help if anyone is able
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)[^\/])/i" link="http://www.testlink.com/" class="nounder" popup="1"} 
 
The bot does pickup the text and turns it into a link, however the link is still underlined. Have I made a mistake here in the bot syntax or is my .nounder a(text-decoration; None;} css addition wrong?
 
nefar
11-01-2008 08:13
 
Class argument usage
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!
 
molgyk
11-04-2008 21:30
 
Multiple Default Bots
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?
 
Wiggy
14-04-2008 21:53
 
Works for me
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...
 
molgyk

Only registered users can write comments. Please login or register

 

 



Last Updated ( Thursday, 24 January 2008 )
spacer.png, 0 kB
spacer.png, 0 kB
   
Design based on the Natura template from www.joomlashack.com - CC share alike license