Gossamer Forum
Quote Reply
How to show Company data
Hi!


I'm stuck with something like this:


In my database I have two type of links

- Company
- Product




Each Product link has one custom field called "CompanyID" and it
contains "ID" value of Company link.




The problem is:

Currently I am using this global to grab Title and URL

sub {
return $DB->table('Links')->get($_[0]);
}


and <%CompanyInfo($CompanyID)%> to show Company data.


But, this has to be placed at the end of the link template, because if it is placed
at the beginning of link template, all the Product data (Title, URL and other stuff)
are pulled from Company instead of Product link.


Is there a way (and I bet there is :) ) to create a global which will
pull data from Company without messing my Product display.

I just hope that you will understand this mess :)


Thank you!
Quote Reply
Re: [Payooo] How to show Company data In reply to
Try this global:
Code:
sub {
my $data = $DB->table('Links')->get($_[0]);
return { map { +"company_$_" => $data->{$_} } keys %$data };
}
This should prefix all the fields with 'company_'. Your product fields are still the same.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] How to show Company data In reply to
THANK YOU YOGI! Smile