Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Global to Display Category Properties on add.html

Quote Reply
Global to Display Category Properties on add.html
I was wondering if anyone knows how to write a global that will display category properties (for example, there is a seperate category field such as category_add_listing_description that will be shown on add.html so users can better understand the defination of the category) on add.html & add_success.html & detailed.html page?

Thank you very much.

Vishal

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Global to Display Category Properties on add.html In reply to
Hi,

Something below should work

sub {

my $cols = $DB->table('Category')->cols;
my $output = qq|<table border=1><tr><th>Fields</th><th>Type</th><td>Default value</td></tr>|;
foreach (sort{$cols->{$a}->{pos} <=> $cols->{$b}->{pos}} keys %$cols){

my $f = $cols->{$_};

my $n = $f->{form_display} || $_;
$output .= qq|<tr><td>$n</td><td>$f->{form_type}</td><td>$f->{default}</td></tr>|;
}

$output .= "</table>";
return $output;

}

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Global to Display Category Properties on add.html In reply to
Hello Dat,

Thank you for the quick reply and help.

Yes the global above works, however what it does is displays all the category property in a table format where the sub is inserted.

I was wondering if you knew how to display only certain selected field when and where required, for example

(a) Category add link description:
So like where I want the description to appear I can add <%category_add_link_description%> (or whatever the global would be)

(b) Category Type:
I have this as enum field in category property. So based on the type of category, it will have different include_link_addition_form.html

...

--------------------------

When I use gt:template:dump tag in the template, I can see the fields in category loop as below:

category_loop [
{
'CatDepth' => '0',
'CatRoot' => '0',
'Category_Template' => '',
'Category_Type' => 'glossary',
'Description' => '',
'Direct_Links' => '2',
'FatherID' => '0',
'Footer' => '',
'Full_Name' => 'glossary',
'Has_Changed_Links' => 'No',
'Has_New_Links' => 'Yes',
'Header' => '',
'ID' => '10',
'Link_Add_Description' => 'This is link add description. This is link add description. This is link add description. ',
'Meta_Description' => '',
'Meta_Keywords' => '',
'Name' => 'glossary',
'Newest_Link' => '2005-11-26',
'Number_of_Links' => '2',
'Payment_Description' => '',
'Payment_Mode' => '0',
'Timestmp' => '2005-11-28 10:10:57',
'category_display_name' => 'Glossary',
}
];

Thank you for the help.

Vishal

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Global to Display Category Properties on add.html In reply to
It's simple to print out all the fields. You can limit some by adding the next command within the foreach loop as below

next if(/ID|Timestamp/);

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Global to Display Category Properties on add.html In reply to
Hi,

You could try something like this (untested). It should return new tags such as;

<%category_add_help_Description%>

Code:
sub {

my $cols = $DB->table('Category')->cols;

my $return;
foreach (sort{$cols->{$a}->{pos} <=> $cols->{$b}->{pos}} keys %$cols){
my $f = $cols->{$_};
my $n = $f->{form_display} || $_;
my $field = "category_add_help_" . $f;
$return->{$field} = qq|$n - Example, $f->{default}|;
}

return $return;

}

Hope that helps.

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] Global to Display Category Properties on add.html In reply to
Using sort() is redundant in that case.
Quote Reply
Re: [Andy] Global to Display Category Properties on add.html In reply to
Hello Andy,

The global does not seem to work.

This is what I did.
  • Created a new global & named it cat_field1
  • Now in add.html above Title field, I wanted to display the Category Description, so in the template I inserted <%cat_field1%> however the output was Unknown Tag: 'catfield1'

I have created a table Link_Add_Description in category properties in GLinks Admin & while adding category, I also write 2-3 lines of description for the category. So when end users are adding the listing, within the template I can display this Link_Add_Description in proper formatted manner.

Thank you for the the help.

Vishal

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Global to Display Category Properties on add.html In reply to
Hi,

erm, so in fact you don't want the value from the table.. but instead the "Description" of the categories from the table "Link_Add_Description" field in lsql_Category?

Kinda different things Tongue

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] Global to Display Category Properties on add.html In reply to
In Reply To:
Hi,

erm, so in fact you don't want the value from the table.. but instead the "Description" of the categories from the table "Link_Add_Description" field in lsql_Category?

Kinda different things Tongue

Cheers


Right on target....

So any idea, how would this work?

Vishal

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Global to Display Category Properties on add.html In reply to
...well, assuming they are passing in ?ID=xxxx (where xxx is the Id of the category they want to add), you could use something like;

