Jump to content

module development


secrethost

Recommended Posts

Hey I am writing a module based on minictutorial.

http://module.minic.ro/how-to-create-a-prestashop-module-tutorial/

I installed the core module, and did the development.

Then I zippet the code module and uploaded the zippet module, to a new prestashop, the file is uploaded to the server in the module library, and it got it's own library, but when I push install, I get the follow-ring error .

 

Here is the error ??

 Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\prestashop4\classes\module\Module.php(1096) : eval()'d code on line 1

The following module(s) could not be loaded::
  1. minictutorialA (parse error in /modules/minictutorialA/minictutorialA.php)
  2. minictutorialA (class missing in /modules/minictutorialA/minictutorialA.php)

 

Here is the code

 

<script src="../modules/minictutorial/ckeditor/ckeditor.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php

/*
* minicskeleton - a module template for Prestashop v1.5+
* Copyright © 2013 S.C. Minic Studio S.R.L.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* http://module.minic.ro/how-to-create-a-prestashop-module-tutorial/
* http://doc.prestashop.com/display/PS15/Creating+a+PrestaShop+module
*/

if (!defined('_PS_VERSION_'))
exit;

class minictutorial extends Module {
// DB file

const INSTALL_SQL_FILE = 'install.sql';

public function __construct() {
$this->name = 'minictutorialA';
$this->tab = 'secrethostA';
$this->version = '1.0';
$this->author = 'secrethostA';
$this->need_instance = 0;
$this->ps_versions_compliancy = array('min' => '1.5', 'max' => '1.6');
// $this->dependencies = array('blockcart');

parent::__construct();

$this->displayName = $this->l('secretsmsA');
$this->description = $this->l('A module to send sms and email newsletters2.');

$this->confirmUninstall = $this->l('Are you sure you want to uninstall?');
}

/**
* install
*/
public function install() {
// Create DB tables - uncomment below to use the install.sql for database manipulation
/*
if (!file_exists(dirname(__FILE__) . '/' . self::INSTALL_SQL_FILE))
return false;
else if (!$sql = file_get_contents(dirname(__FILE__) . '/' . self::INSTALL_SQL_FILE))
return false;
$sql = str_replace(array('PREFIX_', 'ENGINE_TYPE'), array(_DB_PREFIX_, _MYSQL_ENGINE_), $sql);
// Insert default template data
$sql = str_replace('THE_FIRST_DEFAULT', serialize(array('width' => 1, 'height' => 1)), $sql);
$sql = str_replace('FLY_IN_DEFAULT', serialize(array('width' => 1, 'height' => 1)), $sql);
$sql = preg_split("/;\s*[\r\n]+/", trim($sql));

foreach ($sql as $query)
if (!Db::getInstance()->execute(trim($query)))
return false;
*/

if (!parent::install() ||
!$this->registerHook('displayHome') ||
!$this->registerHook('displayHeader') ||
!$this->registerHook('displayBackOfficeHeader') ||
!$this->registerHook('displayAdminHomeQuickLinks') ||
!$this->registerHook('ActionOrderStatusUpdate'))
return false;
return true;
}

/**
* uninstall

public function uninstall() {
if (!parent::uninstall())
return false;
return Db::getInstance()->execute('DROP TABLE ' . _DB_PREFIX_ . 'minicskeleton');
}
*/
public function uninstall()
{
if (!parent::uninstall())
return false;
return true;
}

/**
* admin page
*/
public function getContent() {
//admin

//$visTplFile1 = $this->display(__FILE__, 'views/templates/admin/minictutorial.tpl');
//$visTplFile2 = $this->display(__FILE__, 'views/templates/admin/header.tpl');
//$visTplFile3 = $this->display(__FILE__, 'views/templates/admin/invoice.tpl');

if (($_POST['news']) == "news_both" || ($_POST['news']) == "news_sms" || ($_POST['news']) == "news_mail") {

if (Tools::isSubmit('sendnewsletter')) {

$sh_newsl_tekst = $_POST['editor1'];

if (($_POST['news']) == "news_both" || ($_POST['news']) == "news_mail") {

//echo $sh_newsl_tekst;

$sql = 'SELECT `mail`,`sms` FROM ' . _DB_PREFIX_ . 'minicskeleton';

if ($result = Db::getInstance()->ExecuteS($sql)) {

foreach ($result as $row) {
$sh_a[] = $row['mail'];
}
}
$recipients = implode(', ', $sh_a);

$to = '[email protected]';
$subject = "E-mail subject test2";
$body = $sh_newsl_tekst;
$headers = 'From: server.dk' . "\r\n";
$headers .= 'Reply-To: [email protected]' . "\r\n";
$headers .= 'BCC: ' . $recipients . "\r\n";

mail($to, $subject, $body, $headers);
echo 'Der blev sendt en email.';
}
if (($_POST['news']) == "news_both" || ($_POST['news']) == "news_sms") {

$sql = 'SELECT `mail`,`sms`,`apikey` FROM ' . _DB_PREFIX_ . 'minicskeleton';

if ($result = Db::getInstance()->ExecuteS($sql)) {

foreach ($result as $row) {

//file_get_contents("http://api.sms.dk/sms/[email protected]&apiKey=6cde66a012e734e5291224da432bb42f&from=anders&dialcode=45&recipient=.'$row[mail]'.&text=.'$sh_newsl_tekst'.");

$urlencode_sh_newsl_tekst = urlencode($sh_newsl_tekst);

file_get_contents("http://api.sms.dk/sms/send.php?email=$row[mail]&apiKey=$row[apikey]&from=anders&dialcode=45&recipient=$row[sms]&text=$urlencode_sh_newsl_tekst");
}
}
//echo '
Der blev sendt en sms';
}
}
}

if (Tools::isSubmit('sms_setup')) {

$sms_name = $_POST['sms_navn_send'];
//$sms_apikey = "6cde66a012e734e5291224da432bb42f";
$sms_apikey = $_POST['apikey'];
$auth_id = 1;
$auth_reg_email = $_POST['afs_email'];
$auth_reply_to = $_POST['rpl_email'];;
$auth_afs_email = $_POST['afs_email'];;

Db::getInstance()->Execute('UPDATE `ps_minicskeleton_auth` SET
`auth_apikey` = \'' . $sms_apikey . '\',
`auth_reg_email` = \'' . $auth_reg_email . '\',
`auth_sms_name` = \'' . $sms_name . '\',
`auth_afs_email` = \'' . $auth_afs_email . '\',
`auth_reply_to` = \'' . $auth_reply_to . '\'
WHERE
`auth_id` = \'' . $auth_id . '\'');
}

return $this->_displayForm();
}

// BACK OFFICE HOOKS

/**
* adminHook
*/
public function hookDisplayBackOfficeHeader() {
// CSS
$this->context->controller->addCSS($this->_path . 'views/css/elusive-icons/elusive-webfont.css');
// JS
// $this->context->controller->addJS($this->_path.'views/js/js_file_name.js');
}

/**
* Hook for back office dashboard
*/
public function hookDisplayAdminHomeQuickLinks() {
$this->context->smarty->assign('minictutorialA', $this->name);
return $this->display(__FILE__, 'views/templates/hooks/quick_links.tpl');
}

// FRONT OFFICE HOOKS

/**
*Hook
*/
public function hookDisplayHeader() {
// CSS
$this->context->controller->addCSS($this->_path . 'views/css/' . $this->name . '.css');
// JS
$this->context->controller->addJS($this->_path . 'views/js/' . $this->name . '.js');
}

/**
* Top of pages hook
*/
public function hookDisplayTop($params) {
return $this->hookDisplayHome($params);
}

/**
* Home page hook
*/
public function hookDisplayHome($params) {
//forside home
$this->context->smarty->assign('minictutorialA', array(
'some_smarty_var' => 'some_data',
'some_smarty_array' => array(
'some_smarty_var' => 'some_data',
'some_smarty_var' => 'some_data'
),
'some_smarty_var' => 'some_data'
));

return $this->display(__FILE__, 'views/templates/hooks/home.tpl');
}

/**
* Left Column Hook
*/
public function hookDisplayRightColumn($params) {



return $this->hookDisplayHome($params);
}

/**
* Right Column Hook
*/
public function hookDisplayLeftColumn($params) {

$this->context->smarty->assign(
array(
'my_module_name' => Configuration::get('minictutorialA'),
'my_module_link' => $this->context->link->getModuleLink('minictutorialA', 'display'),
'my_module_message' => $this->l('This is a simple text message') // Do not forget to enclose your strings in the l() translation method
)
);

return $this->display(__FILE__, 'mymodule.tpl');

//return $this->hookDisplayHome($params);
}

/**
* Footer hook
*/
public function hookDisplayFooter($params) {
return $this->hookDisplayHome($params);
}

// Prestashop 1.5
public function hookActionOrderStatusUpdate($params) {
// Get order status
// echo 'new_order_status = ' . $params['newOrderStatus']->id;

// Get order id
//echo 'order_id = ' . $params['id_order'];
}

private function _displayForm() {
 

Link to comment
Share on other sites

 

Hello

 

Remove your html before php opening '<?php'

 

This lines should not be there

<script src="../modules/minictutorial/ckeditor/ckeditor.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

yes I figured that out, thanks for you time :-)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...