I'm developing a php module to Magento 1.9.2.4. I want to check if my module is enable or disable, but it is not working. What is wrong ?
Module folder: C:\wamp\www\magento\app\code\core\Projetos\HelloWorld
My code:
<?php
require_once 'app/Mage.php';
Mage::app();
$moduleName = 'Projetos_HelloWorld';//eg Mage_Cms
if(Mage::getConfig()->getModuleConfig($moduleName)->is('active', 'true')) {
//$product = new Projetos_HelloWorld_Model_Product;
//$product->sayHello();
echo "Module Enable";
} else {
echo "Module Disable";
}
?>
Thank you
I guess you'are not following standard magento module creating method.
If you would like to know whether particular module is enable or not then you have to check it from app/etc/modules/name_of_module.xml
Please have a look at how to create an extension in magento.
http://www.pierrefay.com/magento-developper-guide-howto-tutorial-5
I hope this will help you out.
Thanks,
Sam
Try this
<?php
if (Mage::helper('core')->isModuleEnabled('Projetos_HelloWorld'))
{
echo "Module Enable";
} else {
echo "Module disabled";
}
Related
I am Trying To Add Help Button On Module Menu . I have Doing Lots Off R&D but Failed . BTW Here is My Code
my_first_module.info
name = My Module
description = embedded Video Comment
core = 7.x
my_first_module.module
<?php
/**
* Implements hook_help().
*/
function my_first_module_help($path, $arg) {
if ($path == 'admin/help#my_first_module') {
return t('A demonstration module.');
}
}
I have Cleared Cache But help link isn't appear
My best guess is that the help module (from Core) is not enabled.
I want to use https://github.com/HelloFax/hellosign-php-sdk in Yii2 project so I followed following step
1 ) updated composer.json with "hellosign/hellosign-php-sdk": "3.*#dev" in require section
2) run composer update in CMD (I work with window 7)
so it downloaded required libraries (hellosign-php-sdk and libary) in vendor
3 ) include following code in controller file
$client = new HelloSign\Client('df754dd564e52fb2891a60eb2fea777b5320397********');
$response = $client->getSignatureRequest('f6197945000616b383d4752*****');
if ($response->isComplete()) {
echo 'All signers have signed this request.';
} else {
foreach ($response->getSignatures() as $signature) {
echo $signature->getStatusCode() . "\n";
}
}
Error
Unable to find 'app\controllers\HelloSign\Client' in file: C:\wamp\www\yii2hellosign/controllers/HelloSign/Client.php. Namespace missing?
How to solve this issue, any help ?
the library use psr-0 autoload, so you need to prepend classname with \ , like this:
$client = new \HelloSign\Client('...');
Though depreciated. still, I want to achieve this functionality and please don't advise me to upgrade to newer version of Joomla. I have tried to write this piece of code in required place in /tmp/default.php file of a particular component. Please advise me am I going right. I have still not got the answer. Thanks.
jimport('joomla.form.form');
JModel::addIncludePath(JPATH_SITE.DS.'components'.DS.'com_user'.DS.'models');
$model = JModel::getInstance('User', 'UserModel');
echo "something is not right. Please login.";
var_dump($model);
$form = $model->getLoginForm();
To include any module any where this code will be handy.
<?php
$doc = JFactory::getDocument();
$module = JModuleHelper::getModule('mod_login');
//get and update params
$params = new JRegistry;
$params->loadString($module->params);
//$params->set('param','value');
//render module
$renderer = $doc->loadRenderer('module');
$content = $renderer->render($module, array('params'=> $params));
print $content;
?>
I am trying to use php-excel-reader(http://www.yiiframework.com/extension/php-excel-reader/) extension to upload excel file into database. I was trying to implement the example function provided in the extension page. But i keep on getting the error "Undefined index: dontprint".I am not able to understand what is causing the error. please help.This is my controler code.
public function actionUpload()
{
Yii::import('ext.phpexcelreader.JPhpExcelReader');
$data=new JPhpExcelReader(Yii::app()->getBasePath().'/import/example.xls');
echo $data->dump(true,true);
}
This is the code involving dontprint in extension code.
for($col=1;$col<=$this->colcount($sheet);$col++) {
// Account for Rowspans/Colspans
$rowspan = $this->rowspan($row,$col,$sheet);
$colspan = $this->colspan($row,$col,$sheet);
for($i=0;$i<$rowspan;$i++) {
for($j=0;$j<$colspan;$j++) {
if ($i>0 || $j>0) {
$this->sheets[$sheet]['cellsInfo'][$row+$i][$col+$j]['dontprint']=1;
}
}
}
if(!$this->sheets[$sheet]['cellsInfo'][$row][$col]['dontprint']) {
$style = $this->style($row,$col,$sheet);
if ($this->colhidden($col,$sheet)) {
$style .= "display:none;";
}
Any help appreciated. Thanks in advance.
A quick Google shows an identical issue happening when iconv isn't installed and enabled, do you have that installed/enabled?
IT's a notice.. Problem solved with adding on Controller
error_reporting(E_ERROR|E_WARNING);
But this is not a safe solution.
I'm trying to write some code to track dependencies. Is there a way to programatically detect if a PEAR package has been installed? I'm thinking something like:
if ($some_pear_api->isPackageInstalled('FooPack')) {
echo 'FooPack is installed!';
} else {
echo 'FooPack is not installed. :(';
}
I know you can simply detect if the class file for that package exists, but I mostly want to know if PEAR has that installed because sometimes some libraries provide other means of including their code (e.g. PHPUnit has a pear channel as well as a git repo.).
Thanks for the help!
You need to use the PEAR_Registry class to do this (which is what the PEAR script itself uses).
Read Adam Harvey's blog post "pear -> list" from 3 years ago - all the details/examples you need are there.
include 'PEAR/Registry.php';
$reg = new PEAR_Registry;
foreach ($reg->listPackages() as $package) {
print "$package\n";
}
If you need this to check for specific versions of each package, then you could base something on the following example, which I provided in a comment to that blog entry:
<?php
require 'PEAR/Registry.php';
$reg = new PEAR_Registry;
define("NAME", 0);
define("VERSION", 1);
$packages = array(
array("PEAR", "1.6.2"),
array("Date", "1.4.7"),
array("Date_Holidays", "0.17.1"),
array("Validate_IE", "0.3.1")
);
foreach ($packages as $package) {
$pkg = $reg->getPackage($package[NAME]);
$version = $pkg->getVersion();
echo "{$package[NAME]} – {$package[VERSION]} – ";
echo version_compare($version, $package[VERSION], '>=') ? 'OK': 'BAD', "\n";
}
?>
If you need to copy and paste this, then it might be best for you to use the version at https://gist.github.com/kenguest/1671361.
You can use Pear/Infos packageInstalled to answer this:
<?php
require_once 'PEAR/Info.php';
$res = PEAR_Info::packageInstalled('FooPack');
if ($res) {
print "Package FooPack is installed \n";
} else {
print "Package FooPack is not yet installed \n";
}
?>
Why not just include the package and see if the class exists?
// Supress Errors. Checking is done below.
#require_once 'PHP/UML.php';
if(!class_exists('PHP_UML'))
{
throw new Exception('PHP_UML is not installed. Please call `pear install PHP_UML` from the command line',1);
}
// Code to use PHP_UML below...
$uml = new PHP_UML();