Gossamer Forum
Home : Products : Links 2.0 : Customization :

title_linked to display on add, modify, etc. pages

Quote Reply
title_linked to display on add, modify, etc. pages
Bobsie: I re-post this message, because UBB took out the <%title_linked%> from my subject Smile You can delete my 004677 thread.

How could I make <%title_linked%> available in the add, modify, search, etc. pages?
It should belong to & show the actual category, where the add.cgi was called.
I would like to appear the title_linked in the add, modify, etc. pages as similar as in the categories:
Category : subcategory1 : subcategory2 : etc.
Could anybody help me?

Thanks in advance,
Webmaster33

[This message has been edited by webmaster33 (edited January 19, 2000).]
Quote Reply
Re: title_linked to display on add, modify, etc. pages In reply to
1) Add the following codes in your add.cgi at the top of the sub process_form routine:

Code:
local ($title_linked);

Repeat this for the modify.cgi file. In the search.cgi file, put these codes in the sub main routine.

2) Add the following codes:

Code:
$title_linked = &build_linked_title ("Add Site");

Change Add Site to Modify Site or Search Pages (depending on the file you put this in).

Before the open DB codes.

3) Add your sub build_linked_title from the nph-build.cgi file to the add.cgi, modify.cgi, and search.cgi file.

4) Make sure you define <%title_linked%> in all the add, modify, and search sub-routines in the site_html_templates.pl file in the following manner:

Code:
title_linked => $title_linked,

If this works, let me know...because I may want to implement this in my scripts.

Good luck.

Regards,


------------------
Eliot Lee
Anthro TECH,L.L.C
http://www.anthrotech.com
Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
----------------------





Quote Reply
Re: title_linked to display on add, modify, etc. pages In reply to
Okay...I have played around with this and I have come up with a solution...

1) Add the following sub-routine in your db_utils.pl
file:

Code:
sub build_linked_cgi_title {
# --------------------------------------------------------
# Returns a string of the current category broken up
# by section, with each part linked to the respective section.

my $input = shift;
my (@dirs, $dir, $output, $last);

@dirs = split (/\//, $input);
$last = &build_clean(pop @dirs);

$output .= qq| <A HREF="$build_root_url/">Top</A> :|;
foreach $dir (@dirs) {
$output .= qq| <A HREF="$ENV{'SCRIPT_NAME'}">$dir</A> :|;
}
$output .= qq| <B>$last</B>|;

return $output;
}

You can change the HTML layout by editing and adding HTML codes between $output .= qq| and |;.

2) Replace the following codes in add.cgi file:

Code:
local (%in) = &parse_form;

With the following codes:

Code:
local (%in, $title_linked) = &parse_form;

3) Add the following codes after the local... codes
at the top of the sub main routine in the add.cgi
file:

Code:
$title_linked = &build_linked_cgi_title ("Add a Resource");

You can replace Add a Resource between the double
quotation marks to anything you want.

4) In the sub process_form routine add the following
codes at the top after the my...codes:

Code:
local ($title_linked);

5) Add the following codes before any of the &site_html_add_failure
calls:

Code:
$title_linked = &build_linked_cgi_title ("Add a Resource/Error: Unable to Process Form");

Again, you can edit the text between the double quotation marks.

6) Add the following codes before any of the &site_html_add_success
calls:

Code:
$title_linked = &build_linked_cgi_title ("Add a Resource/Submission Received");

Again, you can edit the text between the double quotation marks.

7) Define the <%title_linked%> tag in ALL of the ADD sub-routines in the site_html_templates.pl file:

Code:
title_linked => $title_linked,

8) Then in your ADD template files, add the following codes:

Code:
<%title_linked%>

BTW: These codes can be placed in similar manner in the other LINKS scripts, like modify.cgi, rate.cgi, search.cgi.

HOPE THIS HELPS.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
----------------------







[This message has been edited by Eliot (edited January 19, 2000).]
Quote Reply
Re: title_linked to display on add, modify, etc. pages In reply to
Eliot:
Your help was very useful, so Thank you very much for your help!

P.S.: Sorry for the duplicate thread. I explained why I was resent the question. I asked to delete the other post.
Quote Reply
Re: title_linked to display on add, modify, etc. pages In reply to
Good...Glad it worked.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
http://www.anthrotech.com
Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
----------------------





Quote Reply
Re: title_linked to display on add, modify, etc. pages In reply to
Eliot: Bad news... The foreach part of sub build_linked_cgi_title is not working:
foreach $dir (@dirs) {
$output .= qq| <A HREF="$ENV{'SCRIPT_NAME'}">$dir</A> :|;
}

I don't see from where @dirs comes. @dirs gets it's values from the input, and input is added here:
$title_linked = &build_linked_cgi_title ("Add a Resource");
So finally your mod results only the following: Top : Add a Resource

I tried correct the problem, but I wasn't able to make the it working, however I have an idea, how we could do it. I'm not professional, so now I can only write just a sketch. Smile
My version will do the following:

I will use HTTP_REFERER to find the current category:
------------
$referer = $ENV{'HTTP_REFERER'} =~ m,$build_root_url/(.+?)/?$,;
------------

I use nonenglish version, so I have to compare category names to the database:
------------
@dir = split ('/', @referer[0]); # separate the category names
$output .= qq| <A HREF="$build_root_url/">Top</A> :|;
MATCH:
I should look the line in category database, where |$referer| match, then split the line to get the fields.
I should get the nonenglish name from column 8: ($nonenglish) = @{$category{$subcat}}[8];
@referer = pop @referer # take out the last element from the list
repeat MATCH until all nonenglish values was assigned
LINK:
$output .= qq| <A HREF="$build_root_url$path/">$nonenglish</A> :|;
$i--;
repeat LINK until all link values was assigned
$output .= "Add a Resource";
display $output
------------

