Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How specify a link to a local PDF file


mrlake

Recommended Posts

Greetings,

 

What PHP code would I add to catalog\includes\languages\english\shipping.php to specify a link to a local PDF file such as catalog\my.pdf?

 

DETAILS

 

The demo osComm cart has an Information box in the left column. This box has a number of links, such as Shipping and Returns, Privacy Notice and so on. These links eventually display content from files such as

 

catalog\includes\languages\english\shipping.php

 

catalog\includes\languages\english\privacy.php.

 

By default, the code for these files look like this:

 

********* code sample ********

 

<?php

/*

$Id: privacy.php,v 1.4 2002/11/19 01:48:08 dgw_ Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2002 osCommerce

 

Released under the GNU General Public License

*/

 

********* code sample ********

 

define('NAVBAR_TITLE', 'Privacy Notice');

define('HEADING_TITLE', 'Privacy Notice');

 

define('TEXT_INFORMATION', 'Put here your Privacy Notice information.');

?>

 

What PHP code would I add to the file above specify a link to a local PDF file such as catalog\my.pdf?

Link to comment
Share on other sites

Thanks for your reply, Jonathan.

 

However, if I simply add a line similar to what you suggested, the file does not pass a PHP syntax check.

 

You suggested:

 

<a href="<?php echo tep_href_link('PATH_TO_YOUR_PDF_FILE'); ?>" target=_blank>YOUR_LINK_TEXT_HERE</a>

 

But when I added a similar line . . .

 

<a href="<?php echo tep_href_link('pdf/order_form_print.pdf'); ?>" target=_blank>Printable Order Form</a>

 

to the bottom of the code block below . . .

 

<?php
define('NAVBAR_TITLE', 'Printable Order Form');
define('HEADING_TITLE', 'Printable Order Form');

define('TEXT_INFORMATION', 'If you prefer to order by surface mail, click the link below to display a printable order form.');

<a href="<?php echo tep_href_link('pdf/order_form_print.pdf'); ?>" target=_blank>Printable Order Form</a>

?>

 

. . . and sent it to a PHP syntax-checker, I got this error:

 

Parse error: parse error in order_form.php on line 25

...

25: <a href="<?php echo tep_href_link('pdf/order_form_print.pdf'); ?>" target=_blank>Printable Order Form</a>

...

 

Suggestions?

Link to comment
Share on other sites

Folks,

 

I did some research and found that the tep_href_link function is a wrapper for most lnks in the osComm shopping cart. Apparently it preserves session IDs as users switch pages in the cart.

 

Now I think the error reported by the syntax checker I used (just a checker on a web site) happened because tep_href_link was not defined in the file I tested. It is defined in my production environment, however, so that error was not significant.

 

REQUESTS

1. Perhaps someone could point me to the doc that describes how to use the tep_href_link function. Or . . .

2. Perhaps someone could just take my code block below and make it right.

 

SOURCE FILE (custom file that contains the link I want to make)

catalog\includes\languages\english\order_form.php

 

This is page that displays when you click "Printable Order Form" in a custom box I added to the right column. When I include the HREF link below, I get a blank page. When I omit the link below, I get the appropriate page (Printable Order Form).

 

CODE IN THE SOURCE FILE

<?php
define('NAVBAR_TITLE', 'Printable Order Form');
define('HEADING_TITLE', 'Printable Order Form');

define('TEXT_INFORMATION', 'If you prefer to order by surface mail, click the link below to display a printable order form.');

<a href="<?php echo tep_href_link('pdf/order_form_print.pdf'); ?>" target=_blank>Printable Order Form</a>

?>

 

TARGET FILE (PDF I want to display from a link in shipping.php)

catalog\pdf\order_form.pdf

 

FYI . . . As far as I know, the path in the HREF link above is correct because "catalog" is assumed.

Link to comment
Share on other sites

Folks,

 

I did some research and found that the tep_href_link function is a wrapper for most lnks in the osComm shopping cart. Apparently it preserves session IDs as users switch pages in the cart.

 

Now I think the error reported by the syntax checker I used (just a checker on a web site) happened because tep_href_link was not defined in the file I tested. It is defined in my production environment, however, so that error was not significant.

 

REQUESTS

1. Perhaps someone could point me to the doc that describes how to use the tep_href_link function. Or . . .

2. Perhaps someone could just take my code block below and make it right.

 

SOURCE FILE (custom file that contains the link I want to make)

catalog\includes\languages\english\order_form.php

 

This is page that displays when you click "Printable Order Form" in a custom box I added to the right column. When I include the HREF link below, I get a blank page. When I omit the link below, I get the appropriate page (Printable Order Form).

 

CODE IN THE SOURCE FILE

<?php
define('NAVBAR_TITLE', 'Printable Order Form');
define('HEADING_TITLE', 'Printable Order Form');

define('TEXT_INFORMATION', 'If you prefer to order by surface mail, click the link below to display a printable order form.');

<a href="<?php echo tep_href_link('pdf/order_form_print.pdf'); ?>" target=_blank>Printable Order Form</a>

?>

 

TARGET FILE (PDF I want to display from a link in shipping.php)

catalog\pdf\order_form.pdf

 

FYI . . . As far as I know, the path in the HREF link above is correct because "catalog" is assumed.

 

What is the exact link to your PDF File?

Wade Morris

Amarillo, Texas

 

