Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Multi Cat Templates continued...

Quote Reply
Multi Cat Templates continued...
HI All, I'm starting a new thread for this topic, cause the other ones getting to big. To reference the first thread go to
http://www.gossamer-threads.com/scripts/forum/resources/Forum9/HTML/000466.html

I'd really love some feedback or help on this as I'm flying by the seat of my pants, but everything is coming together sloooowwwwlly.

So here's where I'm at.

I'm now able to modify my record and write the information to the database and when I select the record for modification, it shows me the data for the individual template fields. Here's the code for build_template_row

sub build_template_row {
# --------------------------------------------------------
# Returns a template row for the html form.
#

my ($name, $value, $rec) = @_;
my $select = &get_templates_list ($value, $name);
$name =~ s,-\d+$,,;

return "<tr><td align=right valign=top width=20%><font face='verdana,arial' size=2>$name</font></td><td width=80%><select name='$name'>$select</select></td></tr>\n";
}

and here's the code for get_templates_list. Note this is slightly different than get_template_list.

sub get_templates_list {
# --------------------------------------------------------
# Returns a list of all the templates (select list).
#

my ($value, $name) = @_;
my (@tpls, $tpl, $output);
opendir (TPL, "$LINKS{admin_root_path}/templates") or die "Invalid template directory: $LINKS{admin_root_path}/templates. Reason: $!";
@tpls = grep {!/^\./} readdir TPL;
closedir (TPL);
$output = '<option value="">----';
foreach $tpl (sort @tpls) {

($tpl eq $value) ? ($output .= qq~<option value="$tpl" SELECTED>$tpl~) :
($output .= qq~<option value="$tpl">$tpl~);
}
$output .= '';
return $output;
}

This is what I need:
Can anyone tell me how to incorporate the modify multiple records into this? I'm not sure what variables need to be defined. I'm assuming, I would use the same code as found in dbsql.pm
# Set the name if we are doing a multiple forms.
$opt->{'multiple'} ? ($name = "$field-${$rec}{$key}") : ($name = $field);

but I'm not sure where and how to add that line without crashing the program.

Looking forward to hearing from someone.

Kyle
Quote Reply
Re: Multi Cat Templates continued... In reply to
Okay, I'm able to print to my selected Link_Template and my selected Detailed_Template but not the category Template. There's something different about this.

This is the code that sends the information for category printing in nph_build.cgi: Code is from sub build_category_pages

print CAT &site_html_category (\%OUT);

and here is the code that determines the templates to actually use in
sub site_html_category


(-e "$TEMPLATES/$template" && $template) or ($template = "category.html");

The problem here is the $template is always evaluating to category.html. Something seems to be missing.

In the Link_Template and Detail_Template codes, I changed the name of the file (i.e. link.html and detailed.html to $template and that did the trick, but that doesn't work here.

Help?!?!?!

Kyle


Quote Reply
Re: Multi Cat Templates continued... In reply to
YESSSSS! Finally, I got all templates to work properly.

Alex or Widgetz, please look at the first posting in this thread. I'm finding this one extremely difficult to solve.

Also, if you agree with the coding I've done, I'd be willing to post a final version that's easier to understand.

So, Here's what I finally did for the category Template.

In nph_build.cgi
sub build_category_pages

In two spots
replaced
print CAT &site_html_category (\%OUT);

with

print CAT &site_html_category (\%OUT, $category_r->{'Template'});


Then in HTML_Templates.pm
sub site_html_category

replaced
(-e "$TEMPLATES/$template" && $template) or ($template = "category.html");

with

(-e "$TEMPLATES/$template" && $template) or ($template = "$template");

That took care of it,


HOWEVER, I still have no idea how to get the the Admin_HTML.pm to let me modify multi records at once for defining templates.


This is the final hurdle (refer to the very first post in this thread) and it involves something that I bet Alex or Widgetz can solve blind folded.

I look forward to hearing from you.

Kyle
Quote Reply
Re: Multi Cat Templates continued... In reply to
ugh.. klangan.. ok.. first of all.. your second mod makes no sense.. it pretty much says in plain english.. if this template does not exist use it.. which is totally wrong..

also..

mod mult should work with the original mod..

the one instruction i did not say was the one to Admin_HTML.pm

instead i gave instructions to add a tag to every occurance of something.. there are so many occurances that i did not want to go through it..

jerry
Quote Reply
Re: Multi Cat Templates continued... In reply to
YESSSSS! Finally, I got all templates to work properly.

Alex or Widgetz, please look at the first posting in this thread. I'm finding this one extremely difficult to solve.

Also, if you agree with the coding I've done, I'd be willing to post a final version that's easier to understand.

So, Here's what I finally did for the category Template.

In nph_build.cgi
sub build_category_pages

In two spots
replaced
print CAT &site_html_category (\%OUT);

with

print CAT &site_html_category (\%OUT, $category_r->{'Template'});


Then in HTML_Templates.pm
sub site_html_category

replaced
(-e "$TEMPLATES/$template" && $template) or ($template = "category.html");

with

(-e "$TEMPLATES/$template" && $template) or ($template = "$template");

That took care of it,


HOWEVER, I still have no idea how to get the the Admin_HTML.pm to let me modify multi records at once for defining templates.


This is the final hurdle (refer to the very first post in this thread) and it involves something that I bet Alex or Widgetz can solve blind folded.

I look forward to hearing from you.

Kyle
Quote Reply
Re: Multi Cat Templates continued... In reply to
once again..

Code:
(-e "$TEMPLATES/$template" && $template) or ($template = "$template");

just allows it to use an invalid template..

jerry
Quote Reply
Re: Multi Cat Templates continued... In reply to
Jerry,

Thanks for you're reply.

You're completely correct.
adding the following code to the top of HTML_templates.pm took care of all the problems I was having.

my $TEMPLATES = "$LINKS{admin_root_path}/templates";

So I've used all the code you've outlined in

http://www.gossamer-threads.com/scripts/forum/resources/Forum9/HTML/000466.html

Thanks again for all your help. This is truly a powerful modification that I hope finds it's way into the next version.

Kyle