First module help needed

I am trying to create a price quotation module.

So far i have in my
page -> details -> details.tpl divs where my sucess failure message should appear

  • roughly copied from pricealarmstatus.

I have in my tabs.tpl an include for my form in a new tab (not sure how to move that include into my module)
in my form i have


<input type="hidden" name="cl" value="[{$oViewConf->getActiveClassName()}]"/>
<input type="hidden" name="fnc" value="send"/>

In my module metadata i have

'extend'       =&gt; array(
    'oxEmail' =&gt; 'anfrage/extendedoxEmail',
  'details' =&gt; 'anfrage/views/anfrage'
)

I have then an anfrage view which extends the details view and contains the following

<?php
class Anfrage extends Details
{
/** Anfrage status.
* @var integer
*/
protected $_AnfrageStatus = null;

/**
 * Composes and sends Anfrage written message, returns false if some parameters are missing.
 *
 * @return bool
 */
public function send()
{
    $myConfig = $this-&gt;getConfig();
    $myUtils  = oxUtils::getInstance();

    //control captcha
    $sMac     = oxConfig::getParameter( 'c_mac' );
    $sMacHash = oxConfig::getParameter( 'c_mach' );
    $oCaptcha = $this-&gt;getCaptcha();
    if ( !$oCaptcha-&gt;pass( $sMac, $sMacHash ) ) {
        $this-&gt;_iAnfrageStatus = 2;
        return;
    }

    $aParams = oxConfig::getParameter( 'editval' );
    if ( !isset( $aParams['oxuser__oxusername'] ) || !$myUtils-&gt;isValidEmail( $aParams['oxuser__oxusername'] ) ) {
        $this-&gt;_iAnfrageStatus = 0;
        return;
    }

    $aParams['aid'] = $this-&gt;getProduct()-&gt;getId();

    $sSubject = oxConfig::getParameter( 'c_subject' );
    $sMessage  = $aParams['oxuser__oxlname'] . "(" .$aParams['oxuser__oxusername'] . ")&lt;br /&gt;
  			 Company: ".$aParams['oxuser__oxcname'] ."&lt;br /&gt;".
  			 nl2br( oxConfig::getParameter( 'c_message' ) );
  

    // Send Email
    $oEmail = oxNew( 'extendedoxEmail' );

$oEmail->sendAnfrageMail( $aParams, $sSubject);

}


/**
 * Return anfrage status (if it was sent)
 *
 * @return integer
 */
public function getAnfrageStatus()
{
    return $this-&gt;_iAnfrageStatus;
}

}

Should basically just send a mail. - i’ve kicked out error reporting at the moment, while trying to get it to work. This is being called (when you add a render function you can see that)

I also have my extended email

<?php
class extendedoxEmail extends oxEmail {

public function sendAnfrageMail( $aParams, $sSubject = null )
{
    $this-&gt;_clearMailer();
    $oShop = $this-&gt;_getShop();

    //set mail params (from, fromName, smtp)
    $this-&gt;_setMailParams( $oShop );
  $oLang = oxLang::getInstance();

    $this-&gt;setRecipient( $oShop-&gt;oxshops__oxorderemail-&gt;value, $oShop-&gt;oxshops__oxname-&gt;getRawValue() );
    $this-&gt;setSubject( ( $sSubject !== null ) ? $sSubject : $oArticle-&gt;oxarticles__oxtitle-&gt;getRawValue() );

  $this-&gt;setBody( 'bing bon bang');
    $this-&gt;setFrom( $aParams['oxuser__oxusername'], "" );
    $this-&gt;setReplyTo( $aParams['oxuser__oxusername'], "" );

    return $this-&gt;send();
}

}

Getting the following error

oxSystemComponentException-oxException (time: 2012-11-02 15:52:40): [0]: EXCEPTION_SYSTEMCOMPONENT_CLASSNOTFOUND
Stack Trace: #0 /var/www/vhostscore/oxutilsobject.php(125): oxUtilsObject->_getObject(‘oxsystemcompone…’, 0, Array)
#1 [internal function]: oxUtilsObject->oxNew(‘oxSystemCompone…’)
#2 /var/www/vhostscore/oxfunctions.php(314): call_user_func_array(Array, Array)
#3 /var/www/vhostscore/oxutilsobject.php(115): oxNew(‘oxSystemCompone…’)
#4 [internal function]: oxUtilsObject->oxNew(‘extendedoxEmail’)
#5 /var/www/vhostscore/oxfunctions.php(314): call_user_func_array(Array, Array)
#6 /var/www/vhostsmodules/anfrage/views/anfrage.php(55): oxNew(‘extendedoxEmail’)
#7 /var/www/vhostsviews/oxview.php(518): Anfrage->send()
#8 /var/www/vhostsviews/oxshopcontrol.php(312): oxView->executeFunction(‘send’)
#9 /var/www/vhostsviews/oxshopcontrol.php(114): oxShopControl->_process(‘details’, ‘send’)
#10 /var/www/vhostsindex.php(103): oxShopControl->start()
#11 {main}

Faulty component –> extendedoxemail

Can someone tell me why ?

The “extends” array is used for extending existing classes in a transparent way, e.g. you call oxNew( ‘oxEmail’ ); and instead of oxEmail your class is used. Every call to oxNew( ‘oxEmail’ ); will load your class instead of the original one. The correct header would be in this case: class extendedoxEmail extends extendedoxEmail_parent.

If you do not want to replace oxEmail in every place, instead only when called explicitly with oxNew( ‘extendedoxEmail’ );, you have to remove it from extends array and put it into “files” array to tell the autoloader about it:http://wiki.oxidforge.org/Features/Extension_metadata_file#files
In this case header is correct.

PS: please format code with php-code tags, much easier to read.:wink:

thanks - that makes sense and works :slight_smile:

i do have two other questions mind you…

  1. Why after i have submitted the form, do i redirect to the same page, but now with “index.php?” in the address bar, instead of my nice seo address, well i know why, but can i avoid it ?
  2. Whats the correct “module” way of dealing my anfrage form ?
    Should i create a folder “form” in my module, pack it in there and then use files or blocks ?
    And if use blocks, i suppose i still have to edit the tabs tmp file ?

edit: and apologies about the formatting, thought code was ok

[QUOTE=soup;106886]

  1. Why after i have submitted the form, do i redirect to the same page, but now with “index.php?” in the address bar, instead of my nice seo address, well i know why, but can i avoid it ?
    [/QUOTE]

There is a function you can use that will try to fetch the SEO equiv of any url. I think it’s available through oxconfview. If not, you can make it available through the applicable controller class. Search the documentation for a functions with ‘SEO’ and ‘url’ in their name.

[QUOTE=soup;106886]thanks - that makes sense and works :slight_smile:
2. Whats the correct “module” way of dealing my anfrage form ?
Should i create a folder “form” in my module, pack it in there and then use files or blocks ?
And if use blocks, i suppose i still have to edit the tabs tmp file ?
[/QUOTE]

Ideally, for the sake of easier maintenance, you would extend/replace existing TPL blocks by creating an appropriate file under modules/your_module/out/blocks/ and then making an associated entry in metadata.php, but this is not always possible. If you have to override the template completely, I think a new theme (based on the existing one) is the most ‘proper’ way. There are tutorials on both of these topics in the wiki tutorials.