Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Has this mod been done?

Quote Reply
Has this mod been done?
I would like to do this:

---------Category Page---------

links:
ibm.com etc
aol.com etc
microsoft.com

featured links:
microsoft.com


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

I would like to flag a link as featured and on it's category pages the link will be displayed twice, once normally and then again under a featured title.


Thanks for the help!

Shane

Quote Reply
Re: Has this mod been done? In reply to
Is something like the top5 on category-mod. Search the forum for this, please.
Robert

Quote Reply
Re: Has this mod been done? In reply to
Take a look at the Top5 mods that are here.

Then, decide if you want to do that for the whole site, or for each category.

If you want to do it for the whole site, calculate the "featured" links at the top of the HTML_Templates.pm file, and stuff it into a variable.

If you want to do it per-category, you need to add it to the build_category routine (probably) and assign the result to a variable that you then pass down the chain as part of the %GLOBAL data for that section.

It will then be reset every time you re-enter the build_category_page routine.

Should be easy to do which ever way you choose to do it.

http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: Has this mod been done? In reply to
Thanks guys for your replies. I've looked at the mod your talking about http://www.gossamer-threads.com/...um9/HTML/000184.html and it sounds good and I need it to but what I want right now is a little different, tell me if I'm wrong here.

I will mark links as preferred or not and on their category pages they will be displayed twice. Once normally and again at the bottom of the page. No need to look at the highest rated or most hits.

Just calling at top <%links%>

And call at the bottom, <%links_preferred%>
Displaying links with the preferred value checked on.

Thanks
shane staats
www.jeal.com



Quote Reply
Re: Has this mod been done? In reply to
so basically you make another field in the links database.. a Yes|No field..

call it.. isFeatured

then in nph-build.cgi.. you'd add something like this..

if ($tmp->{isFeatured} eq "Yes") {
$OUT{featured} .= &site_html_link ($tmp);
}

you put that a few times all around sub build_category_pages..

find these..

$tmp = $LINKDB->array_to_hash (${$links_r}[$i]);

and put the code from above underneath them.. (there are 3 occurences of this.. put underneath all 3)..

then under this..

close CAT;

(2 occurences.. put all 2).. put..

$OUT{featured} = "";

then in the category pages.. you can now put <žatured%> and it will display the featured links..

Jerry Su
email@jerrysu.com
http://www.jerrysu.com/
Quote Reply
Re: Has this mod been done? In reply to
Not a bad picutre jerry! Not quite how I expected you to look though. I figured you'd have a less serious, more rounder, "jolly" look to you <G>



http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: Has this mod been done? In reply to
well.. that is my school picture..

Cool

jerry

Jerry Su
email@jerrysu.com
http://www.jerrysu.com/
Quote Reply
Re: Has this mod been done? In reply to
Hi Jerry,

I am using this addition for my "Feaured Sites" feature. One question: the featured sites only show up on the pages that the actual link does. Is there a way to have the featured sites show up eitehr on every page within the category or just on the first page of the category? Problem is, the featured sistes only show up on, say, the 2nd or 3rd page in the category, which is pretty useless.

If you want to see what I mean, check out:

http://www.hothockey.com/pages/Associations___Federations/Regional/Canada/Nova_Scotia/more2.html

Thanks!

Quote Reply
Re: Has this mod been done? In reply to
Ok. I haven't really looked at this mod, but I've been asked to comment.

First, you've got a nice layout.

Second, you are probably testing each link to see if it's 'featured' rather than yanking all the featured links out of the category first.

Or, you are trying to sort with "isFeatured" first, and you are hitting the alt-link bug.

What you want is to generate the "featured" list as if it was a subcategory or related-category item.

Before you enter the processing of the category, you want to select all the "isFeatured" links for that category, and process them into a template variable "featured" or something like that, so you can do <%if featured%><%featured%><%endif%>

You only want to do this in the top block of the code for the first page of the output.

This is why the category processing subroutine first grabs the data, sees if we are spaning pages, and if we are, if we have more than one page, it builds page 1, then enters the build the rest of the pages loop.

This routine may look ungainly the first few times you go through it, but the reason is the first page of the category build is "different" from the rest of the pages due to the extra items you put at the top (related, subcats, etc). So, the routine first either builds one big page or just a page 1, then has a routine to loop through the rest of the data building any remaining pages.

You want to do the same thing, but just add the <%featured%> tag to the build routine after the <%subcategory%> and <%related%>

Make sense??

This may change in the next release. I have a feeling the program is going to be more of a set of widgets, and you string them together to do the work. In which case all the build routines are going to change, with more of the processing code in the .pm files, and only the structure code in the .cgi files. How much of that there is still remains to be seen :)



http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: Has this mod been done? In reply to
Pugdog,

You are correct, I have been tagging these links as isFeatured. So I have used the mod to pass the featured links into a usable vairbale such as <%links%> and am using <%if featured%><%featured%><%endif%>. As I mentiond, it works, but only on the page that the link appears in the normal place.

