Forums / General Questions / include link help needed

include link help needed

Started by goshawk on 14 Oct 2011, 12:29 AM · Views: 643

Results 1 to 5 of 5
14 Oct 2011, 12:29 AM
#1
goshawk avatar

goshawk

Zen Follower

Join Date:
Aug 2006
Location:
Kihikihi, New Zealand
Posts:
220
Plugin Contributions:
2

include link help needed

Hi all,

I am trying to clean up my product details in my database as much general information is included for each listing.

I propose to create a new custom page in the languages directory (like about-us) say products_general_info.php and include this in the product view page after the specific product information.

What would be the correct link in the require(); statement to allow this information to display in the correct language.

something like this????

require($template->get_template_dir('products_general_info.php',DIR_WS_TEMPLATE, $current_page_base,'pages'). '/products_general_info.php');

Many thanks,

Goshawk

Time is but an illusion, there is only "now"!

14 Oct 2011, 12:35 AM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: include link help needed

Yiour best bet is probably to use swguy's boilerplate file technique to draw the general info from HTML files you create. (Post 6 in the thread referenced.)

14 Oct 2011, 1:21 AM
#3
goshawk avatar

goshawk

Zen Follower

Join Date:
Aug 2006
Location:
Kihikihi, New Zealand
Posts:
220
Plugin Contributions:
2

Re: include link help needed

Thanks gjh42 for your reply.

I propose to place the link in the tpl_product_info_display.php file at the end of this code:

<!--bof Product details list  -->
<?php if ( (($flag_show_product_info_model == 1 and $products_model != '') or ($flag_show_product_info_weight == 1 and $products_weight !=0) or ($flag_show_product_info_quantity == 1) or ($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name))) ) { ?>
<ul id="productDetailsList" class="floatingBox back">
  <?php echo (($flag_show_product_info_model == 1 and $products_model !='') ? '<li>' . TEXT_PRODUCT_MODEL . $products_model . '</li>' : '') . "\n"; ?>
  <?php echo (($flag_show_product_info_weight == 1 and $products_weight !=0) ? '<li>' . TEXT_PRODUCT_WEIGHT .  $products_weight . TEXT_PRODUCT_WEIGHT_UNIT . '</li>'  : '') . "\n"; ?>
  <?php echo (($flag_show_product_info_quantity == 1) ? '<li>' . $products_quantity . TEXT_PRODUCT_QUANTITY . '</li>'  : '') . "\n"; ?>
  <?php echo (($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name)) ? '<li>' . TEXT_PRODUCT_MANUFACTURER . $manufacturers_name . '</li>' : '') . "\n"; ?>
</ul>
<br class="clearBoth" />
<?php
  }
?>
<!--eof Product details list -->

So not in the html created from the database.

It should be possible just to place a include/require statement before the ?> that loads the additional file.

Goshawk

Time is but an illusion, there is only "now"!

14 Oct 2011, 3:33 AM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: include link help needed

Is there just one file that you want to include in every product? Then your idea is sound and will work easily.

If you have various stock texts that you want to insert in different products, then the boilerplate concept may be better. I have developed a variant of swguy's method that can be used to insert as many stock text/HTML chunks as desired into whatever part of the product info page is wanted, triggered by an HTML comment in the description. All it requires is putting a function call into the file in the place desired. I haven't submitted it to Free Addons yet, but I will attach it here if you would like to try it.

What would be the correct link in the require(); statement to allow this information to display in the correct language.$_SESSION['language'] will get the current language, and can be used in a file lookup.
Why are you planning to require a PHP file? Is it going to need PHP manipulation and processing to output the HTML you will want to display? If you are only going to want one piece of text/HTML in this location, you can define that as a constant in a language file (one for each language you are using)php define('PRODUCT_GENERAL_INFO_TEXT', '<div class="boilerplate"><p class="generalSection">This is a bunch of general product information.</p><p>It is long and repetitious and the same on every product.</p></div>'); and echo the constant where you want it:```php

<!--eof Product details list --> <?php echo PRODUCT_GENERAL_INFO_TEXT;?>
14 Oct 2011, 6:22 AM
#5
goshawk avatar

goshawk

Zen Follower

Join Date:
Aug 2006
Location:
Kihikihi, New Zealand
Posts:
220
Plugin Contributions:
2

Re: include link help needed

Thanks gjh42,

I will try this method, as 90% of my products have the same info attached.

For the other few products the information would not distract from the listing.

I will however again look closer at swguy's boilerplate file technique as it will give some future proofing if new prodicts need to be added.

Goshawk

Time is but an illusion, there is only "now"!