Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Display Tag only if Plugin found

Quote Reply
Display Tag only if Plugin found
How can I leave plug-in tags in my templates, and have the template bypass the tag without producing errors if I uninstall the plug-in?

I tried:

<%if Plugins::EditorMonitor::EditorLastLogin %>

<%Plugins::EditorMonitor::EditorLastLogin ($Username)%>

<%endif%>

But the template still produces an error saying basically "no plugin buddy, so can't do that"

Crazy


http://www.iuni.com/...tware/web/index.html
Links Plugins
Quote Reply
Re: [Ian] Display Tag only if Plugin found In reply to
So how come <%if Editors%><%Editors%><%endif%> works, it doesn't with a plugin function?


http://www.iuni.com/...tware/web/index.html
Links Plugins
Quote Reply
Re: [Ian] Display Tag only if Plugin found In reply to
Try a set tag.

<%set exists = Plugins::EditorMonitor::EditorLastLogin($Username)%>

Then do:

<%if exists%>

Blah

<%endif%>
Quote Reply
Re: [Paul] Display Tag only if Plugin found In reply to
ooooo, thanks Paul!Smile I will try that!

Must be getting late in the Uk?


http://www.iuni.com/...tware/web/index.html
Links Plugins
Quote Reply
Re: [Ian] Display Tag only if Plugin found In reply to
Yeah its 1.43am

I was just listening to MTV with my cordless headphones attached to the tv and just stopped off at the forum on my way to bed :)
Quote Reply
Re: [Paul] Display Tag only if Plugin found In reply to
I know the feeling... I thinks for me its more like I stopped off at my bed on the way to the forum!!Tongue


http://www.iuni.com/...tware/web/index.html
Links Plugins
Quote Reply
Re: [Ian] Display Tag only if Plugin found In reply to
Oh wait sorry I think I misunderstood your question. That will still produce an error if the plugin doesn't exist as it won't be able to find the function.

You may need to use a global or something for that.

sub { -e "$CFG->{admin_root_path}/Plugins/YourPlugin.pm" ? 1 : 0 }

Then you'd use the global in the if tag...

<%if global%>

Last edited by:

Paul: Jun 4, 2002, 5:48 PM
Quote Reply
Re: [Paul] Display Tag only if Plugin found In reply to
Is it possible to do the error handling inline within the template?

Like, if the error returns function not found, then ignore it?

I see where you are going by putting it into a global though. Thanks.


http://www.iuni.com/...tware/web/index.html
Links Plugins
Quote Reply
Re: [Paul] Display Tag only if Plugin found In reply to
Just looking for a method that will let me add extra tags to the existing ones (with CGI.pm), and came across this thread.

>>>sub { -e "$CFG->{admin_root_path}/Plugins/YourPlugin.pm" ? 1 : 0 } <<<

That will most likely not work. There is a bug in LSQL that causes it to simply 'print' the value of the sub, if it is not ordered on seperate lines....i.e it should be more like;

Code:
sub {
-e "$CFG->{admin_root_path}/Plugins/YourPlugin.pm" ? 1 : 0;
}

Just thought I would make a post, so anyone who may be new to LSQL, and see this thread, will not get confused Crazy

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Display Tag only if Plugin found In reply to
Works perfectly fine on my 2.1.2 copy...

sub { return "hello" }

Puts "hello" in my template.
Quote Reply
Re: [Paul] Display Tag only if Plugin found In reply to
Maybe a 2.1.1 bug? I'm definate there was an issue with it. If you had no newline after the 'sub {' and '}' parts, it would simply print out the code itself Unsure

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Display Tag only if Plugin found In reply to
Alex had explained that as a parsing thing he did for picking out subs. He never posted he changed the behaviour, as he was pretty clear it was a way to cut overhead or errors or such.


PUGDOG´┐Ż Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.