Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Category path in categoey.html

Quote Reply
Category path in categoey.html
How I can use this code to work in categoey.html

sub {
my $tag = shift;
my ($table, $sth, $catID, $cattable, $sth2, $name, @dirs, $output, $i);
$table = $DB->table ('CatLinks');
$sth = $table->select ( { LinkID => $tag->{ID} }, ['CategoryID'] );
$catID = $sth->fetchrow();
$cattable = $DB->table('Category');
$sth2 = $cattable->select ( { ID => $catID }, ['Full_Name'] );
$name = $sth2->fetchrow_array;
@dirs = split (/\//, $name);
$i = 0;
for (0 .. $#dirs) {
if ( $i == '0') {my $path = "/" . $cattable->as_url( join "/", @dirs[0 .. $_] ); $output .= " <a href=\"=\"http://www.mysite/\">$dirs[$_]</a> &nbsp;"; $output .= " > "; $i++; next; } #
my $path = "/" . $cattable->as_url( join "/", @dirs[0 .. $_] );
$output .= " <a href=\"http://www.mysite/$path/$CFG->{'build_index'}\">$dirs[$_]</a> &nbsp;";
$output .= " > " if $i < $#dirs;
$i++;
}
return $output;
}
Quote Reply
Re: [nir] Category path in categoey.html In reply to
What exactly does that do? Sounds more like you don't need a global - just use title_loop.

For example:

Code:
<%loop title_loop%>
<a href="<%URL%>"><%Name%></a> <%if not last%> &gt; <%endif%>
<%endloop%>

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Category path in categoey.html In reply to
Is there a way to change the <%URL%>, I try to make something like this www.mysite.com/<%ID%>/ but its display the same ID for all the loop, it’s the ID of the current category.
Quote Reply
Re: [nir] Category path in categoey.html In reply to
Hi,

The only options you have, are <%Name%> and <%URL%>

Do : <%DUMP title_loop%>, and you will see what I mean.

Why do you just wanna do <%ID%> for the category URL? If you are doing it for the whole site, just change Setup > Build Options > build_category_format to "Category ID", and that will make all categories get built as <%build_root_url%>/<%ID%>/

Hope that helps

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Category path in categoey.html In reply to
I do it just for part of the site because of this I use the global I attach, but the global work for details page and I need it to work on category page, do you know who I can use the global in category page.
Quote Reply
Re: [nir] Category path in categoey.html In reply to
You need a new global.

Code:
sub {
my ($table, $sth, $catID, $cattable, $sth2, $name, @dirs, $output, $i);

$cattable = $DB->table('Category');
$name = $cattable->select ( ['Full_Name'], { ID => $_[0] } )->fetchrow;
@dirs = split (/\//, $name);
$i = 0;
for (0 .. $#dirs) {

if ( $i == '0') {
my $path = "/" . $cattable->as_url( join "/", @dirs[0 .. $_] );
$output .= " <a href=\"=\"http://www.mysite/\">$dirs[$_]</a> &nbsp;"; $output .= " > ";
$i++;
next;
}
my $path = "/" . $cattable->as_url( join "/", @dirs[0 .. $_] );
$output .= " <a href=\"http://www.mysite/$path/$CFG->{'build_index'}\">$dirs[$_]</a> &nbsp;";
$output .= " > " if $i < $#dirs;
$i++;

}
return $output;
}

Call with:

<%global_name($ID)%>

Untested, but should work.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Category path in categoey.html In reply to
Its work, ThanksSmile