Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Auto Link 1.1 - How do I add the hyperlinks ?

Carlo_13Carlo_13
edited August 2012 in Vanilla 2.0 - 2.8

Hello,

For the person who created this plugin, how do I add the hyperlinks ?

Tks

Tagged:

Comments

  • Options

    what exactly would you like to do? give me an example. And I'll try to provide a solution on how to adjust.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options

    Hi peregrine, tks for taking the time to answer my post.

    I just want to add an automatic hyper links in everybody posts.

    Let's I have to add an hyperlink for "Chocolate", every body you write chocolate in their post would get the word "Chocolate" hyperlinked.

  • Options

    You wrote:

    edit the class.autolink.plugin.php to add keywords and associated link.

    What strings in class.autolink.plugin.php shoudl I edit to add keywords and links?

  • Options

    you can do it two ways.

    Option 1

    tag option

    a) chocolate is a tag in your tagging database,
    then it can be autotagged
    if you choose the 3rd option in settings (tags is checked in settings in the plugin).

    Option 2

    creating your own directed links

    choose the 2nd option in settings (links is checked in settings in the plugin).

    if you want the word chocolate to be autolinked always to www.chocolate.com

    then go into class.autolink.plugin.php
    
    and modify it
    
    e.g.
    
    I have the code in the example as
    
    
         public function LinkWord($match) {
                $item = $match[0];
    
    
                $wordlinkArray = array("documentation" => "http://vanillaforums.org/docs",
                    "wiki" => "http://vanillawiki.homebrewforums.net/index.php/Main_Page",
                    "localization" => "http://vanillaforums.org/docs/localization",
                    "plugin" => "http://vanillaforums.org/docs/pluginquickstart",
                    "bonk" => "http://vanillaforums.org/docs/errors",
                    "config" => "http://vanillaforums.org/docs");
    
    
    
    
    to make it only highlight chocolate that goes to www.chocolate.com
    
    
    change it to
    
    public function LinkWord($match) {
                $item = $match[0];
    
    
                $wordlinkArray = array("chocolate" => "http://chocolate.com");
    
    
    
    lets say you wanted vanilla and chocolate
    
    
    change it to 
    
    public function LinkWord($match) {
                $item = $match[0];
    
    
                $wordlinkArray = array("chocolate" => "http://chocolate.com",
                         "vanilla" => "http://vanilla.com"
    );
    
    
    
    if you wanted strawberry , vanilla and chocolate
    
    
    change it to 
    
    public function LinkWord($match) {
                $item = $match[0];
    
    
                $wordlinkArray = array("chocolate" => "http://chocolate.com",
                         "vanilla" => "http://vanilla.com",
                          "strawberry" => "http://strawberry.com"
                           );
    

    Option 3 - lets say you made the changes in both option 2 and option1

    meaning chocolate was a tag in your database, but was also a directed link (set up in option 2)

    you could use the precedence checkbox (precedence option checkbox in dashboard gfor plugin to say which linkage take precedence when you click on it

    e.g - when clicking on chocolate - should it go to www.chcolate.com or do a search of your discussions containing the tag chocolate.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    peregrineperegrine MVP
    edited August 2012

    Likewise you can alter the css

    to display "autolinked as highlighed, underlined, dotted underline, etc.

    just modify plugins/AutoLink/design/al.css

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options

    @Carlo_13 and @est

    do you follow?

    I could change the plugin and give a settings for about 3 or 4 options for directed linkwords and linkage.

    But I figured people would want more than 3 or 4 - so it is easier just for you to change the program. Because invariably someone would want just one more keyword.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options

    @peregrine

    Thank you so much! I'll try that.

    I was waiting for this plugin for a long long time.... I am not lying:
    http://vanillaforums.org/discussion/16632/plugin-create-automatic-hyperlink#latest

  • Options
    peregrineperegrine MVP
    edited August 2012

    Let me know if it works for you - its alway cool if somebody uses a plugin that is developed and actually tells the developer, I believe.

    If it doesn't work for you post your changes and error messages if any will sort it out.

    the syntax with commas, etc has to be just right.

    Too little positive feedback on users who use the plugins and themes in general, I think

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    estest New
    edited August 2012

    @peregrine

    Thanks a lot for sharing this plugin, it really helps to add internal linking to the site, and it works.

    But... Can I make this plugin to work with international characters? E.g. with cyrillic.

  • Options
    peregrineperegrine MVP
    edited August 2012

    est said:
    @peregrine

    Thanks a lot for sharing this plugin, it really helps to add internal linking to the site, and it works.

    But... Can I make this plugin to work with international characters? E.g. with cyrillic.

    you may be able to tinker with the $search variable

    and the addition of some variant of
    \p{M}

    I'm not real familiar with internationalization or cyrillic or unicode

    Perhaps someone else might have a solution

    http://stackoverflow.com/questions/3538293/php-regular-expression-pcre-does-not-support-l-l-n-p

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options

    other options are to try for $search in class.autolink.plugin.php

    $search = '/(\b\X{4,15}\b)/u';

    or possibly

    $search = '/(\b\p{Cyrillic}{4,15}\b)/u';

    be interested if either of these work, if you want to report back @est

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options

    Neither of these works. Even $search = '/(\w+)/u'; searches only English (Latin).

    Now I'm digging into system locale settings.

  • Options
    peregrineperegrine MVP
    edited August 2012

    @est

    I don't think the unicode works well with the \b consequently the callback probably won't work. But a search and replace array works for cyrillic, let me know and I'll send you the code.

    Here's a screenshot of cyrillic unicode with modified autolink.

    I don't know cyrillic but I cut and pasted some words from here

    http://en.wikipedia.org/wiki/Cyrillic_script_in_Unicode

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options

    I don't think the unicode works well with the \b consequently the callback probably won't work. But a search and replace array works for cyrillic, let me know and I'll send you the code.

    Oh, that would be great, please show me the code!

    Here's a screenshot of cyrillic unicode with modified autolink.

    I don't know cyrillic but I cut and pasted some words from here

    Yes, this is cyrillic.

  • Options
  • Options
        protected function WordFind(&$text) {
    
    
    
    $link[0] = "http://en.wikipedia.org/wiki/Cyrillic_script_in_Unicode";
    $link[1] = "http://www.russianlessons.net/dictionary/transliterate.php?english=Hello";
    $link[2] = "http://www.test.com";
    $preanchor= '<a class="autolinker" title="click me to for more information" href="';
    $midanchor ='">';
    $postanchor = '</a>';
    
    $word = array();
    $word[0] = "ћириличког";
    $word[1] = "хэлло";
    $word[2] = "писма";
    $patterns = array();
    
     for ($x = 0; $x < count($word); $x++) {
         $patterns[$x] = "/$word[$x]/";
         }
    
    $replacements = array();
    $replacements[0] = $preanchor . $link[0] . $midanchor . $word[0]  . $postanchor;
    $replacements[1] = $preanchor . $link[1] . $midanchor . $word[1]  . $postanchor;
    $replacements[2] = $preanchor . $link[2] . $midanchor . $word[2] . $postanchor;
    
    $text =  preg_replace( $patterns, $replacements, $text);
    
    
    
            return $text;
        }
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options

    I tried the code, but it doesn't work. I think the problem most likely is in my server environment.

    Anyway, thanks a lot for your help.

Sign In or Register to comment.