You are missing lots of "or"'s from that tag.
May 8, 2003, 2:14 PM
Veteran (2312 posts)
May 8, 2003, 2:14 PM
Post #28 of 45
Views: 7389
Hmm.
Checked Category.pm. It seems children() method returns arrayref, not array.
Try this:
my $catid_current = shift;
my $catid_check = shift;
return 0 unless $catid_current =~ /^\d$/;
return 0 unless $catid_check =~ /^\d$/;
return 1 if $catid_check eq $catid_current;
my $children = $DB->table('Category')->children($catid_check);
foreach (@{$children}) {
return 1 if $_ eq $catid_current;
}
}
<%if is_child_category($ID, 231)%><%include include_form_ebooks.html%><%endif%>
Hopefully all bugs corrected now.
Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Checked Category.pm. It seems children() method returns arrayref, not array.
Try this:
Code:
sub { my $catid_current = shift;
my $catid_check = shift;
return 0 unless $catid_current =~ /^\d$/;
return 0 unless $catid_check =~ /^\d$/;
return 1 if $catid_check eq $catid_current;
my $children = $DB->table('Category')->children($catid_check);
foreach (@{$children}) {
return 1 if $_ eq $catid_current;
}
}
<%if is_child_category($ID, 231)%><%include include_form_ebooks.html%><%endif%>
Hopefully all bugs corrected now.
Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
May 8, 2003, 2:28 PM
Veteran (2312 posts)
May 8, 2003, 2:28 PM
Post #30 of 45
Views: 7366
Yeah, thanks
Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...

Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
May 9, 2003, 6:08 AM
Veteran (2312 posts)
May 9, 2003, 6:08 AM
Post #33 of 45
Views: 7437
Yes, you are right
. Multiple numbers should be allowed.
It seems I was more inattentive than usual, so I went to LSQL to test & make working that global.
Here is the tested working is_child_category global:
my ($catid_current, $catid_check) = @_;
return 0 unless $catid_current =~ /^\d+$/;
return 0 unless $catid_check =~ /^\d+$/;
return 1 if $catid_check eq $catid_current;
my $children = $DB->table('Category')->children($catid_check);
foreach (@{$children}) { return 1 if $_ eq $catid_current }
}
You may wish to have implemented the optimization suggested by Paul, so here it is:
my ($catid_current, $catid_check) = @_;
return 0 unless $catid_current =~ /^\d+$/;
return 0 unless $catid_check =~ /^\d+$/;
return 1 if $catid_check eq $catid_current;
my $children = $DB->table('Category')->children($catid_check);
return 1 if grep $_ eq $catid_current, @$children;
}
Then use tags in add.html, or include_form.html this way:
<%set is_child_category_231 = is_child_category($ID, 231)%><%if is_child_category_231%><%include include_form_231.html%><%endif%>
<%set is_child_category_500 = is_child_category($ID, 500)%><%if is_child_category_500%><%include include_form_500.html%><%endif%>
Thanks Laura for pointing out that bug, Yogi for his comments, and Paul for his optimization suggestion.
Lars, finally you can enjoy this global.
Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...

