Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Detailed pag printing Links and Categories too?

(Page 1 of 2)
> >
Quote Reply
Detailed pag printing Links and Categories too?
I would like to be able to post category specific links on detailed pages. My preference would be to have a tag do this, rather than including a template that I have to edit every time someone adds a story to the database.

If you think of the "Links" as navigation, rather than the body of the materials, then it makes sense. Detailed page with a list of other links that you can click on.

In the past, Alex had suggested I use an include, but this means I'd have to go in and edit this every time an editor added a story to our database.

Is there some simple way to get the detailed page to recognize and print Links and/or Categories?

Last edited by:

Evoir: Dec 13, 2001, 10:23 AM
Quote Reply
Re: [Evoir] Detailed pag printing Links and Categories too? In reply to
I'm not exactly sure what you are asking.

But, would it be similar to a <%top_5%> type tag or global?




PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Detailed pag printing Links and Categories too? In reply to
well, I'm still in developement on this site, but here is a link. What I'd like is to continue showing the Links for the category, when you are on a detailed page. I'd like it to show the entire list of links.

You'll see that you lose the navigation when you click through to the detailed page. I'd like to keep the list of Links (for that subcatagory) on the right hand navigation.

Alex had suggested adding an text include, but that would mean every time an article was added, I'd have to go in and edit that file to include the new story. I'd like to make LSQL do the work for me Sly

Does this make sense?

Last edited by:

pugdog: Dec 14, 2001, 7:14 PM
Quote Reply
Re: [Evoir] Detailed pag printing Links and Categories too? In reply to
So you just want a list of all links in the current category that the link you are on is in? You could use a global like:

Code:
category_links => sub {
my $tags = shift;
my ($cat_id, $cat_name) = each %{$DB->table('Links')->get_categories($tags->{ID})};
my $link_db = $DB->table('Links','CatLinks');
$link_db->select_options ("ORDER BY $CFG->{build_sort_order_category}");
my $sth = $link_db->select ( { CategoryID => $cat_id });
my $output = '';
while (my $link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display('link', $link);
}
return $output;
}

Wasn't as straight forward as I thought, but looks like it should work.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Detailed pag printing Links and Categories too? In reply to
My god. I love you (ok, so I got excited here), and I love LSQL. this is so cool I can't stand it. I am soooo close. Blush Thanks a bunch. You know I'll add this to the resources section.

Last edited by:

Evoir: Dec 13, 2001, 12:57 PM
Quote Reply
Re: [Alex] Detailed pag printing Links and Categories too? In reply to
So one more, Alex, please.
I need a global that passes the first subcat of a cat; then all links in it; then the second subcat ...
means this:

cat cars:

subcat1: (not linked or linked)
link1
link2
link3

subcat2:
link1
link2
link3

...

Robert
Quote Reply
Re: [Robert] Detailed pag printing Links and Categories too? In reply to
Quote:
cat cars:

subcat1: (not linked or linked)
link1
link2
link3

subcat2:
link1
link2
link3
I'm curious.... Did you ever get a fix for this? It would solve one of my immediate problems!
Quote Reply
Re: [AtoZ] Detailed pag printing Links and Categories too? In reply to
 
Hello (Alex?),

I have made the following mod_sub for newest links with categroy-tree.

Is it possible to list the 5 newest links in the current category and in all the following subcategories? It would be nice to show the user not only the newest links in the current category, but also the newest links in the following subcategories. Is there a guy with a solution for integrating the subcategories?

