Gossamer Forum
Quote Reply
Next Prev - Title
How about a global to link the next / previous url on the detailed pages (like the next_url tag) BUT grab the title from the next page! Having the link text containing the title will do wonders for better listing on google!

--------------------------------
Privacy Software
Quote Reply
Re: [BLOOD] Next Prev - Title In reply to
Something like this:

sub {
my $args=shift;
my $db = $DB->table ('Category','CatLinks');
my ($cat_id,$full_name) = $db->select ( { 'CatLinks.LinkID' => $args->{ID} }, ['Category.ID', 'Category.Name'] )->fetchrow_array;
my $catlnk_db = $DB->table ('Links', 'CatLinks');
$catlnk_db->select_options ("ORDER BY $CFG->{build_sort_order_category}") if ($CFG->{build_sort_order_category});
my $sth = $catlnk_db->select ( { CategoryID => $cat_id, isValidated => 'Yes' }, [ 'Links.ID' ,'Links.Title'] );
my ($next, $prev);

while (my ($id,$title) = $sth->fetchrow_array) {
if ($id == $args->{ID}) {
($next,$next_title) = $sth->fetchrow_array;
last;
}
else {
$prev = $id;
$prev_title=$title;
}
}

my ($next_url, $prev_url);
if ($next) {
$next_url = qq~<a href="$CFG->{db_cgi_url}/detail.cgi?ID=$next">$next_title</a>~;
}
if ($prev) {
$prev_url = qq~<a href="$CFG->{db_cgi_url}/detail.cgi?ID=$prev">$prev_title</a>~;
}
return {next_url => $next_url, prev_url => $prev_url};
}
Quote Reply
Re: [afinlr] Next Prev - Title In reply to
Then what? How do you use it in the template?
Quote Reply
Re: [dwh] Next Prev - Title In reply to
You would name the global something like get_next and then in the template you would have
<%get_next%>
<%next_url%>
<%prev_url%>
where you want them.
Quote Reply
Re: [afinlr] Next Prev - Title In reply to
Thanks for trying, but it didn't work... Any more ideas?
Quote Reply
Re: [dwh] Next Prev - Title In reply to
Sorry - this was edited slightly to include the title. You need to declare the title variables too:
change
my ($next,$prev)
to
my ($next,$prev,$next_title,$prev_title)

Last edited by:

afinlr: Aug 14, 2004, 4:23 AM
Quote Reply
Re: [afinlr] Next Prev - Title In reply to
Thanks, I tried it but got this error:

Unable to compile 'get_next': Global symbol "$next_title" requires explicit package name at (eval 29) line 12. Global symbol "$prev_title" requires explicit package name at (eval 29) line 17. Global symbol "$next_url" requires explicit package name at (eval 29) line 23. Global symbol "$prev_url" requires explicit package name at (eval 29) line 26. Global symbol "$next_url" requires explicit package name at (eval 29) line 28. Global symbol "$prev_url" requires explicit package name at (eval 29) line 28.
Quote Reply
Re: [dwh] Next Prev - Title In reply to
I think I copied it to the wrong place.

Now my error is different. Could the Braces be in the wrong place?

I noticed that the "}" ends the subroutine here:

}

my ($next_url, $prev_url);

So it looks like two subroutine in one global. Is that correct?
Quote Reply
Re: [dwh] Next Prev - Title In reply to
Now I had some typos and errors but I'm almost there. I'll post the correct code once it's working. Thanks again for all your help!
Quote Reply
Re: [dwh] Next Prev - Title In reply to
The only change you should need is the one in my post above. I've just copied it into my site to check and it works fine.
Quote Reply
Re: [dwh] Next Prev - Title In reply to
Hi again,

Just trying to think of any other reasons for problems you're encountering - if you have a prefix on your Links table you may need to change Links.ID and Links.Title to prefix_Links.ID and prefix_Links.Title - where 'prefix' is your prefix.
Quote Reply
Re: [afinlr] Next Prev - Title In reply to
In Reply To:
The only change you should need is the one in my post above. I've just copied it into my site to check and it works fine.

I was testing it on the dynamic page and it wasn't working. So I used this code and it worked for dynamic:

sub {
my $args=shift;
my $db = $DB->table ('Category','CatLinks');
my ($cat_id,$full_name) = $db->select ( { 'CatLinks.LinkID' => $args->{ID} }, ['Category.ID', 'Category.Name'] )->fetchrow_array;
my $catlnk_db = $DB->table ('Links', 'CatLinks');
$catlnk_db->select_options ("ORDER BY $CFG->{build_sort_order_category}") if ($CFG->{build_sort_order_category});
my $sth = $catlnk_db->select ( { CategoryID => $cat_id, isValidated => 'Yes' }, [ 'Links.ID' ,'Links.Title'] );
my ($next,$prev,$next_title,$prev_title) ;
while (my ($id,$title) = $sth->fetchrow_array) {
if ($id == $args->{ID}) {
($next,$next_title) = $sth->fetchrow_array;
last;
} else {
$prev = $id;
$prev_title=$title;
}
}
my ($next_url, $prev_url);
if ($next) {
$next_url = qq~<a href="$CFG->{db_cgi_url}/page.cgi?g=Detailed/$next.html&d=1">$next_title</a>~;
}
if ($prev) {
$prev_url = qq~<a href="$CFG->{db_cgi_url}/page.cgi?g=Detailed/$prev.html&d=1">$prev_title</a>~;
}
return {next_url => $next_url, prev_url => $prev_url};
}