Unfortunately I don't know Perl & Links so much (yet) to write it,
but I hope the sketch above is close to the desired effect.
Eliot: Could you help to correct this mod?
If you have better idea, than the sketch above, let me know.

Webmaster33

[This message has been edited by webmaster33 (edited January 20, 2000).]
Quote Reply
Re: title_linked to display on add, modify, etc. pages In reply to
The @dir array uses directories with / marks in the code to denote a separate menu page:

like with the example of the $title_linked using the &build_title_cgi_linked routines,

when I put:

("Add a Resource");

This is the main directory title!

Then when I put:

("Add a Resource/Error: Unable to Process Form");

This puts the codes in the HTML page:

Top: Add a Resource: Error Unable to Process Form

Using the non-english mod doesn't matter. All you have to do is change the title names of the directory title.

Also, the sub-routine I gave you, you will noticed that it does use Top codes like in your other web pages, and then prints directories BASED on what I just wrote about.

Also, the "Mod" I gave you does not print Category names nor is it that easy to print category names from where you came from.

For example:

I am in the following category:

Perl/Learning_is_key

I click on "Add Site". In order to "print" a link to Perl/Learning_is_key, I would have to add an environmental variable link, like the following:

Code:
<a href="$ENV{'HTTP_REFERRER'}">Previous Page</a>

But to replace Previous Page with a category name would be very challenging to do.

Hope this helps.

Cheers,


------------------
Eliot Lee
Anthro TECH,L.L.C
http://www.anthrotech.com
Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
----------------------





Quote Reply
Re: title_linked to display on add, modify, etc. pages In reply to
>But to replace Previous Page with a category name would be very challenging to do.
Well, this is exactly, what I would like to do. I wrote a sketch in my previous message, how I plan to make it.
It's really a challenge to write it, but I don't think it's impossible.
The basics of it is, to determine the current category from HTTP_REFERER, then to compare it to the database.
This way we identified the right category in database, so we can make links as usually made on the category pages.

Do you see the idea?
What do you think about it?

Webmaster33
Quote Reply
Re: title_linked to display on add, modify, etc. pages In reply to
I see your idea...I said was challenging, not impossible. I think I can come up with something based on the Recommend It! Mod, which Bobsie wrote...It uses codes to pull Titles from the links.db, but there are some codes in the default birdcast.cgi file that pulls the title of the previous page.

However, the codes I will be providing will print out the title bar in the following manner:

Code:
Top: Category Page : Add Resource

OR

Code:
Top: Category Page : Add Resource : Error Message

This is what you want, RIGHT?

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
http://www.anthrotech.com
Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
----------------------





Quote Reply
Re: title_linked to display on add, modify, etc. pages In reply to
Yes, right.
Top: Category Page : Add Resource
or
Top: Category Page : Add Resource : Error Message
Quote Reply
Re: title_linked to display on add, modify, etc. pages In reply to
Well, I will see what I come up with.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
http://www.anthrotech.com
Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
----------------------





Quote Reply
Re: title_linked to display on add, modify, etc. pages In reply to
Thanks, Eliot!
I will also try something, but I don't trust my knowledge too much Smile At least I try to learn something Smile

Webmaster33
Quote Reply
Re: title_linked to display on add, modify, etc. pages In reply to
I have come a little bit closer to a possible solution. I found some codes in the Perl/CGI Forum in the following Thread:

http://www.gossamer-threads.com/...um8/HTML/000461.html

It does not seem to do exactly what you or I want...but it is a step closer to the final solution....

Add the following codes at the top of the sub build_title_cgi_linked:

Code:
use URI::URL;
my $doc_root = '/mnt/web/guide/anthrotech/vlib';
my $url = new URI::URL $ENV{'HTTP_REFERER'};
my $path = $url->path;
($path and (-e "$doc_root/$path")) or cgierr ("Unkown file: $path");
my $title;
open (FILE, "$doc_root/$path") or cgierr ("open: $!");
while (<FILE> ) {
m,<title>(.+?)</title>, or next;
m,<TITLE>(.+?)</TITLE>, or next;
($title = $1) and last;
}
close FILE;
$title &#0124; &#0124;= 'Previous Page';

AFTER the following codes:

Code:
$last = &build_clean(pop @dirs);

2) Then add the following codes after the Top: codes:

Code:
<A HREF="$ENV{'HTTP_REFERER'}">$title</a>

Again, it the only thing that prints is Previous Page.

Regards,
Make sure that you close the space between the two |.

------------------
Eliot Lee
Anthro TECH,L.L.C
http://www.anthrotech.com
Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
----------------------





Quote Reply
Re: title_linked to display on add, modify, etc. pages In reply to
Yippy-yippy-yeeeee... I made it & works!
Finally I made it with my own logic, however I'm very grateful for your solutions.
They helped me to see the problem from different viewpoints.

The only place I changed, is site_html_templates.pl, where I used features already exists + I added a new mod sub.
(of course it works with non-english names, too)

I will post the mod, when I finish implementing & testing into modify, search, etc.
Please allow me a week, because I'm doing the other developing jobs, too.
(but if you really need it sooner, I can post the core of it)

Best regards,
Webmaster33
Quote Reply
Re: title_linked to display on add, modify, etc. pages In reply to
I don't really need it. Just something else to make my cgi scripts consistent with my other pages (without manually adding HTML codes).

But I would like to see what you came up with!

Smile

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
----------------------







[This message has been edited by Eliot (edited January 20, 2000).]
Quote Reply
Re: title_linked to display on add, modify, etc. pages In reply to
Ok. Smile
I will post it as I finish the full mod.

Webmaster33