Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Adding links to homepage

(Page 2 of 2)
> >
Quote Reply
Re: Adding links to homepage In reply to
Hi Paul,why do you not help him?

You gave the advice with category => 'name'
but this couldnīt work, cause he tries to get data from Links;
then you advice to use the Cat table;
but this wont bring him the links;


I will take a look now to the old known code of 1.13; maybe i find something.

Robert

Quote Reply
Re: Adding links to homepage In reply to
Uh well you tell me where the category column is in the Links table....

If he wants to select the links from a certain category then he can't use the LINKS table now can he!!

.....and I didn't tell him to use the Cat table, I suggested to use BOTH.

Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: Adding links to homepage In reply to
For the last 5 new on your homepage try this plz:

my ($sth, $root, $cat, $cat_list, $start_new, $total);

my $cat_db = $DB->table('Category');
my $link_db = $DB->table('Links');
$GRAND_TOTAL ||= _grand_total ($link_db);

my $output;
$link_db->select_options ("ORDER BY ID DESC LIMIT 5");
my $sth = $link_db->select ({ isNew => 'Yes', isValidated => 'Yes'});

while (my $link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('link', $link);
}
return $output;

Not all vas are needed, but its part of a bigger sub;
Important to understand are:

$link_db->select_options ("ORDER BY ID DESC LIMIT 5");

and


my $sth = $link_db->select ({ isNew => 'Yes', isValidated => 'Yes'});



Its the same like:

select from Links where isNew = 'Yes' and isValidate = 'Yes' Order by ID desc Limit 5

MEANS: Alle the field stuff to select; all the rest to select_options



Hope to have in the next minutes some specials like: only from this cat

then this must be done for every cat_page and we are through.

Robert





Quote Reply
Re: Adding links to homepage In reply to
I don't see where you used this in the code....

my $cat_db = $DB->table('Category');



Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: Adding links to homepage In reply to
Thatīs in fact the problem, where i stuck at the moment:

My Query should be:

SELECT Links.*
FROM CatLinks, Links
WHERE CatLinks.LinkID = Links.ID
AND (CatLinks.CategoryID IN (114))

/* 114 is the cat i want the links from as an example.

I dont know how i can say Links:

From CatLinks, Links


If i understand your code right, you want:
-----------------------------------
my ($sth, $root, $cat, $cat_list, $start_new, $total);

my $cat_db = $DB->table('Category'); # <-------------
my $link_db = $DB->table('Links');
$GRAND_TOTAL ||= _grand_total ($link_db);

my $output;
$link_db->select_options ("ORDER BY ID DESC LIMIT 5");
my $sth = $link_db->select ({ isNew => 'Yes', isValidated => 'Yes'});

while (my $link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('link_new', $link);
}
return $output;

But that only says 'FROM Links', not both?

---

With:


my $cat_db = $DB->table('Category');
my $sth = $cat_db->select ({ Name => 'Your_category' });


You can get the CategoryID for a Category name; not more.


I want to have: get all links where some fields = value;
and the Category ID in CatLinks = CategoryName in category ;

With this you need three parts.

Without the name, using only the catID you need two steps only.

The problem is, i dont know how to say it to links cause Alex uses not the normal queries as in 1.13.

....

Quote Reply
Re: Adding links to homepage In reply to
WIthout being able to figure out the problem here, and what's going on, the problems may be in the query and implicit joins.

To get the last 5 links, that were added to any category, on the category page, you'd want to do:

SELECT Links.*
FROM Links, CatLinks
WHERE Links.ID = CatLinks.LinkID
AND CatLinks.CategoryID = '33'
Order by Links.ID DESC Limit 5

If you are passing in the globals, you can make the '33' $input->{category_id} You can use it in the query:

SELECT Links.*,CatLinks.*
FROM Links, CatLinks
WHERE Links.ID = CatLinks.LinkID
AND CatLinks.CategoryID = $input->{category_id}
Order by Links.ID DESC Limit 5


You don't need to do dates, since the ID field is incremented, the newest links will always have a higher ID than the older ones.

If you are doing this in the "globals" just do a standard query, and put the results into a $return_value->{Tag_Name}

The <%Tag_Name%> would be a HASH .... whatever.

You can then use the <%loop%> variable to format the return values in the template itself, simplifying the overall code greatly.

I was asked to look in on this thread, but I'm not sure why.

I read the thread 3 times, and still don't get what the problem is, and why.


PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Forum:http://LinkSQL.com/forum
Quote Reply
Re: [afinlr] Adding links to homepage In reply to
Where does this code go? I tried adding it and got a compilation error.

Thanks
Alba
> >