It seems I was more inattentive than usual, so I went to LSQL to test & make working that global.
Here is the tested working is_child_category global:
Code:
sub { my ($catid_current, $catid_check) = @_;
return 0 unless $catid_current =~ /^\d+$/;
return 0 unless $catid_check =~ /^\d+$/;
return 1 if $catid_check eq $catid_current;
my $children = $DB->table('Category')->children($catid_check);
foreach (@{$children}) { return 1 if $_ eq $catid_current }
}
You may wish to have implemented the optimization suggested by Paul, so here it is:
Code:
sub { my ($catid_current, $catid_check) = @_;
return 0 unless $catid_current =~ /^\d+$/;
return 0 unless $catid_check =~ /^\d+$/;
return 1 if $catid_check eq $catid_current;
my $children = $DB->table('Category')->children($catid_check);
return 1 if grep $_ eq $catid_current, @$children;
}
Then use tags in add.html, or include_form.html this way:
<%set is_child_category_231 = is_child_category($ID, 231)%><%if is_child_category_231%><%include include_form_231.html%><%endif%>
<%set is_child_category_500 = is_child_category($ID, 500)%><%if is_child_category_500%><%include include_form_500.html%><%endif%>
Thanks Laura for pointing out that bug, Yogi for his comments, and Paul for his optimization suggestion.
Lars, finally you can enjoy this global.
Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
May 10, 2003, 7:16 AM
User (245 posts)
May 10, 2003, 7:16 AM
Post #34 of 45
Views: 7366
Hi,
I said i tried Jack method and it is working. But the problem is if user left any 'Not Null - Yes' link fields the form is going back to 'add.cgi' not 'add.cgi?ID'
For example Title is set to Not null- Yes. If user enter the form at mydomain/add.cgi?231 and forgot to fill title. He will be pointing to the error and now he will be on add.cgi (default form) So even though i can present different forms for different categories, they are redirected to add.cgi default form, if they didn't enter a required field.
Webmaster33, is your global overcomes this?
Thanks.
I said i tried Jack method and it is working. But the problem is if user left any 'Not Null - Yes' link fields the form is going back to 'add.cgi' not 'add.cgi?ID'
For example Title is set to Not null- Yes. If user enter the form at mydomain/add.cgi?231 and forgot to fill title. He will be pointing to the error and now he will be on add.cgi (default form) So even though i can present different forms for different categories, they are redirected to add.cgi default form, if they didn't enter a required field.
Webmaster33, is your global overcomes this?
Thanks.
May 10, 2003, 7:41 AM
Veteran (2312 posts)
May 10, 2003, 7:41 AM
Post #35 of 45
Views: 7437
Note:
The mydomain/add.cgi?231 format is bad.
The mydomain/add.cgi?ID=231 is good.
If you don't want to use my global, then don't use it.
However I thought you want to avoid typing such a lot if conditions...
Well, yes, because it seems the ID isn't passed to the error page.
Just use my global, and add the following code to add.html pages, after <%include include_form.html%>:
Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
The mydomain/add.cgi?231 format is bad.
The mydomain/add.cgi?ID=231 is good.
If you don't want to use my global, then don't use it.
However I thought you want to avoid typing such a lot if conditions...

