Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Is it possible to manually set a link popular?

Quote Reply
Is it possible to manually set a link popular?
Hi!

Is it possible for the admin to give a link the status popular? Even if the link didn't reached the cutoffs value set in admin menu? Is there a mod or something for this?



sun
Quote Reply
Re: [sun112] Is it possible to manually set a link popular? In reply to
You could just change the number of hits to put it over the cutoff?
Quote Reply
Re: [afinlr] Is it possible to manually set a link popular? In reply to
Hi!

That's possible, but as we want to have sponsored links, it'd be easier to manually set them popular. As well as other, usual submitted links would get popular status, too.



sun
Quote Reply
Re: [sun112] Is it possible to manually set a link popular? In reply to
Its not that easy as the flags for popular links are set everytime you build (I think).

Why do you want them to be popular? Do you just want them to show up first - you could do this by adding a new field to the database called isSponsored and then add this field to the sort options in setup.
Quote Reply
Re: [sun112] Is it possible to manually set a link popular? In reply to
Hi,

If you know the LINK_ID of the link you want popular, you can make a small change to the code.

Do you use static, or dynamic sites? The process is a bit different for each.

For static sites, you can edit Build.pm, and in the subroutine build_cool_flags you can change:

Code:
while ( ($id, $hits, $ispop) = $sth->fetchrow_array) {
push @ids, $id;
next if ($ispop eq 'Yes');
$link_db->update ( { isPopular => 'Yes' }, { ID => $id }, { GT_SQL_SKIP_CHECK => 1 } );
$changed++;
}


to

Code:

while ( ($id, $hits, $ispop) = $sth->fetchrow_array) {
push @ids, $id;
next if ($ispop eq 'Yes');
$link_db->update ( { isPopular => 'Yes' }, { ID => $id }, { GT_SQL_SKIP_CHECK => 1 } );
$changed++;
}

my @keep_popular_list = (list,of,ids,to,make,or,keep,popular); ## for clarity
push @ids , @keep_popular_list;


What this does, is push the ID's onto $ids, which prevents them from being reset to "isPopular = No" a few lines down. It does *NOT* set any links to popular (you'll have to do that yourself in the admin).

You could probably add:
Code:
foreach my $keep_popular_ID (#keep_popular_list) {
$link_db->update ( { isPopular => 'Yes' }, { ID => $keep_popular_ID }, { GT_SQL_SKIP_CHECK => 1 } );
}


after the last line to actually set the keep_popular links to "pop" in case something resets them for some reason.


If you want to keep the limit you set in your config, a bit higher up you'll need to change

$limit = int $limit || 1;

to be

#$limit = int $limit || 1;
$limit = 15 ; ## or whatever value you want to show, MINUS the number of "Keep Popular" links.

So, if you want 20 total popular links, and have 7 keep-popular links, your $limit needs to be set to 13.


Yes, this is a quick/dirty hack, that should work for static sites, since this routine is called before the pages are built.

Dynamic sites have a different set of problems.


While this is a code edit that won't survive an upgrade, it also won't break an upgrade, and you can always add it back. Creating a plugin, or such, is a lot more code, and sort of like hitting a fly with a slege hammer. Sometimes, code edits are _good_ ;)


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [afinlr] Is it possible to manually set a link popular? In reply to
In Reply To:
Its not that easy as the flags for popular links are set everytime you build (I think).

Why do you want them to be popular? Do you just want them to show up first - you could do this by adding a new field to the database called isSponsored and then add this field to the sort options in setup.


That worked great! Thanks a lot.

btw, I in links properties, I had to enter "Yes" and "No" into the text fields "Form Names" and "Form Values". But under each of this is written "(Stored in Database/Displayed on Form) Only for checkbox, multi-select or radio forms. But I set form to select only, not multi-select. Is it ok, the way I did?



And the next question: Angelic

Would it be as easy, to assign isSponsored links, which are set to "yes", a image like "new" or "popular" in links.html?



sun
Quote Reply
Re: [sun112] Is it possible to manually set a link popular? In reply to
>>>Would it be as easy, to assign isSponsored links, which are set to "yes", a image like "new" or "popular" in links.html? <<<

Easy. Just add a new field, INT, default 0 ... then in your template, put something like;

Code:
<%if isSponsor%>
show sponsor stuff
<%else%>
show normal link
<%endif%>

... you also need to edit build_sort_order so that it you have something like this at the beginning;

isSponsor DESC, isPop DESC ... etc.

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: [sun112] Is it possible to manually set a link popular? In reply to
I tried by myself adding

<%if isSponsored%>
&nbsp;<img src="<%build_images_url%>/default/hot2.gif" border=0>
<%endif%>

to link.html.

But that way all links get the hot gif. Even those, that are set to "No".

Any ideas?



sun
Quote Reply
Re: [sun112] Is it possible to manually set a link popular? In reply to
You need to use 1 (yes) or 0 (no) to make it work correctly. If you use yes/no, then its always going to be true, as you have something set for the tag. 1/0 is a TRUE/FALSE environment, so that should work.

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] Is it possible to manually set a link popular? In reply to
In Reply To:
>>>Would it be as easy, to assign isSponsored links, which are set to "yes", a image like "new" or "popular" in links.html? <<<

Easy. Just add a new field, INT, default 0 ... then in your template, put something like;

Do you mean with adding "a new field, INT" that I should add a new column? How do I make it that the field belongs to "isSponsored" ? sun
Quote Reply
Re: [sun112] Is it possible to manually set a link popular? In reply to
Use <%if isSponsored eq 'Yes'%>
Quote Reply
Re: [afinlr] Is it possible to manually set a link popular? In reply to
Got it to work finally, with eq 'Yes'

Thanks for all you help! Smile



sun