Before you do any changes on your site you need to do BACKUP! BACKUP!

Link to comment
Share on other sites

I could be totally wrong but I believe it's not working because you added the provided code in the wrong area of the page.

 

Instead place the code in the page like so:

<?php
define('NAVBAR_TITLE', 'Printable Order Form');
define('HEADING_TITLE', 'Printable Order Form');

define('TEXT_INFORMATION', 'If you prefer to order by surface mail, click the link below to display a printable order form. <br> <a href="<?php echo tep_href_link('pdf/order_form_print.pdf'); ?>" target=_blank>Printable Order Form</a>');

?>

 

Just my guess -- Mindy

Link to comment
Share on other sites

What is the exact link to your PDF File?

 

Wade,

 

The path in the link I posted is apparently correct because the link works if I move it outside of the previous PHP block, like this:

 

<?php
define('NAVBAR_TITLE', 'Printable Order Form');
define('HEADING_TITLE', 'Printable Order Form');

define('TEXT_INFORMATION', 'If you prefer to order by surface mail, click the link below to display a printable order form.');

?>

<a href="<?php echo tep_href_link('pdf/order_form_print.pdf'); ?>" target=_blank>Printable Order Form</a>

 

The link above opens the PDF. However, all not is not well because the link appears (unformatted) at the top of the page above all headers, not in the body where I need it.

 

Perhaps I need:

 

1. An alternative to the link code above that will work in the context of the first code block, so that the link will appear below the TEXT INFORMATION.

 

2. To include the link code above in the file that includes order_form.php. Just guessing here.

 

Will investigate and repost. Would like to hear any other suggestions.

Link to comment
Share on other sites

Wade,

 

The path in the link I posted is apparently correct because the link works if I move it outside of the previous PHP block, like this:

 

<?php
define('NAVBAR_TITLE', 'Printable Order Form');
define('HEADING_TITLE', 'Printable Order Form');

define('TEXT_INFORMATION', 'If you prefer to order by surface mail, click the link below to display a printable order form.');

?>

<a href="<?php echo tep_href_link('pdf/order_form_print.pdf'); ?>" target=_blank>Printable Order Form</a>

 

The link above opens the PDF. However, all not is not well because the link appears (unformatted) at the top of the page above all headers, not in the body where I need it.

 

Perhaps I need:

 

1. An alternative to the link code above that will work in the context of the first code block, so that the link will appear below the TEXT INFORMATION.

 

2. To include the link code above in the file that includes order_form.php. Just guessing here.

 

Will investigate and repost. Would like to hear any other suggestions.

 

 

It appears Mindy is correct in assessing that you put the link in the wrong location, her version of placement will not result in an error.

 

~~~Tapuahk

Link to comment
Share on other sites

Hi Mindy,

 

Just saw your post. If I include this link code . . .

 

<a href="<?php echo tep_href_link('pdf/order_form_print.pdf'); ?>" target=_blank>Printable Order Form</a>

 

. . . as shown in my previous posts, or as in your post, I always get a blank page. I was guessing that it is possible to include one <?php ?> block inside another, but none of the code put forth so far does it right. I was thinking that alternatives 1 or 2 from my last post to Wade might be a way to move forward.

Link to comment
Share on other sites

Hi Mindy,

 

Just saw your post. If I include this link code . . .

 

<a href="<?php echo tep_href_link('pdf/order_form_print.pdf'); ?>" target=_blank>Printable Order Form</a>

 

. . . as shown in my previous posts, or as in your post, I always get a blank page. I was guessing that it is possible to include one <?php ?> block inside another, but none of the code put forth so far does it right. I was thinking that alternatives 1 or 2 from my last post to Wade might be a way to move forward.

 

 

Okay try it this way once to do a reality check

 

define('TEXT_INFORMATION', 'If you prefer to order by surface mail, click the link below to display a printable order form. <br> <a href="/pdf/order_form_print.pdf" target=_blank>Printable Order Form</a>');

Link to comment
Share on other sites

Okay try it this way once to do a reality check

 

define('TEXT_INFORMATION', 'If you prefer to order by surface mail, click the link below to display a printable order form. <br> <a href="/pdf/order_form_print.pdf" target=_blank>Printable Order Form</a>');

 

Good grief! This works fine. Thanks, Allen!

 

You know, I tried the regular, old HREF call at first, but I must not have tried it like this. Jeez.

 

*

 

Just so I can salvage something high-minded out of this . . . May I assume that one lesson learned is that you cannot use "<?php echo tep_href_link" syntax in the context of a define TEXT_INFORMATION statement? Maybe because tep_href_link does not work in this context?

 

If that is an accurate generalization I'd be willing to add this somewhere in osComm doc, if someone could point me to the right person, guidelines, etc.

Link to comment
Share on other sites

Good grief! This works fine. Thanks, Allen!

 

You know, I tried the regular, old HREF call at first, but I must not have tried it like this. Jeez.

 

*

 

Just so I can salvage something high-minded out of this . . . May I assume that one lesson learned is that you cannot use "<?php echo tep_href_link" syntax in the context of a define TEXT_INFORMATION statement? Maybe because tep_href_link does not work in this context?

 

If that is an accurate generalization I'd be willing to add this somewhere in osComm doc, if someone could point me to the right person, guidelines, etc.

 

 

Thanks, but please forgive me for not offering that at right away, (I've been awake for over 24 hours so I'm low on resources)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...