Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 10-28-2003 10:13:49

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Product/category/page Name In Page Title

This is a mod to get the product/category/page name in the page title of the HTML pages generated dynamically by the program.  Please be aware that this does produce an additional query against the database and can cause a slow down on sites using CSV to store product/category data - especially if the data sets are large.  That said, open up the file ./cgi-bin/library/modules/ste_exec.pl for editing.  Look in the routine 'ste_exec' for:

Code:


&display_print('ste_layout');

Right above it, add this:

Code:


$page_title = "";

if ($fd_pg eq "ste_cat") {

$dbins_fd_ref = database_quote('category',$fd_ref);

$sql_statement = "

SELECT category_name
FROM category
WHERE category_id=$dbins_fd_ref

";

@title = database_call('category','SELECT',$sql_statement);

foreach $row(@title) {($page_title) = @$row;}

} elsif ($fd_pg eq "ste_prod") {

$dbins_fd_ref = database_quote('product',$fd_ref);

$sql_statement = "

SELECT product_name
FROM product
WHERE product_id=$dbins_fd_ref

";

@title = database_call('product','SELECT',$sql_statement);

foreach $row(@title) {($page_title) = @$row;}

} else {

if ($page_name ne "") {

$page_title = "$page_name";

} ######### End of if statement.

} ######### End of if statement.

if ($page_title ne "") {

$html_title_bar_text = "$page_title";

} ######### End of if statement.

If you want the regular page title in addition to the product/category/page name, instead of:

Code:


$html_title_bar_text = "$page_title";

In the above, use this:

Code:


$html_title_bar_text .= "- $page_title";


Nick Hendler

Offline

 

#2 10-28-2003 10:54:36

Lisaweb
Member
From: CA
Registered: 04-21-2003
Posts: 417

Re: Product/category/page Name In Page Title

Nick,

This is truely awesome!

I'd just need a tweak, because to get more info in these tags makes a big difference.

How can I get them to show up like this:   (Ref: $fieldnames)

<title>$sitename: $Category: $Product: </title>

(The Category & Product fields would only appear when applicable)

Also, I'd like to  my static meta description and use your mod instead.  How can I get the meta description to show up this below?

<meta name="description" content="$Category_description: $prod_description">

(The Category & Product description fields would only appear when applicable)

Thanks!
Lisa

Offline

 

#3 10-28-2003 14:24:41

Dan Pinder
Member
Registered: 09-11-2003
Posts: 27

Re: Product/category/page Name In Page Title

Nick, that is awesome! It works perfectly.

This will mean a lot more traffic, and targeted traffic at that.

Thank you!!

Offline

 

#4 10-29-2003 09:13:15

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Product/category/page Name In Page Title

Lisaweb-

It would be a bit different to get all that info:

Code:


$page_title = "";

if ($fd_pg eq "ste_cat") {

$dbins_fd_ref = database_quote('category',$fd_ref);

$sql_statement = "

SELECT category_name,category_desc
FROM category
WHERE category_id=$dbins_fd_ref

";

@title = database_call('category','SELECT',$sql_statement);

foreach $row(@title) {($page_title,$page_desc) = @$row;}

} elsif ($fd_pg eq "ste_prod") {

$dbins_fd_ref = database_quote('product',$fd_ref);

$sql_statement = "

SELECT product_name,product_desclong
FROM product
WHERE product_id=$dbins_fd_ref

";

@title = database_call('product','SELECT',$sql_statement);

foreach $row(@title) {($page_title,$page_desc) = @$row;}

$fd_cat = $q->param('cat');

if ($fd_cat ne "") {

$dbins_fd_cat = database_quote('product',$fd_cat);

$sql_statement = "

SELECT category_name,category_desc
FROM category
WHERE category_id=$dbins_fd_cat

";

@title = database_call('category','SELECT',$sql_statement);

foreach $row(@title) {($cat_title,$cat_desc) = @$row;}

if ($cat_title ne "") {

$page_title = "$cat_title\: $page_title";

} ######### End of if statement.

if ($cat_desc ne "") {

$page_desc = "$cat_desc\: $page_desc";

} ######### End of if statement.

} ######### End of if statement.

} else {

if ($page_name ne "") {

$page_title = "$page_name";

} ######### End of if statement.

} ######### End of if statement.

if ($page_title ne "") {

$html_title_bar_text = "$html_site_name\: $page_title";

} ######### End of if statement.

if ($page_desc ne "") {

$html_desc_text = "$page_desc";

} ######### End of if statement.

By using this code, you would need to add:

Code:


<meta name="description" content="(CGIVAR)html_desc_text(/CGIVAR)">

