Hi!
Back after a holiday break with the urge to get DBMan SQL doing even greater things. Can anyone help me with the following task? I have a global called <%get_data%> which retrieves what is in a field in a particular record of a table:
sub {
my ($table, $field, $value) = @_;
my $sth = $DB->table($table)->select({ $field => $value });
my @output;
while (my $rs = $sth->fetchrow_hashref ) {
push @output, $rs;
}
return { loop_hash => \@output };
}
The global is called this way:
<%get_data('Articles','RecordID',21)%>
<%loop loop_hash%>
<%Content%>
<%endloop%>
This works fine, returning the ENTIRE content of the field <%Content%> in the record numbered 21 of table Articles.
What I would like to do is display >> only the first few paragraphs (say first 2) << of the field <%Content%>.
Now I already have a separate global that does this:
<%display_paras x,y%> # x=initial para, y=last para to show
sub {
my ($low, $high) = @_;
my ($tags) = GT::Template->tags;
my (@paras) = split /\r?\n/, $tags->{Content};
my $numberparas = @paras;
scalar @paras > $high or return join ("", @paras[$low..$numberparas]);
return join ("", @paras[$low..$high]);
}
The challenge is adapt the <%get_data%> global to display first few paragraphs of <%Content%>.
Thanks in advance for any assistance!
Charly
Back after a holiday break with the urge to get DBMan SQL doing even greater things. Can anyone help me with the following task? I have a global called <%get_data%> which retrieves what is in a field in a particular record of a table:
sub {
my ($table, $field, $value) = @_;
my $sth = $DB->table($table)->select({ $field => $value });
my @output;
while (my $rs = $sth->fetchrow_hashref ) {
push @output, $rs;
}
return { loop_hash => \@output };
}
The global is called this way:
<%get_data('Articles','RecordID',21)%>
<%loop loop_hash%>
<%Content%>
<%endloop%>
This works fine, returning the ENTIRE content of the field <%Content%> in the record numbered 21 of table Articles.
What I would like to do is display >> only the first few paragraphs (say first 2) << of the field <%Content%>.
Now I already have a separate global that does this:
<%display_paras x,y%> # x=initial para, y=last para to show
sub {
my ($low, $high) = @_;
my ($tags) = GT::Template->tags;
my (@paras) = split /\r?\n/, $tags->{Content};
my $numberparas = @paras;
scalar @paras > $high or return join ("", @paras[$low..$numberparas]);
return join ("", @paras[$low..$high]);
}
The challenge is adapt the <%get_data%> global to display first few paragraphs of <%Content%>.
Thanks in advance for any assistance!
Charly