Code:
sub {
my $ID = $IN->param('ID') || return '';
my $catdesc = $DB->table('Category')->select( ['Link_Add_Description'], { ID => $ID } )->fetchrow;
return $catdesc;
}

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] Global to Display Category Properties on add.html In reply to
Dude !!!!!

you are genius.... it worked perfectly Smile Smile Smile

Thanks again for the help.

Vishal

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Global to Display Category Properties on add.html In reply to
LOL no problem Blush

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] Global to Display Category Properties on add.html In reply to
Hello Andy,

Above global works great with text fields, however when I try to use it along with ENUM (Select or Radio) options, it fails to work. Any ideas?

Vishal

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Global to Display Category Properties on add.html In reply to
Likely they produce an array result, so you need to handle array at input:
my @ID = ($IN->param('ID')) || return '';

Just a quick idea. Not tested.

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...
Quote Reply
Re: [SWDevil.Com] Global to Display Category Properties on add.html In reply to
When you say "fails to work", what do you mean by that? Doesn't print anything, or its all on one line?

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] Global to Display Category Properties on add.html In reply to
Hello Andy,

Thanks for the reply. Sorry for the false alarm, as a matter of fact it is working perfectly for both text area fields & also select/radio fields too.

P.S. I was working on 3 sets of template & by mistake was updating one set & uploading another :( & hence the error.

Thank you again for the help.

Vishal

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Global to Display Category Properties on add.html In reply to
In Reply To:
Hello Andy,

Thanks for the reply. Sorry for the false alarm, as a matter of fact it is working perfectly for both text area fields & also select/radio fields too.

P.S. I was working on 3 sets of template & by mistake was updating one set & uploading another :( & hence the error.

Thank you again for the help.

Vishal

heheh.. np =)

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] Global to Display Category Properties on add.html In reply to
How would you modify this global to display category properties on detailed pages

for example I want to display ID, Name or FatherID of a link belonging to whatever category its located in on its detailed page

Thanks
Quote Reply
Re: [incik] Global to Display Category Properties on add.html In reply to
In Reply To:
How would you modify this global to display category properties on detailed pages

for example I want to display ID, Name or FatherID of a link belonging to whatever category its located in on its detailed page

Hi,

Something like this would do it;

Code:
sub {
my $ID = $IN->param('ID') || return '';
my $cat = $DB->table('Category')->select( { ID => $ID } )->fetchrow_hashref;
return $cat;
}

Then you should have access to all the category properties :)

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] Global to Display Category Properties on add.html In reply to
Thanks for the assist

but it didnt work
Quote Reply
Re: [incik] Global to Display Category Properties on add.html In reply to
it didnt work

unless I did it wrong

any examples you could show?
Quote Reply
Re: [incik] Global to Display Category Properties on add.html In reply to
This is a bit more complicated because a link can be in multiple categories. Something like this:

Code:

sub {
my $ID = $IN->param('ID') || return '';
my $sth = $DB->table('Category','CatLinks')->select( { LinkID => $ID });

my @cats;
while (my $cat=$sth->fetchrow_hashref){
push @cats, $cat;
}
return {Cat_Loop=>\@cats};
}


Last edited by:

afinlr: Jul 28, 2006, 3:52 PM
Quote Reply
Re: [incik] Global to Display Category Properties on add.html In reply to
This global returns a loop so you need something like this in your template:

<%loop Cat_Loop%>
<%Name%>
<%endloop%>
Quote Reply
Re: [afinlr] Global to Display Category Properties on add.html In reply to
>> This is a bit more complicated because a link can be in multiple categories.

It may be the one piece of logic GT hasn't addressed. Brewt had started to, but said there was probably a reason why it wasn't carried through.

This causes problems on "browse" and prev|next ... really weird stuff until you realize what is happening.

Category_ID needs to be preserved in detail page display, and passed on for the next|prev linking too.

In general, there is no way to know what category a link is being displayed for, unless you limit links to being in only one category (which sort of cripples the features of allowing it to exist in multiple categories).

This is a real weakness and hole in the GLinks logic. One of the few I've hit that has been really, really an issue in working through/around.

I hadn't hit it until GL3, since all my sites were using the detail_page.cgi (or modified version) which did preserve the Category_ID somewhat accidentally. next|prev was still affected eventually, but the detail pages at one-level off a category.html knew where they came from.

It probably should be built into the page-spanning code, since that is where it starts to break down fastest. If it's there, it can (or should be allowed to be) accessed as a simple tag such as span_cat_id.


PUGDOG´┐Ż Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.