This is really a basic question about PageBuilder and printing category lists ...
I want to create a new OPML-file, which is an XML-file looking like this:
<outline text="Services">
<outline text="Google API">
<outline text="Implementations">
</outline>
<outline text="Applications">
</outline>
</outline>
<outline text="xmlStorageSystem">
<outline text="Implementations">
</outline>
</outline>
</outline>
...
Here, "Services" would be a toplevel category, with "Google API" and "xmlStorageSystem" would be sub-categories (and "Implementations" the name of two sub-sub-categories, etc.).
But with some somewhat complex nesting within tags...
Can anyone help me here?
I can make the "flat" lists, like these...
Get and print main categories:
my $tags = shift;
my $cat_db = $DB->table('Category');
my @root_cats = $cat_db->select (['Full_Name'], { FatherID => 0 })->fetchall_list;
my $output;
foreach my $root_cat (@root_cats) {
my $url = $cat_db->as_url($root_cat);
my $id = $cat_db->as_id($root_cat);
$output .= qq~<outline text="$root_cat" type="link" url="$CFG->{build_root_url}/$url" />\n~;
}
return $output;
}
Get and print all categories:
my $tags = shift;
my $cat_db = $DB->table('Category');
$cat_db->select_options("ORDER BY Full_Name");
my @root_cats = $cat_db->select (['Full_Name'])->fetchall_list;
my $output;
foreach my $root_cat (@root_cats) {
my $url = $cat_db->as_url($root_cat);
$output .= qq~<outline text="$root_cat" type="link" url="$CFG->{build_root_url}/$url" />\n~;
}
return $output;
}
But how to make the nested lists??
I want to create a new OPML-file, which is an XML-file looking like this:
Code:
... <outline text="Services">
<outline text="Google API">
<outline text="Implementations">
</outline>
<outline text="Applications">
</outline>
</outline>
<outline text="xmlStorageSystem">
<outline text="Implementations">
</outline>
</outline>
</outline>
...
Here, "Services" would be a toplevel category, with "Google API" and "xmlStorageSystem" would be sub-categories (and "Implementations" the name of two sub-sub-categories, etc.).
But with some somewhat complex nesting within tags...
Can anyone help me here?
I can make the "flat" lists, like these...
Get and print main categories:
Code:
sub { my $tags = shift;
my $cat_db = $DB->table('Category');
my @root_cats = $cat_db->select (['Full_Name'], { FatherID => 0 })->fetchall_list;
my $output;
foreach my $root_cat (@root_cats) {
my $url = $cat_db->as_url($root_cat);
my $id = $cat_db->as_id($root_cat);
$output .= qq~<outline text="$root_cat" type="link" url="$CFG->{build_root_url}/$url" />\n~;
}
return $output;
}
Get and print all categories:
Code:
sub { my $tags = shift;
my $cat_db = $DB->table('Category');
$cat_db->select_options("ORDER BY Full_Name");
my @root_cats = $cat_db->select (['Full_Name'])->fetchall_list;
my $output;
foreach my $root_cat (@root_cats) {
my $url = $cat_db->as_url($root_cat);
$output .= qq~<outline text="$root_cat" type="link" url="$CFG->{build_root_url}/$url" />\n~;
}
return $output;
}
But how to make the nested lists??