Quote:
He will be pointing to the error and now he will be on add.cgi (default form) ...Just use my global, and add the following code to add.html pages, after <%include include_form.html%>:
Code:
<input type=hidden name='ID' value='<%ID%>'>Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
May 10, 2003, 8:03 AM
User (245 posts)
May 10, 2003, 8:03 AM
Post #36 of 45
Views: 7360
Is this the way in add.html?
<%set is_child_category_231 = is_child_category($ID, 231)%><%if is_child_category_231%><%include include_form_231.html%><input type=hidden name='ID' value='<%ID%>'><%endif%>
<%set is_child_category_500 = is_child_category($ID, 500)%><%if is_child_category_500%><%include include_form_500.html%><input type=hidden name='ID' value='<%ID%>'><%endif%>
Thanks.
<%set is_child_category_231 = is_child_category($ID, 231)%><%if is_child_category_231%><%include include_form_231.html%><input type=hidden name='ID' value='<%ID%>'><%endif%>
<%set is_child_category_500 = is_child_category($ID, 500)%><%if is_child_category_500%><%include include_form_500.html%><input type=hidden name='ID' value='<%ID%>'><%endif%>
Thanks.
May 10, 2003, 8:59 AM
Veteran (2312 posts)
May 10, 2003, 8:59 AM
Post #37 of 45
Views: 7390
No. The
<input type=hidden name='ID' value='<%ID%>'>
code is needed only once, and should not be placed within the if statement.
Place before
<input type="SUBMIT" name="add" value="Add Link">
code.
Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
<input type=hidden name='ID' value='<%ID%>'>
code is needed only once, and should not be placed within the if statement.
Place before
<input type="SUBMIT" name="add" value="Add Link">
code.
Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
May 11, 2003, 7:13 PM
Veteran (2312 posts)
May 11, 2003, 7:13 PM
Post #39 of 45
Views: 7380
Do you use the global?
Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
May 11, 2003, 7:20 PM
User (245 posts)
May 11, 2003, 7:20 PM
Post #40 of 45
Views: 7470
No. With global i got this problem:
Example- say i have A,B,C,D categories. Global is taking the category and its sub and sub sub categories and presenting one form. If i want one or two sub categories under 'A' different form from the form of that category, i couldn't get it work.
So again i changed back to <if ID == 3... method.
thanks.
Example- say i have A,B,C,D categories. Global is taking the category and its sub and sub sub categories and presenting one form. If i want one or two sub categories under 'A' different form from the form of that category, i couldn't get it work.
So again i changed back to <if ID == 3... method.
thanks.
May 12, 2003, 9:57 AM
Veteran (2312 posts)
May 12, 2003, 9:57 AM
Post #41 of 45
Views: 7522
You didn't mention that until now.
Yes, I understand your problem.
Original supposed solution was: "Using the 123 as parameter, means it will display the form in category with ID 123, and all subcategories of it".
There is a workaround for that problem, but it just a limited solution, since you will not able to use include to get form from a file.
<%set is_child_category_123 = is_child_category($ID, 123)%>
<%set is_child_category_130 = is_child_category($ID, 130)%>
<%set is_child_category_131 = is_child_category($ID, 131)%>
<%if is_child_category_123%><%set result = 'aaaaaaaaaaaaaaaaaa'%><%endif%>
<%if is_child_category_130%><%set result = 'bbbbbbbbbbbbbbbbbb'%><%endif%>
<%if is_child_category_131%><%set result = 'cccccccccccccccccc'%><%endif%>
<%result%>
In some cases this will help you out.
However the approach of the problem was bad, so we need a different approach.
Seems you want a more complex solution, to have the form templates inherited down in the hierarchy, while you can override the used form template anytime in deeper categories.
I will try to come out with a solution for you, which will match that new approach above.
Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Yes, I understand your problem.
Original supposed solution was: "Using the 123 as parameter, means it will display the form in category with ID 123, and all subcategories of it".
There is a workaround for that problem, but it just a limited solution, since you will not able to use include to get form from a file.
<%set is_child_category_123 = is_child_category($ID, 123)%>
<%set is_child_category_130 = is_child_category($ID, 130)%>
<%set is_child_category_131 = is_child_category($ID, 131)%>
<%if is_child_category_123%><%set result = 'aaaaaaaaaaaaaaaaaa'%><%endif%>
<%if is_child_category_130%><%set result = 'bbbbbbbbbbbbbbbbbb'%><%endif%>
<%if is_child_category_131%><%set result = 'cccccccccccccccccc'%><%endif%>
<%result%>
In some cases this will help you out.
However the approach of the problem was bad, so we need a different approach.
Seems you want a more complex solution, to have the form templates inherited down in the hierarchy, while you can override the used form template anytime in deeper categories.
I will try to come out with a solution for you, which will match that new approach above.
Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
May 12, 2003, 10:58 AM
User (245 posts)
May 12, 2003, 10:58 AM
Post #42 of 45
Views: 7288
Quote:
You didn't mention that until now.I didn't think of that until i put your global and customized everything and then scratched my head...
I gave you an email .Can you check that for me please and answer me?
thanks.
May 12, 2003, 11:08 AM
Veteran (2312 posts)
May 12, 2003, 11:08 AM
Post #43 of 45
Views: 7286
Uh, please take/edit out my email from you last post, please!
I just finished the new global I mentioned, will post soon.
Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
I just finished the new global I mentioned, will post soon.
Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
May 12, 2003, 11:50 AM
Veteran (2312 posts)
May 12, 2003, 11:50 AM
Post #45 of 45
Views: 7291
Because I don't like to have my email in forums. Email parser engines will find my email and I will get a lot spams. I already get many of them, don't want more...
Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Best regards,
Webmaster33
Paid Support from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...