Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Edit global progmatically

Quote Reply
Edit global progmatically
Hi Guys!

Before I try to reinvent the wheel or reverse engineer... Does anyone have a quick line or two of Perl that easily lets you pragmatically update a current Template Global?

Thanks for your time...

Cheers,

Alex
Quote Reply
Re: [AlexJ] Edit global progmatically In reply to
Hi,

What do you want to do with it? Can't say I've ever done that before - but Links/Admin/Tools.pm global_editor() should give you some pointers on how to do it, as that is how they manage it in the GLinks admin panel :)

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] Edit global progmatically In reply to
Hi Andy,

Thanks for pointing me to a good starting point.

Back in time when I wrote this GT cored game, I rather lazily put an event time in the template globals. Since this time changes every month I've had to manually edit the time in the admin every month.

Right now I'm working on a project to fully automate the game, so that it would run for all eternity without any required intervention from me, so I need to be able to either update that time pragmatically or move it to another location.

I'll post back with my solution....

Best regards,

AlexJ
Post deleted by AlexJ In reply to

Last edited by:

AlexJ: Sep 1, 2020, 3:06 PM
Quote Reply
Re: [AlexJ] Edit global progmatically In reply to
It turns out that this is super easy:

Code:
my $dir = "$CFG->{admin_root_path}/templates/luna";
my $file = 'globals.txt';
my $globals = GT::Config->load("$dir/$file", { create_ok => 1, inheritance => 1, local => 1, cache => 1 });
$globals->{your_global} = "UPDATED DATA";
$globals->save;
Cheers,

Alex
Quote Reply
Re: [AlexJ] Edit global progmatically In reply to
Thanks for sharing. I had a feeling it would be pretty easy :) (uses the same logic as changing the $CFG variables)

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!