sub {
my ($output,$sth,$link);

my $search_db = $DB->table ('Links');
$search_db->select_options ('ORDER BY Add_Date DESC Limit 5');
$sth = $search_db->select ( { isNew => 'Yes', isValidated => 'Yes' } );

while ($link = $sth->fetchrow_hashref)
{
my $id = $link->{ID};
my $db = $DB->table ('Category','CatLinks');
my $sth = $db->select ( { 'CatLinks.LinkID' => $id }, ['Category.ID', 'Category.Full_Name'] );
my $cat;

while (my ($id,$fullname) = $sth->fetchrow_array)
{
$fullname =~ s/ /_/g;

my @pfad = split(/\//, $fullname);

my $newpfad = "";
my $name;
my $value;
my $value_old;

$newpfad .= " <font face=\"Arial,Helvetica\" class=\"fpfad\" size=\"-1\">\n";

foreach $value (@pfad){

$name = $value;
$name =~ s/_/ /g;

$newpfad .= " <a href=\"$value_old/$value/\" class=\"pfad\">$name</a>&nbsp;&gt;&nbsp;\n";
$value_old = "$value_old/$value";
}

$newpfad = substr($newpfad, 0, -17);
$newpfad = $newpfad."</font><br>\n";

$output .= "$newpfad\n";
$output .= " <a href=\"$link->{URL}\"><b>$link->{Title}</b></a><br>\n";
$output .= " <img src=\"/img/blank.gif\" width=\"330\" height=\"10\" alt=\"\" border=\"0\"><br>\n\n";
}
}

$output = substr($output, 0, -85);
return $output;

#if (length $link->{Title} > 50) {
# $link->{Title} = substr($link->{Title}, 0, 50) . '...';
#}

}

Bye, Oliver
Quote Reply
Re: [AtoZ] Detailed pag printing Links and Categories too? In reply to
Here is one solution:

http://www.gossamer-threads.com/...i?post=193600#193600

But as I said at the time, I dont think it is very efficient. I'm using it on my site. Obviously you could change the output so that it gives the output as you specified like this:

sub {
my $tags = shift;
my $cat_id = $tags->{'ID'};
my $name = $tags->{'Name'};
my $link_db = $DB->table('Links','CatLinks');
$link_db->select_options ("ORDER BY $CFG->{build_sort_order_category}");
my $sth = $link_db->select ( { CategoryID => $cat_id, isValidated => 'Yes' });

my $output = qq~ <b>$name:</b><br> ~;

while (my $link = $sth->fetchrow_hashref) {
$output .= qq~ <li>$link->{'Title'} ~;
}

my $cat_db = $DB->table('Category');
my $sth2 = $cat_db->select ( ['ID','Name'],{ FatherID => $cat_id });

while (my ($child_id,$subname) = $sth2->fetchrow_array){
$output .= qq~ <br><br><b>$subname:</b><br> ~;

my $sth3 = $link_db->select ( { CategoryID => $child_id, isValidated => 'Yes' });

while (my $link2 = $sth3->fetchrow_hashref) {
$output .= qq~ <li>$link2->{'Title'} ~;
}
}

return $output;
}


What I actually want is all the links in a sortable list rather than by subcategory but I can't see how to do it. I also have lots of links in several categories which appear several times in my dropdown list which is a bit annoying. Anyway, hope it helps you,

Laura.
Quote Reply
Re: [flasi] Detailed pag printing Links and Categories too? In reply to
Hi Oliver,

This global will show all the new links in the category and sub categories. I hope this is something like what you were looking for.

sub {
my $tags = shift;
my @list;
my $cat_id = $tags->{'ID'};
my $name = $tags->{'Name'};
my $link_db = $DB->table('Links','CatLinks');
my $cat_db = $DB->table('Category');
my $sth2 = $cat_db->select ( ['ID'],{ FatherID => $cat_id });

$link_db->select_options ("ORDER BY Add_Date");
my $sth = $link_db->select ( { CategoryID => $cat_id, isValidated => 'Yes', isNew =>'Yes' });

my $output = qq~ <b>New Links in $name:</b><br> ~;

while (my $link = $sth->fetchrow_hashref) {
push @list, $link->{'Title'};
}

while (my ($child_id) = $sth2->fetchrow_array){
my $sth3 = $link_db->select ( { CategoryID => $child_id, isValidated => 'Yes', isNew => 'Yes' });
while (my $link2 = $sth3->fetchrow_hashref) {
push @list, $link2->{'Title'};
}
}

foreach my $link (@list) {
$output .= "<li>$link";
}

return $output;
}

Laura.
Quote Reply
Re: [afinlr] Detailed pag printing Links and Categories too? In reply to
 
Hi Laura,

thank you very much for you help!

I modifyed your script a bit, so the global is now able to show the last 5 new Links with the URL to the category or subcategory, the URL to to Detaild-Site and the Add_Date of the Link. All Links are sorty by Add_Date of the Links. The sort was a bit tricky, because of the array with the two SQL-Querys. But now it works fine!

Here are my modified "The newest 5 Links in these categroy and the following subcategories"-Sub ;-)