I am not sorting by isFeatured, so I am not running into that bug. Ideally, I would like the Featured links to show on all spanned pages, including the first, like the "Related Categories" do. But, if it shows up on the first page only, that would be fine as well.

I understand the concept as to what I need to do, but I don't exactly understand what it is I need to do in the programming sense. Can you clarify this a little more for me?

Thanks as usual!

Quote Reply
Re: Has this mod been done? In reply to
The easiest thing would be to send me a copy of you nph-build.cgi (if that is the file you changed) Or just the whole subroutine you changed in that file, and any other. I really don't need the whole file, just the whole subroutine (or you could post it here).

To get the isFeatured on all the spanning pages, you would need to put it into a variable in the first-page routine, and not re-set that variable to null or empty in the subsequent routine (ie: define it outside either of those proceedures). Then, in the the second block (loop to generate the subsequent pages) you would assign the isFeatured variable back to one of the hash values such as $rec->{isFeatured}=$featured, and it would be passed to the category template on _each_ pass, not just the first one. (If there are no featured categories, it would be ignored if empty with the <%if%> test.

To populate the $featured variable, you'd want to do a:

SELECT * FROM Links where isFeatured=Yes

then pass the results into a short loop to print each of the resulting 'hits' using the 'featured.html' template (create another subroutine in the HTML_Templates.pm file to print that, just copy one of the other routines, change the name, the template name and add the sub routine name to the exported list at the top).

if $featured is defined outside any of the loops (even at the top of the subroutine) then you can do this SELECT inside the first block of code for the first page, and those featured selections will stay in the $featured variable for the duration of that category.

You need to set $featured = '' at the top-level loop, so that when you pick the next category you reset it to ''.

(after:
foreach $category_r (@{$categories_r}) {
)


You don't want to test each link unless.....

Something interesting you could do.... if you test each found link for "isFeatured" you could send featured links to a "isFeatured.html" template rather than the standard link.html template... and that link would stand out in the regular list, but in it's regular place. This is probably easier than creating a multi-function template especially sinc you have already written the sub to print out the 'isfeatured.html' for the main page.

To give you anything more specific, I'd need to see your build_category_pages routine.



http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: Has this mod been done? In reply to
Pugdog,

I will send you my nph-build.cgi file via e-mail. I have actually already used a mod to take advantage of my isFeatured field (it is actually called "Priority") to print all featured links to the priority.html page. Now, as we have talked about, my problem is having the featued links show up on all of the (spanned) pages of its category, instead of only on the page where it exists in the default order.

I aplogize for my programming and Links SQL ignorance, but I would appreciate any specific changes to my nph-build.cgi file that you can find to make what I want to do work. You will see some comments where I made the changes, but I essentially used the exact changes mentioned above in this thread.

Quote Reply
Re: Has this mod been done? In reply to
It's just as I said.

what you are doing is scanning each page, and putting any featured links you find on that page.


Just above the comment line:

Code:
# If we are spanning pages, we grab the first x number of links and build
add this:

Code:

##################### corrected 07/12/00 (see following message)
for my $i (0 .. $numlinks - 1) {
$tmp = $LINKDB->array_to_hash (${$links_r}[$i]);
if ($tmp->{Priority} > 0) {
$OUT{featured} .= &site_html_link ($tmp);
}
}
#####################
That above section of code goes through all the found links looking for
any that are priority, and assigns them to the "featured" tag.

Remove all the other edits you made between the ######## bars, except for
the:

Code:
#######featured###########
$OUT{featured} = "";
#######################
which you leave right above the begining of the remaing page builds:

Code:
# Then we go through the list of links and build on the remaining pages.
If you want the featured items to appear on EVERY build page, just eliminate
the line that sets the value to empty.

NOTE: I don't have a way to test this, but it should work as written.

http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: Has this mod been done? In reply to
Pugdog,

Great, thanks! It works like a charm.

Just for those who are following this thread, a "}" is missing at the end of:

#####################
for my $i (0 .. $numlinks - 1) {
$tmp = $LINKDB->array_to_hash (${$links_r}[$i]);
if ($tmp->{Priority} > 0) {
$OUT{featured} .= &site_html_link ($tmp);
}
#####################

Quote Reply
Re: Has this mod been done? In reply to
Pugdog,

What do you mean, "eliminate the line that sets the value to empty." ?

Is that:

$OUT{featured} = "";

?

Thanks.

Quote Reply
Re: Has this mod been done? In reply to
oops about the '}' ... sometimes it's hard to see exactly what gets cut/pasted.

Yes, that line. If you don't re-set the value to empty, then the $OUT hash should maintain the value set for $OUT{featured} through the end of the loop for each category. The $OUT values are re-assigned each time a category is changed, but that's all.

If you set it to empty, it will fail the <%if featured%> test in the template, and you'll only get it on the first page, and not the span pages.

If you leave it full, then the <%if featured%> test will be true through all the pages, and that will show up on the top of all the pages.

http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/