To your site layout.  This would get the decriptions in.  Also, the changed code above gets the category name in the title bar when found - at the cost of yet another SQL call.


Nick Hendler

Offline

 

#5 10-29-2003 10:49:00

Lisaweb
Member
From: CA
Registered: 04-21-2003
Posts: 417

Re: Product/category/page Name In Page Title

Beautiful!!!  (How can you code that so quickly?)

The Title is perfect.  I KNOW it is going to boost my ranking big-time.  I'll keep you posted on this.

However, I didn't realize it, but all the html I have in my product descriptions is wigging out my page when it's put into the meta-tag!  My mistake!

So I took out of my layout the tag:

Code:

<meta name="description" content="(CGIVAR)html_desc_text(/CGIVAR)">

Sorry to be such a bother, but anyway I can change only the meta-description back to descibing the category only?

Thanks!
Lisa

Offline

 

#6 10-29-2003 11:44:23

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Product/category/page Name In Page Title

Actually, you can strip all HTML from that tag like this.  Instead of:

Code:


if ($page_desc ne "") {

$html_desc_text = "$page_desc";

} ######### End of if statement.

Use:

Code:


if ($page_desc ne "") {

$html_desc_text = "$page_desc";
$html_desc_text =~ s/<[^>]*.//gs;

} ######### End of if statement.


Nick Hendler

Offline

 

#7 10-30-2003 05:19:56

Dan Pinder
Member
Registered: 09-11-2003
Posts: 27

Re: Product/category/page Name In Page Title

That is excellent nick!

I think the last thing that everyone is waiting for here would be to pull "search keywords" as well, so that it could be put/added into meta keywords.

:-) 

Offline

 

#8 10-30-2003 08:24:43

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Product/category/page Name In Page Title

Ok.  Applying *everything* that's been requested so far, here you go:

Code:


$page_title = "";

if ($fd_pg eq "ste_cat") {

$dbins_fd_ref = database_quote('category',$fd_ref);

$sql_statement = "

SELECT category_name,category_desc
FROM category
WHERE category_id=$dbins_fd_ref

";

@title = database_call('category','SELECT',$sql_statement);

foreach $row(@title) {($page_title,$page_desc) = @$row;}

} elsif ($fd_pg eq "ste_prod") {

$dbins_fd_ref = database_quote('product',$fd_ref);

$sql_statement = "

SELECT product_name,product_desclong,product_keywords
FROM product
WHERE product_id=$dbins_fd_ref

";

@title = database_call('product','SELECT',$sql_statement);

foreach $row(@title) {($page_title,$page_desc,$page_keywords) = @$row;}

$fd_cat = $q->param('cat');

if ($fd_cat ne "") {

$dbins_fd_cat = database_quote('product',$fd_cat);

$sql_statement = "

SELECT category_name,category_desc
FROM category
WHERE category_id=$dbins_fd_cat

";

@title = database_call('category','SELECT',$sql_statement);

foreach $row(@title) {($cat_title,$cat_desc) = @$row;}

if ($cat_title ne "") {

$page_title = "$cat_title\: $page_title";

} ######### End of if statement.

if ($cat_desc ne "") {

$page_desc = "$cat_desc\: $page_desc";

} ######### End of if statement.

} ######### End of if statement.

} else {

if ($page_name ne "") {

$page_title = "$page_name";

} ######### End of if statement.

} ######### End of if statement.

if ($page_title ne "") {

$html_title_bar_text = "$html_site_name\: $page_title";
$html_title_bar_text =~ s/<[^>]*.//gs;

} ######### End of if statement.

if ($page_desc ne "") {

$html_desc_text = "$page_desc";
$html_desc_text =~ s/<[^>]*.//gs;

} ######### End of if statement.

if ($page_keywords ne "") {

$html_keywords_text = "$page_keywords";
$html_keywords_text =~ s/<[^>]*.//gs;

} ######### End of if statement.

Now you can print the meta-description tag as:

Code:


<META NAME="description" CONTENT="(CGIVAR)html_desc_text(/CGIVAR)">

And the meta-keywords tag as:

Code:


<META NAME="keywords" CONTENT="(CGIVAR)html_keywords_text(/CGIVAR)">

And, as always, the title tag as:

Code:


<TITLE>(CGIVAR)html_title_bar_text(/CGIVAR)</TITLE>


Nick Hendler

Offline

 

#9 10-30-2003 10:04:49

Lisaweb
Member
From: CA
Registered: 04-21-2003
Posts: 417

Re: Product/category/page Name In Page Title

  I'm going to get busy implementing it right now...

Offline

 

#10 10-31-2003 09:09:36

