Gossamer Forum
Quote Reply
random link with image
Hi Andy,
for random links I normally use your ultra globals.

But is there a global to show random links from defined categories and their subcategories?
AND
only links which have an image uploaded by your thumb image plugin!

Thanks

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] random link with image In reply to
Untested, but something like this should work:

get_random_link_with_image
Code:
sub {

my $cat = shift;
my $all_ids = $DB->table('Category')->children($cat);
push @$all_ids, $cat;

my $db_obj = $DB->table('Links','CatLinks','Category');
$db_obj->select_options ('ORDER BY RAND() LIMIT 1');

my $cond = GT::SQL::Condition->new('CategoryID', 'IN', $all_ids);
my $cond2 = GT::SQL::Condition->new('isValidated','=','Yes','LENGTH(Field_Name)','>',0);

my $link = $db_obj->select (['Links.*'], $cond, $cond2 )->fetchrow_hashref;
$link = Links::SiteHTML::tags('link', $link);

return { 'random_link_with_image' => $link }

}

Call with:

Code:
<%get_random_link_with_image(CAT_ID)%>
Title is: <%random_link_with_image.Title%>
URL is: <%random_link_with_image.URL%>
..etc

Be sure to change the part in red above to the actual field name :)

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] random link with image In reply to
Hi Andy,
thanks that's close to what I need!
I'm calling the global with this code

Code:
<%get_random_link_with_image(693)%>
<small><a href="<%random_link_with_image.detailed_url%>" target="_blank">
<%random_link_with_image.Title%></a><br />
<a href="<%random_link_with_image.detailed_url%>" target="_blank">
<img border="0" src="<%random_link_with_image.Bilder%>" <%if random_link_with_image.Width%>width="<%random_link_with_image.Width%>"<%endif%> <%if random_link_with_image.Height%>height="<%random_link_with_image.Height%>"<%endif%> title="<%random_link_with_image.Title%>" /></a></small>
There are only two problems
I need the full url to the thumbnails from your plugin.
At the moment <%random_link_with_image.Bilder%> does print out only the image title?

Thanks

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] random link with image In reply to
Hi,

You would want to use it like you do with Thumb_Images elsewhere, but instead of passing along $ID, you would use $random_link_with_image.ID 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!
Quote Reply
Re: [Andy] random link with image In reply to
Cool I got it.
This is another great andy global w00t

Thanks

Matthias
gpaed.de