Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Need anything like premium entries - ideas howto?

Quote Reply
Need anything like premium entries - ideas howto?
Hi,

i need to display the following in a category:

-----------
'premium entries'
-----------
'normal entries'

The premium entries should be markable over the administration ... any idea how to do this?

Any help is appriciated - but please answer for a newbie!

Thanks

Quote Reply
Re: Need anything like premium entries - ideas howto? In reply to
Add a field to your links database (lets call it premium), where default value could be 0 for normal entries and 1 could be the value for premium entries. Than you have to build into category.html something like this:

<%if links%>
<%if premium eq 1%>
<%links%>
______________________ (your choice of divide)
<%endif%>

<%if premium eq 0%>
<%links%>
<%endif%>
<%endif%>

If this doesn't work, play around a little bit with the <%if ...%> tags, it's pretty easy (more is explaned in Help).

Regards,
Andy

Quote Reply
Re: Need anything like premium entries - ideas howto? In reply to
Hi Andy,

thanks for your hint - what type of field should the "premium"-field be?

Thanks!

Quote Reply
Re: Need anything like premium entries - ideas howto? In reply to
I would suggest INT if you want to use numerical values.
Please note that my answer was a shot from the hip - if it doesn't work: as I said (I guess you know this already), using the <%if %> tags is quite simple and its amazing how much you can do with them. Just play around and you will find a solution. To backup your templates- and defs-files befor making changes is, of course, always a good idea. ;-)

Hope it helps,
Andy

Quote Reply
Re: Need anything like premium entries - ideas howto? In reply to
Hi andy,

i've read the help and tried the following:

<%if links%>
<%if Premium eq '1'%>
<b>premium:</b>
<%links%>
<%else%>
<b>standard:</b>
<%links%>
<%endif%>
<%endif%>

Additionally i've added:

<%if Premium eq '1'%>
<small>Premium</small>
<%endif%>

to link.html to see if an entry is really marked as "Premium".

my entry for testing purposes is marked as premium but not listed as premium entry ...

Does anyone have a suggestion what could be wrong?

Thanks!

Quote Reply
Re: Need anything like premium entries - ideas howto? In reply to
Try:

<%if Premium eq '1'%>
<b>premium:</b>
<%links%>
<%endif%>

<if Links%>
<b>standard:</b>
<%links%>
<%endif%>



Paul Wilson.
Installations:
http://www.wiredon.net/gt/
Quote Reply
Re: Need anything like premium entries - ideas howto? In reply to
Hi Paul,

nope - doesn't work ....



Quote Reply
Re: Need anything like premium entries - ideas howto? In reply to
Ok, you have added an extra field to your database.

Go to SETUP >> BUILD OPTIONS >>

There arte the entries of sort order for
Category, new and col sites.

Just set there your Field to the first position.

Should work

Michael

Quote Reply
Re: Need anything like premium entries - ideas howto? In reply to
Michael is right: if you change the sort order you will sort your premium links to the top. But there is a mistake im my previous suggestion: the <%Premium ...%> tags will only work in links.html but not in catgory.html. So what you can do is sort them to the top and mark them as premium. Other things you might want to do like deviding your premium from your normal links may be a little bit tricky.

Good luck,
Andy

Quote Reply
Re: Need anything like premium entries - ideas howto? In reply to
Hi,

> Other things you might want to do like deviding your
> premium from your normal links may be a little bit tricky.

Yes - but thats exactly what i want ...

Any further hints?

Thanks!

Quote Reply
Re: Need anything like premium entries - ideas howto? In reply to
Hi Chief,

you can mark your premium records with the IF tags.
It must work!!
I use text-fields to let it work, with YES or NO option.

in link.html change to

<ul><li><a class="link" href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>">

<%if Premium eq 'Yes'%>
<font color=red>
<%Title%>
<%endif%>
<%if Premium eq 'No'%>
<%Title%>
<%endif%>

</a>

<%if Description%>
<span class="descript">- <%Description%></span>
<%endif%>

<%if isNew%>
<small><sup class="new">new</sup></small>
<%endif%>

<%if isChanged%>
<small><sup class="new">update</sup></small>
<%endif%>

<%if isPopular%>
<small><sup class="pop">pop</sup></small>
<%endif%>

<small class="date">(Added: <%Add_Date%> Hits: <%Hits%> Rating: <%Rating%> Votes: <%Votes%>) <a href="<%db_cgi_url%>/rate.cgi?ID=<%ID%>">Rate It</a></small>