Lisaweb
Member
From: CA
Registered: 04-21-2003
Posts: 417

Re: Product/category/page Name In Page Title

This is beautiful!   Now people will be able to find us! 

One more small request.....Sorry!  sad

The Search Engines (Barons of evil that they are) penalize for too long of a description in the meta-tag. Some of my descriptions are 600 - 1000 words long! 

Is there anyway to truncate the description to pull in just the first 150 characters or so?

If not, no biggy, I'll just change the code to grap from the keywords field for the description as well.

At any rate, I'm absolutely  about this mod! 



Lisa

Offline

 

#11 11-09-2003 16:17:18

lake
Member
Registered: 09-12-2003
Posts: 54

Re: Product/category/page Name In Page Title

Hi everyone,

i tried to implement this mod and all the shows up in the title bar is the title, I can't get the category or product name to show up. What could I be doing wrong?

i've changed the ste_exec.pl as well, per instructions. And still nothing -- only the title.

BTW, does that file have to be upload as ASCII or binary or does it matter?

thanks.

Offline

 

#12 11-09-2003 19:46:32

Lisaweb
Member
From: CA
Registered: 04-21-2003
Posts: 417

Re: Product/category/page Name In Page Title

The file needs to be uploaded in ascii.  Are you attempting this mod with 5.0 rather than 5.1 perhaps?

Also, check and Double check your changes.  And be reminded, the product and description only shows up if you are currently browsing a product.

Lisa

Offline

 

#13 11-09-2003 20:41:55

lake
Member
Registered: 09-12-2003
Posts: 54

Re: Product/category/page Name In Page Title

i have 5.1.

i've uploaded using ascii.

when nick wrote that the code is supposed to be put above &display_print('ste_layout'), that means before, correct? I'm doing a simple copy and paste.

i'll keep trying.

thanks.

Offline

 

#14 11-09-2003 21:24:13

lake
Member
Registered: 09-12-2003
Posts: 54

Re: Product/category/page Name In Page Title

i reverted the ste_exec.pl file back to its original and it made no difference. I get the same results.

Can someone post there ste_exec.pl file code so that I can use it and see if it makes a difference or compare it to what I was doing? That might help me to see where I have erred.

Thanks.

Offline

 

#15 11-10-2003 08:41:39

Lisaweb
Member
From: CA
Registered: 04-21-2003
Posts: 417

Re: Product/category/page Name In Page Title

Everytime I've uploaded a file I've made changes to, and the modified file produces absolutely no changes, I've always racked my brain, and then finally realized I've uploaded the file to the wrong folder or wrong area of the server.

Or, did you make sure and change (and upload) the ste_layout.txt file so that it included the new metatag code?

Code:

<META NAME="description" CONTENT="(CGIVAR)html_desc_text(/CGIVAR)">

<META NAME="keywords" CONTENT="(CGIVAR)html_keywords_text(/CGIVAR)"> 

Otherwise, it's not going so show up no matter how many changes you make to the ste_exec.pl  file.

Lisa

Offline

 

#16 11-10-2003 11:38:55

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Product/category/page Name In Page Title

To truncate that, change:

Code:


if ($page_keywords ne "") {

$html_keywords_text = "$page_keywords";
$html_keywords_text =~ s/<[^>]*.//gs;

} ######### End of if statement.

To:

Code:


if ($page_keywords ne "") {

$html_keywords_text = "$page_keywords";
$html_keywords_text =~ s/<[^>]*.//gs;

$html_keywords_text = vars_truncate($html_keywords_text,'150');

} ######### End of if statement.


Nick Hendler

Offline

 

#17 11-10-2003 11:59:40

lake
Member
Registered: 09-12-2003
Posts: 54

Re: Product/category/page Name In Page Title

thanks for your efforts.

yes, i've uploaded to the correct folder and the ste_layout.txt was updated and still nothing.

when I go to view source, after I've made the changes, the code reads:

<META NAME="keywords" CONTENT="">
<meta name="description" content="">

The title shows up correctly, but only the title, no category or product name

but in my ste_layout.txt I put in the correct meta codes.

The only other thing that i'm wondering is if the code is placed in the correct location in the ste_exec.pl

I copied and pasted it right before the code: &display_print('ste_layout'), is that correct?

thanks.

Offline

 

#18 11-10-2003 14:31:52

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Product/category/page Name In Page Title

Yes - that correct.  For the empty tags - they'll only have content in them on product & category pages.


Nick Hendler

Offline

 

#19 11-10-2003 18:18:02

lake
Member
Registered: 09-12-2003
Posts: 54

Re: Product/category/page Name In Page Title

