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

Pass var to global

(Page 2 of 2)
> >
Quote Reply
Re: [Andy] Pass var to global In reply to
Everything ok.

It is needed to write

<%var%>

for using

<%var.something%>

That was the missing point.
Quote Reply
Re: [Robert] Pass var to global In reply to
Still not sure what you mean Whistle

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] Pass var to global In reply to
1. Make a global with an array.
2. Try to pass it with

<%global_name.array.key%>


You will fail.

Instead of this you write:

<%global_name%>
<%global_name.array.key%>

Thatīs all.
Quote Reply
Re: [Robert] Pass var to global In reply to
Ahhh right, yes thats correct. You have to run the global first, so that the values can be passed back into the template :)

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] Pass var to global In reply to
Now i have another problem.

For a global i need the typical:

my $tags = shift;
my $id = $tags->{ID};

but in the same time i have to pass

<%name_of_global(1)%>
<%name_of_global(22)%>

from the same template;

How i can get the $tags and the Number that i pass?
Quote Reply
Re: [Robert] Pass var to global In reply to
Hi,

Are you saying you want to PASS a custom ID ... OR have default to the ID tag? If so, just do something like:

Code:
my $id = $_[0] || $tags->{ID};

That way, it will have a look for the value passed in - like so:

Code:
<%name_of_global(22)%>

And failing that, it will then just use the value of "ID" from $tags.

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] Pass var to global In reply to
I solved it with:

set a=1
globalx

set a=2
globalx

set a =3
globalx

and sub {
tags=shift
$a=tags->{a}

do something with tags and a
Quote Reply
Re: [Robert] Pass var to global In reply to
You would be better using:

Code:
<%globalx("foo")%>

and then grabbing with:

Code:
sub {
my $a = $_[0];
}

Doing "set" for each of those variables, just means GT::Template has more work to do than it needs to Angelic

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] Pass var to global In reply to
My problem is:

I have a menu, the menu is written to every page with a global.
I pass for example lang=0/1 (german/english) and position=[0-5];
with lang i decide the language for the menu, with position i decide the "isChoosen" with css, background=choosen-color

As long i need no other var from my tables, everything is fine with <%call-global(x)%>
If i need the whole table data (tags=shift; var=tags->{var}) i got a problem, because i cant do:

my $a = $_[0];
my $tags = shift;
my $title = $tags->{Title}

I got an error.

Situation for this:

A special Category with own templates for category and detail-pages:
Infos about us; extra field "WHAT" with values 1,2,3 for History, Company, Clients

At the detailed page for all Links in Category "Infos about us", i have
left area for text and right area with all Titles to all "Links" inside this category, but sorted by the fielt "What" with a headline. It looks like:


Our History:
- Article 1: 100 years ago (with link to detailed)
- Article 2: The next generation

Our Company:
- Article 1: Today we have 8000 employees
- Article 2: Our shops worldwide

Our Clients:
- Article 1: 5 Mio statiesfied clients worldwide
- Article 2: Why clients has choosen us

I call it with:

set a=1
global
set a=2
global
set a=3
global

and inside the global:
counter=1
if a=1 and counter = 1 { output = headline "our history" (counter=2)
if a=2 and counter = 2 { output = headline "our company" (counter=2)
...

With this i can add more and more articles to this cat and just choose the value for the area to show (and a sort field also);

I choose this way, because it is too much to have a cat with "Information" and three more cats with History, Company, Clients

(Maybe i just send you a screenshot later, because my perfect english maybe will confuse you another time. :)
Quote Reply
Re: [Robert] Pass var to global In reply to
Hi,

Not sure I understand what you are having issues with, but if it works for you, let's just leave it :)

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] Pass var to global In reply to
In short: I need all vars from the tables, i take them with $tags=shift and i need one or more vars from the template itself as you told me.
It seems i can have both only with setting something with SET=VALUE, because i have it in $tags->{VALUE} for the global.
The whole LSQL has maybe 100 Links later in 100 categories; so the time for building is ok for me.
Quote Reply
Re: [Robert] Pass var to global In reply to
I have tried title_linked, but i had problems with Umlauts and more. So i use my own breadcrump again.
Now i have 260 seconds with build-all.
> >