Gossamer Forum
Home : Products : DBMan SQL : Discussion :

BUG: Globals are loaded from default template set, not from t=test template set

Quote Reply
BUG: Globals are loaded from default template set, not from t=test template set
I use DBSQL v2.1.0.

Very strange, but it seems, that globals.txt is loaded from default template set,
not from the 'test' template set I currently use.

I created a new template directory:
/admin/templates/test

I placed a login.html and globals.txt file into 'test' directory.
The 'default' directory does not have globals.txt in it.

I load the following page:
http://www.mysite.com/cgi-bin/db/db.cgi?t=test

It should display <%company_name%>,
but if the globals.txt is missing from from default, then I get Unknown Tag: 'company_name'.


Is there a workaround for this?


Thanks,
Webmaster33
Quote Reply
Re: [webmaster33] BUG: Globals are loaded from default template set, not from t=test template set In reply to
Hi

in Home.pm I'd replace the following line where the template_set variable is defined.


replace

Code:
my $template_set = $self->{cfg}->{template} || 'default';

with

Code:

my $template_set;

if ( defined $self->{cgi}->{t} ) {
$template_set = $self->{cgi}->{t}; }

else { $template_set = $self->{cfg}->{template} || 'default'; }

I haven't had the time to test it yet, but I hope it might help to solve the problem. If you have a free testing environment, please let me know if this works.

Cheers,
Coolliver
Quote Reply
Re: [olivers] BUG: Globals are loaded from default template set, not from t=test template set In reply to
Thanks very much for the quick reply and for the workaround!

Yes, the workaround seems to be logical. It should work.

Will test it soon...

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [olivers] BUG: Globals are loaded from default template set, not from t=test template set In reply to
I tried it, and yes, the fix works Smile
Globals in template 'test' are displayed now.
Thanks very much!

I shortened the code a bit, but the main idea is the same.



Fix for GLOBAL and LANGUAGE file load problem, when it loads from default template set, instead of the URL input of the 't' parameter.

1) In Home.pm find the
_load_global
and
_language
methods and replace the following codes in both:

replace

Code:
my $template_set = $self->{cfg}->{template} || 'default';

with

Code:
#my $template_set = $self->{cfg}->{template} || 'default'; # original code
my $template_set = (defined $self->{cgi}->{t}) ? $self->{cgi}->{t} : ($self->{cfg}->{template} || 'default'); # bugfix

This solves the bug.

GT staff may include the bugfix into the CVS...


Thanks again for the fix, Oliver!

Webmaster33

Last edited by:

webmaster33: Nov 28, 2007, 4:02 PM
Quote Reply
Re: [webmaster33] BUG: Globals are loaded from default template set, not from t=test template set In reply to
Fixed Home.pm attached.
Quote Reply
Re: [webmaster33] BUG: Globals are loaded from default template set, not from t=test template set In reply to
Thanks for testing the code and for uploading your Home.pm! I'm glad that the "global" and "language" problem can be fixed by replacing one file. Especially for multi language sites it's important to apply this fix before using different language templates.

All the best
Smileliver
Quote Reply
Re: [olivers] BUG: Globals are loaded from default template set, not from t=test template set In reply to
It seems I found a further problem.

Now it's with the inheritance of the globals.txt

We have 2 template sets.
  • One is "homes" with global.txt,
  • other is "test" without global.txt, but with inheritance from "homes".

    So we should able to use the globals from "homes" template set, right in "test" template set.



  • homes template set has "company_name" global.
  • "test" template set has inheritance set in .tplinfo:
    {
    inheritance => '../homes'
    }

    I placed <%company_name%> into login.htm.
    I can
    /cgi-bin/dbsql210/db.cgi?t=test
    but I get error:
    Unknown Tag: 'company_name'

    When
    I call
    /cgi-bin/dbsql210/db.cgi?t=homes
    it displays correctly:
    Gossamer Threads Inc.


    I think this is a bug again...

    Could somebody test and confirm this bug???

    Thanks in advance!

    Best regards,
    Webmaster33


    Paid Support
    from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
    Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
  • Quote Reply
    Re: [webmaster33] BUG: Globals are loaded from default template set, not from t=test template set In reply to
    Hello again

    I have tested it and I can confirm the problem.

    Have a look at this thread and read what Alex said in October 2003:
    "For DBMan SQL, it requires updating it to use a GT::Config object to handle the language and the globals files."

    That's all I found.

    Unsureliver
    Quote Reply
    Re: [olivers] BUG: Globals are loaded from default template set, not from t=test template set In reply to
    Note, that I updated the GT library of DBManSQL v2.1.0 to the GT library used in LSQL v3.2.0.

    It seems, that it can integrate without problem. I can now use better template handling, like using <%include $variable%>.
    But this also means, that update of GT::Config did not bring any good fix to this problem.

    Best regards,
    Webmaster33


    Paid Support
    from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
    Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
    Quote Reply
    Re: [olivers] BUG: Globals are loaded from default template set, not from t=test template set In reply to
    Posted a bugfix here for the language and global inheritance problem:
    [BUGFIX] Template and Global inheritance problem in DBManSQL v2.1.0
    Please test it, and post your result there.

    Best regards,
    Webmaster33


    Paid Support
    from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
    Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...