We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

NEW - Neat Links Plugin…

Development and Programming

Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

[EDIT]- I meant to mention that along with this plugin you will also need to turn off the :

Admin->Weblog Administration->Weblog Management->Edit Preferences->Weblog Posting Preferences-Automatically turn URLs and email addresses into links?

in order for this plugin to work correctly.

Hiya,

Another one for anyone who’s interested!

This plugin was created due to a need that Jan had over in this thread.

If you ever have users / clients entering links into fields but have no control over whether or not they are adding in the http:// bit or not then if you try to make a link with one that doesn’t have the http:// bit then you will end up with a totally messed up link as ExpressionEngine will rightly put your site link in front of it. Not very nice at all! 😊

So that’s why I made this plugin.

Neat Link - Usage
{exp:neat_link link_title="Title for link" link_text="Yahoo.com" link="www.yahoo.com" target="_blank"}
You can also use custom fields instead of hard-coding the values which is really what the plugin is all about! 😊
{exp:neat_link link_title="{link_title}" link_text="{link_text}" link="{link}" target="_blank"}
Note that the custom fields {link_title}, {link_text} and {link} all need to have their formatting set to none or this plugin will not work Other custom parameters that you can pass to the plugin are as follows : class=”flashy-css-style” rel=”external” id=”my-css-id” You can specify one or all of these. None of the parameters above are required though. Obviously you probably wouldn’t use the id and class at the same time though! 😊

Anyway hope it helps some people out.

Best wishes,

Mark

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Oops I knew I would miss something. Will add them in now and re-upload after I have made my tea!! 😊

Best wishes,

Mark

       
Jan_Huygens's avatar
Jan_Huygens
106 posts
17 years ago
Jan_Huygens's avatar Jan_Huygens

It works exactly as it says on the tin 😊

Three cheers for Mark!

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Plugin updated and new version attached to top thread. I have also updated the instructions as well.

Should hopefully all work.

Best wishes,

Mark

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham

Nice one mark.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen
Nice one mark.

Why thank you kind sir! 😊

Nothing quite as fantastic as the work that you are doing at the moment but I am learning at least. I need to neat-en up the code-base in this plugin as I’m sure there are neater ways of writing some of what I have done in there.

Best wishes,

Mark

       
Deron Sizemore's avatar
Deron Sizemore
1,033 posts
17 years ago
Deron Sizemore's avatar Deron Sizemore

Nice! I might have use for this now actually. 😊

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Hi Deron,

Thanks for the comment. Hope it does well for you. Any problems just give a shout. I’m pretty sure it should work fine but I have only tested it myself so the more people that do test it will definitely help 😉

Best wishes,

Mark

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham
I’m sure there are neater ways of writing some of what I have done in there.

You could use some shorthand like:

$id = $TMPL->fetch_param('id') ? "id='" . $TMPL->fetch_param('id') . "'" : '';
$class = $TMPL->fetch_param('class') ? "class='" . $TMPL->fetch_param('class') . "'" : '';
$rel = $TMPL->fetch_param('id') ? "rel='" . $TMPL->fetch_param('rel') . "'" : '';

to set the default values 😊

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

There’s always one isn’t there 😉 😊 😉

Thanks Leevi. I had seen this type of coding before in plugins but never really understand it so was going to look it up. I know what it is doing but I just think that the ? and other such stuff confuses me.

Don’t suppose you would be kind enough just to talk me through what it means syllable by syllable as it were?

Thanks.

Best wishes,

Mark

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Just to notify of a small plugin update. No functionality additions but a mention to my learned friend Leevi!! 😉

Best wishes,

Mark

       
mrwarren's avatar
mrwarren
31 posts
17 years ago
mrwarren's avatar mrwarren

Mark! Awesome work w/ Neat Link. I modified it a bit to make it a tad more flexible. The first time I went to test it it didn’t work, because someone (okay okay, it was me) had entered in a website like this: expressionengine.com

So I changed the plugin like this and it worked great.

if (substr($url, 0, 4) != "http"){
        $url = "http://" . $url;
        }

That seems to catch more instances of a link, be it expressionengine.com, www. expressionengine.com or http://expressionengine.com. What do you think?

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

HI there Brian,

Absolutely makes sense! 😉

Thanks for picking up on that deliberate error that I made 😉 😉

Sorry I didn’t even think about URLs without the www when I made this so your modification is definitely a much needed one. I have now updated the plugin to have your code instead and have re-uploaded it to the first post. If you open up the plugin you will see some thanks to yourself in the update list 😉

Best wishes,

Mark

       
mrwarren's avatar
mrwarren
31 posts
17 years ago
mrwarren's avatar mrwarren

Brilliant!

The reason I happened to notice is the exact first time I tested the plugin it was on a url that happened to not have the www in there.

I have another change for you that I made, probably another deliberate error…

I changed this:

$rel = $TMPL->fetch_param('id') ? "rel='" . $TMPL->fetch_param('rel') . "'" : '';

to this:

$rel = $TMPL->fetch_param('rel') ? "rel='" . $TMPL->fetch_param('rel') . "'" : '';

I had some specific “rel” needs for my links, and so I wanted that as its own parameter.

Also I noticed the pi_version is still at 1.0.1.

All really MINOR stuff. I’m just the nitpicky guy who tweaks all your awesome ninja work. Thanks for the plugin!

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Oops.

Sorry about that. Must have made a typo on that one. Have now updated the plugin with the correct item in there. Was meant to work but I must have rushed and not tested thoroughly enough so sorry about that.

No worries on picking. I like the fact that people are using these things and letting me know how to improve them. A nice community spirit is always a good thing 😊

Thanks again.

Best wishes,

Mark

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.