sub {
my $tags = shift;
my @list;
my $cat_id = $tags->{'ID'};

my $link_db = $DB->table('Links','CatLinks','Category');
my $sth = $link_db->select ( { CategoryID => $cat_id, isValidated => 'Yes', isNew =>'Yes' });
$link_db->select_options ("ORDER BY Add_Date");

my $cat_db = $DB->table('Category');
my $sth2 = $cat_db->select ( ['ID'],{ FatherID => $cat_id });

while (my $link = $sth->fetchrow_hashref) {
push @list, $link;
}

while (my ($child_id) = $sth2->fetchrow_array) {
my $sth3 = $link_db->select ( { CategoryID => $child_id, isValidated => 'Yes', isNew => 'Yes' });

while (my $link2 = $sth3->fetchrow_hashref) {
push @list, $link2;
}
}

# Sort
my %tmp_sort;
my @new_list;

for(my $i = 0; $i < $#list; $i++) {
my $key = ${$list[$i]}{'Add_Date'};
$key =~ s/-//g;
$key.= '0';

while($tmp_sort{$key}) {
$key += 1;
}
$tmp_sort{$key} = $list[$i];
}

my $new_cnt = 0;

foreach my $tmp_key (sort {$b <=> $a} (keys(%tmp_sort))) {

if ($new_cnt < 5) {
$new_list[$new_cnt] = $tmp_sort{$tmp_key};
$new_cnt++;
}
}

@list = @new_list;

my $output = qq~<b>The newest Links in this category and the following subcategories:</b>~;

foreach my $link (@new_list) {

# Set the category url
my $url = $cat_db->as_url($link->{'Full_Name'});

# Set the detailed_url
my $detailed_url = "$CFG->{build_detail_url}/$link->{'LinkID'}$CFG->{build_extension}";

$output .= qq~<li><a href="$CFG->{build_root_url}/$url/">$link->{'Name'}</a> | $link->{'Add_Date'}<br><a href="$detailed_url">$link->{'Title'}</a></li>~;
}

return $output;

}

Oliver
Quote Reply
Re: [flasi] Detailed pag printing Links and Categories too? In reply to
Hi Oliver,

Glad I could be of some help. Well done for getting the sort working - I did think about having a go but I'm afraid I was too lazy. Thanks for posting your solution.

Laura.
The UK High Street
Quote Reply
Re: [flasi] Detailed pag printing Links and Categories too? In reply to
flasi,



Please help me with two small things:

1) I would like the new link to display in link.html template (default) .

2) I tried it and it displays the last 5 links regardless of any category. Did I do something wrong?

What do I need to change?

Thank you.

Last edited by:

nt6: Jul 1, 2002, 5:16 AM
Quote Reply
Re: [Alex] Detailed pag printing Links and Categories too? In reply to
Hi Alex,



Could you please take a minute to tell me how to use this great global in a way where I can span the results? I placed the

<%category_links%> in <%if next_span%> tags, but got nothing. I hope this is just a minor tweak.



Cheers.
Quote Reply
Re: [flasi] Detailed pag printing Links and Categories too? In reply to
Hi Flasi,

Your global is nice - but it seems it skips the latest link (shows all the isNew except the very newest)?

Can't seem to find out why though?!?

Anyone?

Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] Detailed pag printing Links and Categories too? In reply to
 
Hi Klaus,

I modified the global, so now it shows the latest link also ;-) and ALL new links in ALL following subcategories.

How it works you can see on http://www.geizkragen.de/verbrauchernews.html in the Box "Die neuesten Einträge".

Here is the code of the new global:

sub {
my $tags = shift;
my $cat = $tags->{'Full_Name'};
my $output;
my $sth;
my $link;

use GT::SQL::Condition;

my $search_db = $DB->table('Links','CatLinks','Category');
$search_db->select_options ('GROUP BY LinkID ORDER BY Add_Date DESC Limit 5');
$sth = $search_db->select (['Links.ID', 'Links.Description', 'Links.Title', 'Links.Add_Date', 'Category.Full_Name', 'Category.Name'], GT::SQL::Condition->new(['Full_Name', 'LIKE', $cat .'%'], ['isNew', '=', 'Yes'], ['isValidated', '=', 'Yes']));

while ($link = $sth->fetchrow_hashref)
{
# Set the category url
my $category_url = $CFG->{build_root_url}."/".$link->{'Full_Name'}."/";

# Set the detailed_url
my $detailed_url = "$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}";

$output .= qq~<a href="$category_url">$link->{'Name'}</a> | $link->{'Add_Date'}<br><a href="$detailed_url">$link->{'Title'}</a><br>~;
}

return $output;
}