But now the static page isn't showing a link to the next / prev static link.

I don't really know how that static/dynamic stuff really works...
Quote Reply
Re: [dwh] Next Prev - Title In reply to
Sorry - always forget that people use different detail pages.

Try this:

$next_url = qq~<a href="$CFG->{build_detail_url}/$next$CFG->{build_extension}">$next_title</a>~;

and
$prev_url = qq~<a href="$CFG->{build_detail_url}/$prev$CFG->{build_extension}">$prev_title</a>~;

This should work for both static and dynamic pages.
Quote Reply
Re: [dwh] Next Prev - Title In reply to
OK this code worked for me:

Code:
sub {
my $args=shift;
my $db = $DB->table ('Category','CatLinks');
my ($cat_id,$full_name) = $db->select ( { 'CatLinks.LinkID' => $args->{ID} }, ['Category.ID', 'Category.Name'] )->fetchrow_array;
my $catlnk_db = $DB->table ('Links', 'CatLinks');
$catlnk_db->select_options ("ORDER BY $CFG->{build_sort_order_category}") if ($CFG->{build_sort_order_category});
my $sth = $catlnk_db->select ( { CategoryID => $cat_id, isValidated => 'Yes' }, [ 'Links.ID' ,'Links.Title'] );
my ($next,$prev,$next_title,$prev_title) ; while (my ($id,$title) = $sth->fetchrow_array) {
if ($id == $args->{ID}) {
($next,$next_title) = $sth->fetchrow_array;
last;
} else {
$prev = $id;
$prev_title=$title;
}
} my ($next_url, $prev_url);
if ($next) {
$next_url = qq~<a href="$CFG->{build_root_url}/Detailed/$next.html">$next_title</a>~;
}
if ($prev) {
$prev_url = qq~<a href="$CFG->{build_root_url}/Detailed/$prev.html">$prev_title</a>~;
}
return {next_url => $next_url, prev_url => $prev_url};
}
Quote Reply
Re: [afinlr] Next Prev - Title In reply to
This one is working like a charm on detailed page, however when I try using it on search result page, it does not seem to work. Any tips on how to get it working?

Thanks.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Next Prev - Title In reply to
How are you trying to use it on the search results page? A next, prev link for each link on the page?
The UK High Street
Quote Reply
Re: [afinlr] Next Prev - Title In reply to
On search results page I am having 2 pagination. 1 near the footer, that displays First Previous 1 2 3 4 5 Next Last. While at the top I am trying to setup something like View Previous 10 - Next 10.... I something like what is available on category.html & detailed page using <%prev%> & <%next%> tags. I tried to search for other globals, but no success.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Next Prev - Title In reply to
I'm still not quite sure I understand. Can you explain the difference between the results you will get if you click on 'previous' in the first one and 'previous 10' in the second one? Will they show the same results and it is just a difference in wording or are you actually aiming for different results?
Quote Reply
Re: [afinlr] Next Prev - Title In reply to
Okay let me try to re-phrase.

on category.html you can use <%prev%>, <%next%> tag along with other related tags like <%if prev%>, <%if next%>.. etc allowing admin to setup fully customized navigation section.


------------------------------------------------
This is how I have on category.html

Prev / Next Option on top:
Code:
Showing: <b>1 to 10 of 254 Listings</b>

View: <%if prev%><a href="<%prev%>">Previous 10</a><%endif%>

<%if next and prev%> - <%endif%>

<%if next%><a href="<%next%>">Next 10</a><%endif%>

Near the Footer:
Code:
<div class='paginghold'><div class="paging"><%Links::Utils::paging(button_id => 'paging_button3')%></div></div>
------------------------------------------------

Now on the search_results.html

Near the footer I am using: (code as Category.html)
Code:
<div class='paginghold'><div class="paging"><%Links::Utils::paging(button_id => 'paging_button3')%></div></div>

However near the top I am trying to setup a structure, so that user can click on Previous Page - Next Page
So suppose search result has 9 pages.

On first page it will only show b]Next Page[/b] as there is no previous page. From 2nd to 8th page, it will show both Previous - Next link and for the last page, it will show only Previous Link.

On category.html this can be done easily by using if/elseif tags, however for some reason this option is not available on search_results.html

Vishal
-------------------------------------------------------