Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Title & URL for Prev & Next Link (in Detailed.html)

Quote Reply
Title & URL for Prev & Next Link (in Detailed.html)
I am using Laura's Global as below:

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->{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};
}

Global Source: https://www.gossamer-threads.com/forum/Products_C9/Gossamer_Links_C5/Development%2C_Plugins_and_Globals_F20/Re%3A_%5Bafinlr%5D_Next_Prev_-_Title_P270913/?search_string=prev%20title#p270913



& the code to output the info/value as below:

<%get_next%>

<%if next_url%> next_url = <%next_url%><br> <%endif%>
<%if prev_url%>prev_url = <%prev_url%><br> <%endif%>


It seems to work just fine, however the problem is with the URL for Prev & Next Link.

Is there any way to display Static URL for Prev & Next Links on Detailed page, instead of the dynamic URL that is being shown using the above global.

Thank you.

Vishal
-------------------------------------------------------
Quote Reply
Re: [VishalT] Title & URL for Prev & Next Link (in Detailed.html) In reply to
It seems that even when not using the global, I have following variables available:

next
next_url

prev
prev_url

But Title is still not available for these links :(

Vishal
-------------------------------------------------------
Quote Reply
Re: [VishalT] Title & URL for Prev & Next Link (in Detailed.html) In reply to
Hi,

Yup - <%next%> , <%next_url%> etc are available as standard. You could try:

Code:
sub {
my $args=shift;
my $db = $DB->table ('Links','CatLinks');
my $cat_id = $db->select ( ['CategoryID'], { LinkID => $args->{ID} } )->fetchrow;

# Figure out the next/prev links.
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('Links.ID' => { CategoryID => $cat_id }, VIEWABLE);
my ($next, $prev, $next_title, $prev_title);
while (my ($id,$title) = $sth->fetchrow) {
if ($id == $link->{ID}) {
($next,$next_title) = $sth->fetchrow;
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};

}

Personally, though, I would just hard-code the tweaks into /admin/Links/Build.pm, finding sub build_detailed , and change:

Code:
# Figure out the next/prev links.
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('Links.ID' => { CategoryID => $cat_id }, VIEWABLE);
my ($next, $prev);
while (my $id = $sth->fetchrow) {
if ($id == $link->{ID}) {
$next = $sth->fetchrow;
last;
}
else {
$prev = $id;
}
}

to:

Code:
# Figure out the next/prev links.
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('Links.ID' => { CategoryID => $cat_id }, VIEWABLE);
my ($next, $prev, $next_title, $prev_title);
while (my ($id,$title) = $sth->fetchrow) {
if ($id == $link->{ID}) {
($next,$next_title) = $sth->fetchrow;
last;
}
else {
$prev = $id;
$prev_title = $title;

}
}


Untested, but should work

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Title & URL for Prev & Next Link (in Detailed.html) In reply to
Hi ,

I tried the global, however it does not seem to work or at least does not give any variable that would allow me to display Title & detailed page static link for previous & next links.

Vishal
-------------------------------------------------------
Quote Reply
Re: [VishalT] Title & URL for Prev & Next Link (in Detailed.html) In reply to
In footer for Detailed html page I added following below code for testing. I am getting proper output for:

<%prev%> (I get the previous listing ID as output
<%prev_url%> (I am getting static Detailed URL as output)
<%prev_title%> ... nothing :(

& same for <%next%> <%next_url%> & <%next_title%>

Vishal
-------------------------------------------------------
Quote Reply
Re: [VishalT] Title & URL for Prev & Next Link (in Detailed.html) In reply to
This seems to work for me:

Code:
sub {
my $this_link_id = $_[0];

my $db = $DB->table ('Links','CatLinks');
my $cat_id = $db->select ( ['CategoryID'], { LinkID => $this_link_id } )->fetchrow;

# Figure out the next/prev links.
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( ['Links.ID','Links.Title'] => { CategoryID => $cat_id }, VIEWABLE);
my ($next, $prev, $next_title, $prev_title);
while (my ($id,$title) = $sth->fetchrow) {
if ($id == $this_link_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 };

}

You have to call it a little differently:

Code:
<%global_name($ID)%>

Then it will give you <%next_url%> and <%prev_url%>

I've tested it on my test install and it works perfectly:

Code:
NEXT: <a href="http://gossamer.ultranerds.co.uk/cgi-bin/page.cgi?g=Detailed/266.html&d=1">SimpleDesign</a>
PREV: <a href="http://gossamer.ultranerds.co.uk/cgi-bin/page.cgi?g=Detailed/268.html&d=1">NaturalDesign</a>

Cheers

Andy

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Title & URL for Prev & Next Link (in Detailed.html) In reply to
But the URL is not static :(

NEXT: <a href="http://gossamer.ultranerds.co.uk/cgi-bin/page.cgi?g=Detailed/266.html&d=1">SimpleDesign</a>
PREV: <a href="http://gossamer.ultranerds.co.uk/cgi-bin/page.cgi?g=Detailed/268.html&d=1">NaturalDesign</a>

I will be doing static build for the site & it would be important to have prev/next url as static.

btw.. in default prev_url and next_url it does generate static url link, but not the Tittle.

Vishal
-------------------------------------------------------
Quote Reply
Re: [VishalT] Title & URL for Prev & Next Link (in Detailed.html) In reply to
Hi,

Easy enough to change to static :)

Code:
my ($next_url, $prev_url);
if ($next) {
my $next_link = $CFG->{build_detail_url} . "/" . $DB->table('Links')->detailed_url( $next );
$next_url = qq~<a href="$next_link">$next_title</a>~;
}
if ($prev) {
my $prev_link = $CFG->{build_detail_url} . "/" . $DB->table('Links')->detailed_url( $prev );
$prev_url = qq~<a href="$prev_url">$prev_title</a>~;
}

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Title & URL for Prev & Next Link (in Detailed.html) In reply to
This edit seems to work perfectly for <%next_url%>, however there is some problem with <%prev_url%> :(, it Shows the title, however without the URL / link :(

Here is the output for <%prev_url%>
<a href="">My Test Listing </a>

--------------------------------------------------------
Global that I am using:
Code:
sub {
my $this_link_id = $_[0];

my $db = $DB->table ('Links','CatLinks');
my $cat_id = $db->select ( ['CategoryID'], { LinkID => $this_link_id } )->fetchrow;

# Figure out the next/prev links.
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( ['Links.ID','Links.Title'] => { CategoryID => $cat_id }, VIEWABLE);
my ($next, $prev, $next_title, $prev_title);
while (my ($id,$title) = $sth->fetchrow) {
if ($id == $this_link_id) {
($next,$next_title) = $sth->fetchrow_array;
last;
}
else {
$prev = $id;
$prev_title = $title;

}
}

my ($next_url, $prev_url);
if ($next) {
my $next_link = $CFG->{build_detail_url} . "/" . $DB->table('Links')->detailed_url( $next );
$next_url = qq~<a href="$next_link">$next_title</a>~;
}
if ($prev) {
my $prev_link = $CFG->{build_detail_url} . "/" . $DB->table('Links')->detailed_url( $prev );
$prev_url = qq~<a href="$prev_url">$prev_title</a>~;
}

return { next_url => $next_url, prev_url => $prev_url };

}


I am calling global using (Global name = prev_next1):

Code:
<%prev_next1($ID)%>

1.prev_url : <%if prev_url%> <%prev_url%> <%endif%>
<br><br>
2 next_url: <%if next_url%><%next_url%> <%endif%>

<br><br>

Vishal
-------------------------------------------------------
Quote Reply
Re: [VishalT] Title & URL for Prev & Next Link (in Detailed.html) In reply to
Sorry, it should be:

Code:
my ($next_url, $prev_url);
if ($next) {
my $next_link = $CFG->{build_detail_url} . "/" . $DB->table('Links')->detailed_url( $next );
$next_url = qq~<a href="$next_link">$next_title</a>~;
}
if ($prev) {
my $prev_link = $CFG->{build_detail_url} . "/" . $DB->table('Links')->detailed_url( $prev );
$prev_url = qq~<a href="$prev_link">$prev_title</a>~;
}

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Title & URL for Prev & Next Link (in Detailed.html) In reply to
It works :)

Awesome.. :) :) :)

Thank you ...

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