Gossamer Forum
Quote Reply
what's more efficient?
You want to write some code that spits out alot of HTML onto a particular templated page. Is it more efficient to put the html into the template or into a global?

Thanks,
Mike
Quote Reply
Re: [Swaylock] what's more efficient? In reply to
Probably better in the template. If you write a global, it needs to load that global, which in turn is probably slower.

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: [Swaylock] what's more efficient? In reply to
HTML should be loadable from files, rather than embedded in code anyway.

If you put the html in the globals file, you enlarge the file, and thus overhead for each instance of running code. If you have it in a template file, it's compiled once, and loaded from the ../compiled directory.

So, which is more efficient depends on what your needs are.

Also, writing "big" globals is not a good idea. You'd be better off to put them in a module, and load the module from the Plugins:: area, using the <%Plugins::Module::Name%> syntax. That way, you have more control over your code layout, and a more logical structure -- while limiting overhead in the globals.txt file.

globals should be small snippets, that are called often, or on multiple templates. They are things that you can put in one place, and edit easily, to make site-wide changes.

Though, often overlooked, the modular layout allows easy integration of external modules into the templates. Quite complex things can be called, and it's easier to modify and edit a .pm file than the globals.txt. You also have more control over what goes on in the set up of the .pm file.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] what's more efficient? In reply to
Pugdog,

So, using the plugin model, how would I get some code to execute in the middle of my categories.html template?

Thanks for the lesson(s).
Mike
Quote Reply
Re: [Swaylock] what's more efficient? In reply to
You would just write a regular perl module, look at the format of any of the plugins for examples. You make sure if it's in the Plugins directory, that it's set up as Plugins::Module_Name

Inside your template, you would just call it as <%Plugins::Module_Name%> You can pass in parameters, and return new tags.

There is good information on it in the GT Manual/Docs in the help area.

The only thing is to set it up to put your modules in the Plugins area. By doing that, it will be ignored by Links upgrades. So, it's a "safe" place to put them.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] what's more efficient? In reply to
Pugdog,

That makes total sense seeing as I've been messing around alot with the plugin system lately.

Thanks.
Mike