Gossamer Forum
Quote Reply
Category Logo
Hi Andy and everyone else!

I created a field in category templete called "header_html".
Its perfectly passed to that category where I want it applied. But I need it to be passed to all categories under that one with out having to fill it in over and over again.
Is there some global or something?

Thanks,

JC
Quote Reply
Re: [Gorospe] Category Logo In reply to
Hi,

You wanna update the sub-categories to use the same value as the parent one? Probably the best way would be with a global (so that it gets updated each time you change it);

get_category_header_html
Code:
sub {
if (length($_[1]) > 1) { return $_[1]; }
my @cats; my @back;
foreach (@split /\//, $_[0]) {
push @back, $_;
push @cats, join "/", @cats;
}

foreach (reverse @cats) {
my $html = $DB->table("Category")->select( ['Header_HTML'], { Full_Name => $_ } )->fetchrow || '';
if (length($html) > 1){ return $html; }
}

}

Then call with:

Code:
<%if not header_html%>
<%set header_html = get_category_header_html($Full_Name,$Header_HTML)%>
<%endif%>


*completly* untested... but should work Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Feb 1, 2012, 7:53 AM
Quote Reply
Re: [Andy] Category Logo In reply to
Its not giving an error but its not working.
Not even on partent categories.
Since the field is called Header_HTML i changed some of the caps on the global after testing the initial one, but still nothing... Not even on parent, or taking off the if.
Quote Reply
Re: [Gorospe] Category Logo In reply to
So the modified version above doesn't work? (I've changed all the places where you gave me the wrong field name ... so if that doesn't work its something else)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Category Logo In reply to
Sorry about that andy. Nope it doesnt work.
Doesnt give an error either.
Just doesnt do anything, parent cat or sub cats.
Quote Reply
Re: [Gorospe] Category Logo In reply to
Please try the modified version and let me know what it outputs:

Code:
sub {
if (length($_[1]) > 1) { print $IN->header; print "Value already exists..."; return $_[1]; }
my @cats; my @back;
foreach (@split /\//, $_[0]) {
push @back, $_;
push @cats, join "/", @cats;
}

print $IN->header;
use Data::Dumper;
print "CATS: " . Dumper(@cats);


foreach (reverse @cats) {
my $html = $DB->table("Category")->select( ['Header_HTML'], { Full_Name => $_ } )->fetchrow || '';
if (length($html) > 1){ return $html; }
}

}

Also, I'm assuming this is being called in category.html?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Feb 1, 2012, 8:01 AM
Quote Reply
Re: [Andy] Category Logo In reply to
Still noting.
No error, no broken image, no nothing.
Called from category.html and header.html just in case.
Neither.
Quote Reply
Re: [Gorospe] Category Logo In reply to
Can you send me GLinks admin logins, and also an example category (via page.cgi) where I can see it running? I'll have a quick look for you.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Gorospe] Category Logo In reply to
Ok, there was a typo in the global - and also a couple of other things.

1) The global should be:

Code:
sub {
if (length($_[1]) > 1) { return $_[1]; }
my @cats; my @back;
foreach (split /\//, $_[0]) {
push @back, $_;
push @cats, join ("/", @back);
}

foreach (reverse @cats) {
my $html = $DB->table("Category")->select( ['Header_HTML'], { Full_Name => $_ } )->fetchrow || '';
if (length($html) > 1){ return $html; }
}

}

2) It should be called BEFORE include_header.html
3) The way to call it is with:

Code:
<%if not Header_HTML%>
<%set Header_HTML = get_category_header_html($Full_Name,$Header_HTML)%>
<%endif%>

Its all working fine now Angelic

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!