Merry Christmas and Happy New Year

Flasi
Quote Reply
Re: [flasi] Detailed pag printing Links and Categories too? In reply to
Thanks Flasi !

Figured it out - just had to include the fields I wanted to appear!

Merry Christmast and Happy New Year to you too :-)



Klaus

http://www.ameinfo.com

Last edited by:

klauslovgreen: Dec 20, 2002, 5:29 AM
Quote Reply
Re: [flasi] Detailed pag printing Links and Categories too? In reply to
Hi Flasi,

One more question - is there a way of using <%next%> - ie next page - so the first 5 in chronological order as it is now, but a link to more pages until you see them all?!?

Klaus

http://www.ameinfo.com
Quote Reply
Re: [flasi] Detailed pag printing Links and Categories too? In reply to
Hi Flasi,

I noticed your pretty nav bar on the side - any script for that?

What I need is however just the main category level - but the current category the user is in marked with a >> or some graphics.

Also I need to be able to control the placement of the categories (and include / exclude cats by ID)

Any ideas?

Klaus

http://www.ameinfo.com
Quote Reply
Re: [Alex] Detailed pag printing Links and Categories too? In reply to
I created the Alex's Global and named it "category_links" then inserted <%category_links%> into the detail.html page. But when I go to the detail page this is the results displayed



category_links => sub { my $tags = shift; my ($cat_id, $cat_name) = each %{$DB->table('Links')->get_categories($tags->{ID})}; my $link_db = $DB->table('Links','CatLinks'); $link_db->select_options ("ORDER BY $CFG->{build_sort_order_category}"); my $sth = $link_db->select ( { CategoryID => $cat_id }); my $output = ''; while (my $link = $sth->fetchrow_hashref) { $output .= Links::SiteHTML::display('link', $link); } return $output; }

No links are displayed! Just the global code. Do I need to do a build all first? These results are from the Dynamic detail pages.



Craven
Quote Reply
Re: [craven32] Detailed pag printing Links and Categories too? In reply to
I've been beating myself up over this one!!! Not sure why it won't work for me but does for everyone else. I did everything according to the directions:)

Craven
Quote Reply
Re: [craven32] Detailed pag printing Links and Categories too? In reply to
Edit your global so that it starts with
Code:
sub {
and not with
Code:
category_links => sub {

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Detailed pag printing Links and Categories too? In reply to
SOmetimes I feel like such an idiotBlush Thats exactly what the problem was. I just copied the global from here http://www.gossamer-threads.com/...s/Detailed/1989.html .

Thanks Yogi!

Craven
Quote Reply
Re: [Alex] Detailed pag printing Links and Categories too? In reply to
Hello Alex,

The Global one is very well !
But, I have a question.

It is possible to withdraw in the list, the link of the page where the Global one is called ?


sub {
my $tags = shift;
my ($cat_id, $cat_name) = each %{$DB->table('Links')->get_categories($tags->{ID})};
my $link_db = $DB->table('Links','CatLinks');
$link_db->select_options ("ORDER BY $CFG->{build_sort_order_category} LIMIT 5");
my $sth = $link_db->select ( { CategoryID => $cat_id });
my $output = '';
while (my $link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display('link', $link);
}
return $output;
}


An example of the detailed page:

--
Detailed link:
Link 1

List (Global):
Link 1 (I do not want that the link is again displayed)
Link 2
Link 3
Link 4
Link 5

--


Thank you for your assistance

Mick
Quote Reply
Re: [mick31] Detailed pag printing Links and Categories too? In reply to
How could I limit this to only displaying say 5 links on the detailed page

Quote:

category_links => sub {
my $tags = shift;
my ($cat_id, $cat_name) = each %{$DB->table('Links')->get_categories($tags->{ID})};
my $link_db = $DB->table('Links','CatLinks');
$link_db->select_options ("ORDER BY $CFG->{build_sort_order_category}");
my $sth = $link_db->select ( { CategoryID => $cat_id });
my $output = '';
while (my $link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display('link', $link);
}
return $output;
}
> >