Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Passing extra vars from build.cgi to build.pm

Quote Reply
Passing extra vars from build.cgi to build.pm
Have the following problem:

in nph_build.cgi we call:
print DETAIL Links::Build::build ('detailed', $link);

in build.pm we take:
my $link = shift;

So i could play with every $link->{Fieldname} here.

I tried in build.cgi to pass with:
$link->{extra} = '1';
print DETAIL Links::Build::build ('detailed', $link);
but it fails, i can print out $link->{extra} , but it seems it isnīt inside the $link we pass to build.pm

another idea was to pass it like that:
print DETAIL Links::Build::build ('detailed', {$link, extra => '1'});
but then the build.pm takes the wrong arguments with the shift.

I also have tried to refill a field from the Links table, but this failed too.
$link->{Description} = '1';
print DETAIL Links::Build::build ('detailed', $link);

Remember the same problems in 1.x, but there i was solveable for me.

Now i have only one solution to copy the build_detailed in build.pm so often i need that extra var. But it thatīs not very clean ;-(

Has someone a clue, how to do that?
Robert
Quote Reply
Re: [Robert] Passing extra vars from build.cgi to build.pm In reply to
Quote:
I tried in build.cgi to pass with:
$link->{extra} = '1';
print DETAIL Links::Build::build ('detailed', $link);
but it fails, i can print out $link->{extra} , but it seems it isnīt inside the $link we pass to build.pm


That doesn't make any sense. What you are passing is $link (hash ref), and if you added the "extra" field to the hash, you would pass that along.

Do you have the whole section of code? There might be some other reason this isn't working. Maybe what you are passing/printing isn't what you think.

...

Checking, I wondered if the routine re-fetched the link record, and it appears to do so:

my $id = $link->{ID};
$link = $link_db->get ($id, 'HASH');


When it does that, it replaces the passed in $link with the re-fetched link. You might have to edit that routine a bit to do what you want. Maybe just commenting out that line will do it.


PUGDOGïŋ― Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Passing extra vars from build.cgi to build.pm In reply to
Thank you, Robert. Once again.

Do you have a clue, why it is fetched once more ?
It makes no sense to pass something from sub a to sub b,
while sub b gets the data once more, isnīt so?

While i have to finish the code, i have just copied the build_detail
nine times ;-(, itīs not very clean, but it takes, what i want.

Now im not clear about that refetching, but i will try it to shorten my build.pm.

Now i have another thing with the same code, but different vars.

I have six details pages and let pass a menu with a global for every one.

It looks like this

Home | Service | Galerie

While it should show the right point in fat, i have juet copied this global six times like this

globalA for template A

... code ...
b Home /b | Service | Galerie
... code ...

globalB for template B

... code ...
Home | b Service /b | Galerie
... code ...


Is it possible to pass something from the template to the global ?
Else i could write six globals instead and pass them all, while writing in
template A
b global1 /b | global2

template B
global1 | b global2 /b

But this will make six times a query to mysql, cause i fetch the data for that urls from it.

So it is the best solution, i had or you know how to pass something to a global from a template, that would be better.


Robert

BTW: Are things running better today? Havenīt heard anything from you the last month. What are you working on at the moment?