Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Update Other Links Fields on Payment

Quote Reply
Update Other Links Fields on Payment
When someone pays for a link, I would like to be able to have the IsFeatured field (which I have added as a Yes/No field) automatically set to Yes (default is No).

I assume this isn't too hard, but I don't know where to start.

Thanks!
Quote Reply
Re: [Jobu] Update Other Links Fields on Payment In reply to
If you aren't using the field for something else, there's always the isPaidLink tag you can use in the templates.

Adrian
Quote Reply
Re: [brewt] Update Other Links Fields on Payment In reply to
Cool. That will work!

How do I update the following global to pull all links that are either tagged isFeatured or isPaid? Of course, it is only grabbing isFeatureds a the moment.

Code:

sub {
# Displays the featured links on each category page.
my ($id,$search_db,$output,$sth,$link);
$id = shift;
$search_db = $DB->table('Links', 'CatLinks');
$search_db->select_options ("ORDER BY Title");
$sth = $search_db->select ( {isFeatured => 'Yes', isValidated => 'Yes', CategoryID=>$id});
while ($link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('link', $link);
}
return $output;
}

Last edited by:

Jobu: Jul 30, 2006, 4:04 PM
Quote Reply
Re: [Jobu] Update Other Links Fields on Payment In reply to
  
$sth = $search_db->select ( {isFeatured => 'Yes', isPaid => 'Yes', isValidated => 'Yes', CategoryID=>$id});

Last edited by:

rascal: Jul 30, 2006, 4:51 PM
Quote Reply
Re: [rascal] Update Other Links Fields on Payment In reply to
If you you want isPaid OR isFeatured, then you need to use GT::SQL::Condition.

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [rascal] Update Other Links Fields on Payment In reply to
In Reply To:

$sth = $search_db->select ( {isFeatured => 'Yes', isPaid => 'Yes', isValidated => 'Yes', CategoryID=>$id});



I tried this and got an error suggesting that IsPaid is undefined (see below). I also tried IsPaidLink. And now that I'm looking at the Links table, I don't see an "IsPaid" field. Am I missing something?

Code:


A fatal error has occured:
Can't call method "fetchrow_hashref" on an undefined value at (eval 38) line 8.

Please enable debugging in setup for more details

Last edited by:

Jobu: Jul 30, 2006, 9:52 PM
Quote Reply
Re: [Jobu] Update Other Links Fields on Payment In reply to
Sorry,

Change isPaid to wasPaid
Quote Reply
Re: [rascal] Update Other Links Fields on Payment In reply to
In Reply To:
Sorry,

Change isPaid to wasPaid


No dice. Also, wouldn't your suggestion only select links that are featured, validated, AND paid? I want to select all links that are featured or paid and validated.
Quote Reply
Re: [brewt] Update Other Links Fields on Payment In reply to
In Reply To:
If you aren't using the field for something else, there's always the isPaidLink tag you can use in the templates.

So I got this to work from the templates, but it is not satisfactory for my purposes.

What I need to do is pull all links that are either featured, i.e., IsFeatured = "Yes" or are paid links, and return them all. Ideally I could just update the following Global with an "or" command:

Code:

sub {
# Displays the featured links on each category page.
my ($id,$search_db,$output,$sth,$link);
$id = shift;
$search_db = $DB->table('Links', 'CatLinks');
$search_db->select_options ("ORDER BY Title");
$sth = $search_db->select ( {isFeatured => 'Yes', isValidated => 'Yes', CategoryID=>$id});
while ($link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('link', $link);
}
return $output;
}

Right now I am selecting all links that are isFeatured, isValidated... I want to also select as part of this all links that are paid and IsValidated.

This seems like it shouldn't be overly complex?
Quote Reply
Re: [Jobu] Update Other Links Fields on Payment In reply to
To get validated and paid links use VIEWABLE. That however, includes free links, so you might want to add ExpiryDate < FREE. So something like select({ isFeatured => Yes }, GT::SQL::Condition->new(ExpiryDate => '<' => FREE), VIEWABLE);

Adrian
Quote Reply
Re: [brewt] Update Other Links Fields on Payment In reply to
In Reply To:
To get validated and paid links use VIEWABLE. That however, includes free links, so you might want to add ExpiryDate < FREE. So something like select({ isFeatured => Yes }, GT::SQL::Condition->new(ExpiryDate => '<' => FREE), VIEWABLE);



Hi Adrian,

I think we are getting there -- However, I want to show all paid links OR all IsFeatured links (not a paid link that is also featured). How can I use an OR command?

Thanks!

Last edited by:

Jobu: Aug 3, 2006, 7:49 PM
Quote Reply
Re: [brewt] Update Other Links Fields on Payment In reply to
I think I got it!

Code:

sub {
# Displays the featured links on each category page.
my ($id,$search_db,$output,$sth,$link);
$id = shift;
$search_db = $DB->table('Links', 'CatLinks');
$search_db->select_options ("ORDER BY Title");
my $cond = GT::SQL::Condition->new(IsFeatured => '=' => 'Yes', ExpiryDate => '<' => FREE);
$cond->bool('OR');
$sth = $search_db->select({CategoryID=>$id}, $cond);
while ($link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('link', $link);
}
return $output;
}