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

Ultra Globals Plugin: Load_Reviews_Advanced

Quote Reply
Ultra Globals Plugin: Load_Reviews_Advanced
Andy

I'm trying to use the Ultra Global Plugin for "Load_Reviews_Advanced"

I've 'modified my pages' so that 'Review' reads 'Latest News and Special Offers'

I've placed the code into the category.htm template and using the code with the $ID

<%Plugins::ULTRAGlobals::Load_Reviews_Advanced("10",$ID)%>
<%if review_loop.length%>
<h3>Latest Bed and Breakfast News or Special Offers</h3>
<%loop review_loop%>
<%include review_include.html%>
<%endloop%>
<%endif%>


Is it supposed to work so that the 'review' should only show in the category that it belongs to?

Eg. on my site I have 1 'review' for a link in this category: England/Cornwall/Helston

But at present it is showing in each category:

England/
England/Cornwall/
England/Cornwall/Helston

Can it be made to work so that the 'review' only displays in the category the link belongs to?

Thanks
Colin Thompson

Last edited by:

colintho: Dec 11, 2008, 9:01 AM
Quote Reply
Re: [colintho] Ultra Globals Plugin: Load_Reviews_Advanced In reply to
Hi,

You need a new global to do it (cos the ULTRAGlobals one using children(), which actually gets the sub-cat ID's too)

Try this: (new global)

Load_Reviews_Advanced

Code:
sub Load_Reviews_Advanced {


my ($output,$hit);

my $catid = $_[1];
my $limit = $_[0] || 10;
my @reviews;

if ($catid) {

my $table = $DB->table('Reviews','Links','Category','CatLinks');
$table->select_options('ORDER BY Review_Date DESC',"LIMIT $limit");

# Only select validated reviews

my $seen;
my $sth = $table->select( GT::SQL::Condition->new( ['CategoryID', '=', $catid], [ 'Review_Validated', '=', 'Yes' ] ) ) || return $GT::SQL::error;
while (my $hit = $sth->fetchrow_hashref()) {

if ($seen->{$hit->{Review_LinkID}}) { next; }
$seen->{$hit->{Review_LinkID}};

# Modify short date format to mini format
$hit->{Review_Date}=GT::Date::date_transform($hit->{Review_Date},"%yyyy%-%mm%-%dd%","%dd% %mmm% %yy%");
$hit->{detailed_url} = $CFG->{build_detail_url} . '/' . $DB->table('Links')->detailed_url($hit->{ID});
push @reviews, $hit;
}

} else {


my $table = $DB->table('Reviews','Links');
$table->select_options('ORDER BY Review_Date DESC',"LIMIT $limit");

# Only select validated reviews

my $sth = $table->select( GT::SQL::Condition->new( [ 'Review_Validated', '=', 'Yes' ] ) ) || return $GT::SQL::error;
while (my $hit = $sth->fetchrow_hashref()) {

# Modify short date format to mini format
$hit->{Review_Date}=GT::Date::date_transform($hit->{Review_Date},"%yyyy%-%mm%-%dd%","%dd% %mmm% %yy%");
$hit->{detailed_url} = $CFG->{build_detail_url} . '/' . $DB->table('Links')->detailed_url($hit->{ID});
push @reviews, $hit;
}

}

return { review_loop => \@reviews };
}

Call with:

Code:
<%Load_Reviews_Advanced("10",$ID)%>

That should work fine.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Ultra Globals Plugin: Load_Reviews_Advanced In reply to
Andy

I've added the code as a new global: "Load_Reviews_Advanced"

Then edited the category template using this code to call the global:

<%Load_Reviews_Advanced("10",$ID)%>
<%if review_loop.length%>
<h3>Latest Bed and Breakfast News or Special Offers</h3>
<%loop review_loop%>
<%include review_include.html%>
<%endloop%>
<%endif%>

I get this error message where I was expecting to see a 'review' on the relevant pages

Error: Variable 'Load_Reviews_Advanced' is not a code reference

I've put the original 'Ultra Global Plugin code back into the category.html

I've set the Helston category to use a 'custome' template (category_hels.html) to show this error code:

Error: Variable 'Load_Reviews_Advanced' is not a code reference




thanks
Colin Thompson
Quote Reply
Re: [colintho] Ultra Globals Plugin: Load_Reviews_Advanced In reply to
Hi,

Sorry - was rushing it =)

This line:

Code:
sub Load_Reviews_Advanced {

..should be:

Code:
sub {

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Ultra Globals Plugin: Load_Reviews_Advanced In reply to
Andy

that works - many thanks - youre a star.
Colin Thompson