Gossamer Forum
Home : Products : Links 2.0 : Customization :

Review.cgi: converting a LinkID to an actual title...

Quote Reply
Review.cgi: converting a LinkID to an actual title...
I have not been able to pull from a given LinkID in the review DB the title of the link in link DB. I have tried a thousand iterations based on get_reviews code in site_html_templates, but could use a fresh set of eyes on the problem.
Quote Reply
Re: Review.cgi: converting a LinkID to an actual title... In reply to
I know there must be a better way but here is what I have.

in site_html_template add
Code:
sub html_link_listing {
# --------------------------------------------------------
# This routine is used to display what a link listing should look
# like.

my %rec = @_;

return &load_template ('linklisting.html', {
detailed_url => "$build_detail_url/$rec{'ID'}$build_extension",
%rec,
%globals
});
}

make a template for you title. (can include any of the resource's info, just title or linked title) If you want to include the new and pop images, you'd have to add some code above. Just look at sub site_html_link

then slap this in the cgi where you need the title

Code:
print &html_link_listing (&get_record($ID));
replacing the $ID with whatever variable you have for the ID num.

or $ResourceTitle = &html_link_listing (&get_record($ID));

try it and see if it will work for you. the cgi where you add this code will wave to require


require "/path/to/links.cfg";
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";
require "$db_lib_path/site_html_templates.pl";


If you come up with something cleaner which just changes id # to title, I'd like the snippet of code
Thanx


------------------
http://bartour.hypermart.net
Quote Reply
Re: Review.cgi: converting a LinkID to an actual title... In reply to
Very cool! Thanks. I will email you directly when I finish my project, which is 99.99% complete.
Quote Reply
Re: Review.cgi: converting a LinkID to an actual title... In reply to
OK, not as close as I thought. When I explicitly require links.def in my sub html_link_listing, the get_record works as expected since proper db_cols definitions are being built. However, by requiring links.def, a loop in my main sub terminates (e.g. gets confused with review.def and links.def). I'm kind of over my head here... to my knowledge, I can't re-require review.def, or "release" links.def. Maybe the solution is not to require links.def in the first place, and build my db_cols definitions from scratch in the sub itself... ???

<update>
I put aside the get_record solution (with troublesome double requires) and kludged together a RegEx of my Links DB. It works Smile, but is "hardcoded" to extract only the title... with a little more thought, perhaps it could be extended to pull out any field given the LinkID from the Review DB.

For those interested, here is the code... no link.def call required. Wherever you need to grab a title, put <%Title%> in your template and the following in the appropriate sub (in the return &load_template part).
Code:
Title => &get_title ($rec{'LinkID'}),
Add the following somewhere in your site_html_template.pl file.
Code:
sub get_title {
# --------------------------------------------------------
# This routine is used to grab a link title given a review link ID
my ($id) = @_;
%globals;
my ($title, $returntitle);
$data_file = "/explicit/path/to/your/links.db";
open (FILE,"<$data_file") or &cgierr ("Can't open review file '$data_file'. Reason: $!");
LINE: while (<FILE> ) {
if ($_ =~ m/^($id)\|(.+?)\|/mg) { $title = $2; }
}
close FILE;
$returntitle = qq~
<a class="link" href="$build_detail_url/$id$build_extension">$title</a>
<a class="link" href="$db_cgi_url/jump.cgi?ID=$id">$title</a>
~;
return $returntitle;
}

[This message has been edited by oldmoney (edited December 29, 1999).]
Quote Reply
Re: Review.cgi: converting a LinkID to an actual title... In reply to
Opps, posted to soon.

This worked for me when I wrote my MyLinks script but didn't work in my current project. I had the same problem you did. I was able to slightly mod yours to work in my situation. Thanx!! Now doing a search for review by a user works beautifuly. I guess i'll have to work on the "edit a review" next.

http://bartour.hypermart.net/...cgi/review.cgi?ID=11

------------------
http://bartour.hypermart.net
Quote Reply
Re: Review.cgi: converting a LinkID to an actual title... In reply to
mutt.. you're site is pretty cool Smile

i like what you've done with review.cgi..

but this image is TOO COOL..

http://bartour.hypermart.net/ubb/avatar/face36.gif

hehe.. Smile

jerry
Quote Reply
Re: Review.cgi: converting a LinkID to an actual title... In reply to
Thanx!
Quote Reply
Re: Review.cgi: converting a LinkID to an actual title... In reply to
Hi!

Mutt and/or Widgetz: I want to use your pretty cool mod, but I can't use the install.cgi! The LWP module use is not allowed at my provider. Frown
Would you please be so kind and pass me your perl-scripts per email? This would be really great! Maybe as great as your scripts Smile

Good luck for 2000
Stefan

------------------
visit Juhu!Katzen!
http://www.juhukatzen.de/

[This message has been edited by stefang (edited December 29, 1999).]
Quote Reply
Re: Review.cgi: converting a LinkID to an actual title... In reply to
I'm pretty sure widgetz's has already addressed this. it's his mod. go back thru the the review.cgi posts. (there are alot of em)
Quote Reply
Re: Review.cgi: converting a LinkID to an actual title... In reply to
there was one post.. to i beleive someone named michelle (i don't know how i remembered that..)

anyways.. i explained what the LWP did to get the code from my site.. and gave instructions on what to do.. it's not an easy process..

i'm about to throw review.cgi v1 in the dumps and not support it any longer as review.cgi v2 for Links SQL is just about ready..

jerry
Quote Reply
Re: Review.cgi: converting a LinkID to an actual title... In reply to
In Reply To:
For those interested, here is the code... no link.def call required. Wherever you need to grab a title, put <%Title%> in your template and the following in the appropriate sub (in the return &load_template part).


code:
--------------------------------------------------------------------------------

Title => &get_title ($rec{'LinkID'}),

--------------------------------------------------------------------------------
I can't work out which sub I'm supposed to put this in?

Simon



Quote Reply
Re: Review.cgi: converting a LinkID to an actual title... In reply to
Hello? Anyone gonna offer me some help? Pretty Please?

Simon Dyson

Quote Reply
Re: Review.cgi: converting a LinkID to an actual title... In reply to
Hi... not on the boards here too much these days, but by sheer coincidence, I saw your post. You really won't need to implement the code I showed earlier unless you are customizing how Links works with Widegetz' Review mod. The best advice I can give you is that the title definition will need to be called where ever you are calling on the Review mod (for example, pulling new reviews into What's New).

Quote Reply
Re: Review.cgi: converting a LinkID to an actual title... In reply to
I have tried to use this mod to add the title into the email message the reviewer gets. I thus inserted the sub into the bottom of the admin_html.cgi file and the other bit into the &load_template refering to the review-add.txt file. Then when a review is validated the email has this in it:

HASH(0xe93c04)

I think my error is in this bit, let me know if I have done something wrong:

Code:
my $msg = &load_template ('review-add.txt', \%link, {
Title => &get_title ($rec{'LinkID'})
});