Author Topic: [Solved] Include one file from virtuemart into another component.  (Read 1731 times)

yiun

  • Beginner
  • *
  • Posts: 5
I want to include a file from virtuemart via "require_one()" into another component.
But when I do that I just getting a white page on my website.

In the file /components/com_test/test.php is the line:
require_once(JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_virtuemart' . DS . 'classes' . DS . 'ps_product.php');

The file "ps_product.php" definitly exists. When I remove the content it works without any problems. It seems there is a problem with the references in the file "ps_products" (CLASSPATH e.g.).

I'm greatful for any help.

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10437
  • VirtueMart Version: 3+
Re: Include one file from virtuemart into another component.
« Reply #1 on: June 09, 2011, 21:24:37 pm »
You are going to have to load more than that

in one of my modules they load this
// Load the virtuemart main parse code
if( file_exists(dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' )) {
   require_once( dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' );
   $mosConfig_absolute_path = realpath( dirname(__FILE__).'/../..' );
} else {
   require_once( dirname(__FILE__).'/../components/com_virtuemart/virtuemart_parser.php' );
}

yiun

  • Beginner
  • *
  • Posts: 5
Re: Include one file from virtuemart into another component.
« Reply #2 on: June 10, 2011, 14:25:36 pm »
Thanks for the fast reply!

First I have activate the debug in the file php.ini by changing

Code: [Select]
error_reporting = E_ALL & ~E_NOTICE
to
error_reporting = E_ALL | E_STRICT

and

Code: [Select]
display_errors = Off
to
display_errors = On

So I was getting different errors which help me to find the solution.
When you want to use the virtuemart-classes you have to include "virtuemart_parser.php" first. Just add the following on the top of your file:
Code: [Select]
require_once( JPATH_SITE.DS.'components' . DS . 'com_virtuemart' . DS . 'virtuemart_parser.php');