<%if isLinkOwner%>
<small class="date"><a href="<%db_cgi_url%>/modify.cgi?LinkID=<%ID%>">Update</a></small>
<%endif%>

</ul>


Play around.

Michael


Quote Reply
Re: Need anything like premium entries - ideas howto? In reply to
Hi Michael,

thanks for your reply - sure this will work in link.html, but i want to display those entries in a different way of the "normal" ones - so the definition of those entries must be in category.html ...

Simply it should be like:

(Start of a category)
premium entries
---horizontal line---
normal entries
(End of a category)

The problem is to display a divider between the normal and premium entries .. i do have no idea how to integrate this ...

Chef


Quote Reply
Re: Need anything like premium entries - ideas howto? In reply to
Hi,

I think what you're wanting to do is 'remove' the premium links from your standard links and then display them separately, as opposed to 'marking' them as premium links within the standard ones - correct?

I've done this with V1.13 on three different levels:

Super listings (most likely the same as your proposed premium ones where link owners pay for an enhanced placement in the top of their link's category)
TopSites listings (for people who place a reciprocal link back to Qango)
Standard listings (all the rest of the regular links)

However, it's not all that easy to do since you have to create different 'sets' of links and process and format them individually to get the kind of control you're looking for.

Here's what I came up with, not sure if it'll apply to 2.x but it might give you an idea on how to proceed:

1) nph-build.cgi at sub build_category_pages:

Directly UNDERNEATH this line "$get_related = $LINKDB->prepare (" SELECT Category.Name FROM ....." I modified the $get_links and added two new link sets:

$get_super = $LINKDB->prepare (" SELECT * FROM Links WHERE CategoryID = ?AND isTop = 1 ORDER BY $LINKS{build_sort_order_category} LIMIT 1000 ");

$get_topsites = $LINKDB->prepare (" SELECT * FROM Links WHERE CategoryID = ? AND isTop = 2 ORDER BY $LINKS{build_sort_order_category} LIMIT 1000 ");

$get_links = $LINKDB->prepare (" SELECT * FROM Links WHERE CategoryID = ? AND isTop = 3 ORDER BY $LINKS{build_sort_order_category} LIMIT 1000 ");

... you'll notice that I've highlighted the parts of the statement that separate the different link types based on the value of 'isTop'. In your case, you'll probably only need one of these additional statements since you'll have 2 sets of links; Premium and Standard

2) Further down you'll find "# Get the links", this is where we split up the links into their different groups for processing and formatting - I added these lines:

$get_super->execute ($category_r->{'ID'});
$get_topsites->execute ($category_r->{'ID'});

$links_s = $get_super->fetchall_arrayref || ['Test','Rotz'];
$links_t = $get_topsites->fetchall_arrayref || ['Test','Rotz'];

$links_s = &build_sort_links ($links_s, $alt_r) if (@{$alt_r});
$links_t = &build_sort_links ($links_t, $alt_r) if (@{$alt_r});

$numlinkssup = $#{$links_s} + 1 || 0;
$numlinkstop = $#{$links_t} + 1 || 0;

$numlinks_total = $numlinks + $numlinkssup + $numlinkstop;
$OUT{total} = $numlinks_total;
$total_links = $numlinks_total;

3) After # Calculate the related entries and put in a <LI> list. I added two new sub routines to process the new sets of links:

# Build the Super Listing's links
$OUT{super} = '';
if ($links_s) {
for my $i (0 .. $numlinkssup -1) {
$tmps = $LINKDB->array_to_hash (${$links_s}[$i]);
$OUT{super} .= &site_html_link ($tmps);
}
}

# Build the Top Sites links
$OUT{topsites} = '';
if ($links_t) {
for my $i (0 .. $numlinkstop -1) {
$tmpt = $LINKDB->array_to_hash (${$links_t}[$i]);
$OUT{topsites} .= &site_html_link ($tmpt);
}
}

4) Finally I added a 'check' into my category.html template to test for the new sets and place them if they are there:


<%if links%>
<hr width=100% size=1>
<ul><%links%></ul>
<%endif%>

... it took me a while to perfect the separation and placement and like I said, it may or may not work like this in 2.0 but it should give you an idea on how to go about separating the different link types for individual/unique placement in your category pages.

Hope this helps.

All the best
Shaun

BTW: there may well be a simpler method availble in 2.x than I've described above so if anyone else can improve on this, please let us know Smile