that is what the source code looks like on the category and product pages of my site -- blank. empty. that's what I'm trying to say. The info is not showing up.

Visit and take a look.



thanks.

Offline

 

#20 11-10-2003 20:35:32

Lisaweb
Member
From: CA
Registered: 04-21-2003
Posts: 417

Re: Product/category/page Name In Page Title

Please copy the section in ste_layout.txt that is between your <Head> tags only and paste them into the post so we can take a look.  Thanks.  :-)

Offline

 

#21 11-11-2003 02:20:48

lake
Member
Registered: 09-12-2003
Posts: 54

Re: Product/category/page Name In Page Title

Here it is. Thanks.

<head>
<meta name="robots" content="all">
<meta name="MSSmartTagsPreventParsing" content="TRUE">
<meta name="robots" content="index, follow">
<meta name="Distribution" content="Global">
<meta name="Rating" content="General">
<meta name="revisit-after" content="5">
<meta name="keywords" content="skincare, skin care products, lavender skin care, organic,
scar healing, body care, aromatherapy, cruelty free, masks, cleansers, toners, astringents,
seaweed products, seaweed treatments, thalassotherapy, dry skin, acne skin, natural skin care, rosacea healing,
cellulite treatments, varicose veins,">
<meta name="description" content="(CGIVAR)html_desc_text(/CGIVAR)">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<TITLE>(CGIVAR)html_title_bar_text(/CGIVAR)</TITLE>
</head>

Offline

 

#22 11-11-2003 08:39:40

Lisaweb
Member
From: CA
Registered: 04-21-2003
Posts: 417

Re: Product/category/page Name In Page Title

lake,11/11/2003 02:20:48 AM wrote:

Here it is. Thanks.

<head>
<meta name="robots" content="all">
<meta name="MSSmartTagsPreventParsing" content="TRUE">
<meta name="robots" content="index, follow">
<meta name="Distribution" content="Global">
<meta name="Rating" content="General">
<meta name="revisit-after" content="5">
<meta name="keywords" content="skincare, skin care products, lavender skin care, organic,
scar healing, body care, aromatherapy, cruelty free, masks, cleansers, toners, astringents,
seaweed products, seaweed treatments, thalassotherapy, dry skin, acne skin, natural skin care, rosacea healing,
cellulite treatments, varicose veins,">
<meta name="description" content="(CGIVAR)html_desc_text(/CGIVAR)">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<TITLE>(CGIVAR)html_title_bar_text(/CGIVAR)</TITLE>
</head>

Hmmm.  Not sure if it will matter at all, but trying putting:

<meta name="description" content="(CGIVAR)html_desc_text(/CGIVAR)">

below the <title> tag instead of above it. 

If that doesn't work, please post ONLY a few lines above and a few lines below the code you inserted into ste_exec.pl

Lisa

Offline

 

#23 11-11-2003 09:12:30

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Product/category/page Name In Page Title

This has got to be in the site layout - not in a regular non-script-generated HTML page.  Are you sure you're using tiki and this is in the site layout element?


Nick Hendler

Offline

 

#24 11-11-2003 09:18:16

Lisaweb
Member
From: CA
Registered: 04-21-2003
Posts: 417

Re: Product/category/page Name In Page Title

I didn't think he was using a static page, as he said his <title> names still show up correctly.

Offline

 

#25 11-11-2003 14:15:32

lake
Member
Registered: 09-12-2003
Posts: 54

Re: Product/category/page Name In Page Title

Yes, i'm using tiki. I customized my site html layout. And the code that I posted was copied from the ste_layout.txt

here's the code from ste_exec.pl (with a few lines above and below the code)

P.S. I'm a "she" smile

Thanks for your help.


} ######### End of if statement.

if ($site_enable_daily_log eq "Y") {

&initialize_sub_require('ste_stats_daily_proc');
&ste_stats_daily_proc;

} ######### End of if statement.

#########
######### Display the site layout.  This is done for both regular
######### pages and forms.
#########

$element_id = "$page_id";

if ($page_id =~ /^ste_nolay_/) {

&display_print($page_id);

} else {

$page_title = "";


(the code that I inserted begins here)

$page_title = "";

if ($fd_pg eq "ste_cat") {

$dbins_fd_ref = database_quote('category',$fd_ref);

$sql_statement = "

SELECT category_name,category_desc
FROM category
WHERE category_id=$dbins_fd_ref


....

} ######### End of if statement.

if ($page_keywords ne "") {

$html_keywords_text = "$page_keywords";
$html_keywords_text =~ s/<[^>]*.//gs;

} ######### End of if statement.


&display_print('ste_layout')

Offline

 

Board footer