Jump to content

Php Fatal Error --- Help


Vilas

Recommended Posts

While using blockcategories module I am getting below error massage.

 

Fatal error: Call to undefined method Category::hideCategoryPosition() in /hermes/.../estock/modules/blockcategories/blockcategories.php on line 139

 

Php file contains below text.

 

<?php

 

class BlockCategories extends Module

{

function __construct()

{

$this->name = 'blockcategories';

$this->tab = 'Blocks';

$this->version = 1.5;

 

parent::__construct();

 

/* The parent construct is required for translations */

$this->page = basename(__FILE__, '.php');

$this->displayName = $this->l('Categories block');

$this->description = $this->l('Adds a block featuring product categories. updated by(www.marghoobsuleman.com | www.giftlelo.com)');

}

 

function install()

{

if (parent::install() == false

OR $this->registerHook('leftColumn') == false

OR Configuration::updateValue('BLOCK_CATEG_MAX_DEPTH', 3) == false

OR Configuration::updateValue('BLOCK_CATEG_DHTML', 1) == false)

return false;

return true;

}

 

public function getContent()

{

$output = '<h2>'.$this->displayName.'</h2>';

if (Tools::isSubmit('submitBlockCategories'))

{

$maxDepth = intval(Tools::getValue('maxDepth'));

$dhtml = Tools::getValue('dhtml');

if ($maxDepth < 0)

$output .= '<div class="alert error">'.$this->l('Maximum depth: Invalid number.').'</div>';

elseif ($dhtml != 0 AND $dhtml != 1)

$output .= '<div class="alert error">'.$this->l('Dynamic HTML: Invalid choice.').'</div>';

else

{

Configuration::updateValue('BLOCK_CATEG_MAX_DEPTH', intval($maxDepth));

Configuration::updateValue('BLOCK_CATEG_DHTML', intval($dhtml));

$output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="'.$this->l('Confirmation').'" />'.$this->l('Settings updated').'</div>';

}

 

$customdhtml = Tools::getValue('customdhtml');

if ($maxDepth < 0)

$output .= '<div class="alert error">'.$this->l('Maximum depth: Invalid number.').'</div>';

elseif ($customdhtml != 0 AND $customdhtml != 1)

$output .= '<div class="alert error">'.$this->l('Custom Dynamic Menu: Invalid choice.').'</div>';

else

{

Configuration::updateValue('BLOCK_CATEG_CUSTOMDHTML', intval($customdhtml));

}

 

}

return $output.$this->displayForm();

}

 

public function displayForm()

{

return '

<form action="'.$_SERVER['REQUEST_URI'].'" method="post">

<fieldset>

<legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Settings').'</legend>

<h2>'.$this->l('Common settings').'</h2>

<label>'.$this->l('Maximum depth').'</label>

<div class="margin-form">

<input type="text" name="maxDepth" value="'.Configuration::get('BLOCK_CATEG_MAX_DEPTH').'" />

<p class="clear">'.$this->l('Set the maximum depth of sublevels displayed in this block (0 = infinite)').'</p>

</div>

<h2>'.$this->l('Prestashop default menu (if enabled)').'</h2>

<label>'.$this->l('Dynamic').'</label>

 

<div class="margin-form">

<input type="radio" name="dhtml" id="dhtml_on" value="1" '.(Tools::getValue('dhtml', Configuration::get('BLOCK_CATEG_DHTML')) ? 'checked="checked" ' : '').'/>

<label class="t" for="dhtml_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>

<input type="radio" name="dhtml" id="dhtml_off" value="0" '.(!Tools::getValue('dhtml', Configuration::get('BLOCK_CATEG_DHTML')) ? 'checked="checked" ' : '').'/>

<label class="t" for="dhtml_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>

<p class="clear">'.$this->l('Activate dynamic (animated/collapsed) mode for sublevels. (Menu expanded by default if disabled)').'</p>

</div>

<hr />

<h2>'.$this->l('Custom menu').'</h2>

<label>'.$this->l('Enable custom menu').'</label>

<div class="margin-form">

<input onclick="javascript:$(\'#module_preview\').attr(\'src\', \'../modules/blockcategories/img/preview-custom.jpg\');" type="radio" name="customdhtml" id="customdhtml_on" value="1" '.(Tools::getValue('customdhtml', Configuration::get('BLOCK_CATEG_CUSTOMDHTML')) ? 'checked="checked" ' : '').'/>

<label class="t" for="customdhtml_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>

<input onclick="javascript:$(\'#module_preview\').attr(\'src\', \'../modules/blockcategories/img/preview-default.jpg\');" type="radio" name="customdhtml" id="customdhtml_off" value="0" '.(!Tools::getValue('customdhtml', Configuration::get('BLOCK_CATEG_CUSTOMDHTML')) ? 'checked="checked" ' : '').'/>

<label class="t" for="customdhtml_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>

<p class="clear">'.$this->l('Use Custom Menu: Updated by marghoobsuleman.com').'</p>

</div>

<div class="margin-form">

<h2>'.$this->l('Menu Preview').'</h2>

<img id="module_preview" border="1" src="'.(Tools::getValue('customdhtml', Configuration::get('BLOCK_CATEG_CUSTOMDHTML')) ? '../modules/blockcategories/img/preview-custom.jpg" ' : '../modules/blockcategories/img/preview-default.jpg').'" />

</div>

<center><input type="submit" name="submitBlockCategories" value="'.$this->l('Save').'" class="button" /></center>

</fieldset>

</form>';

}

 

function getTree($resultParents, $resultIds, $id_category = 1, $currentDepth = 0)

{

global $link;

 

$children = array();

if (isset($resultParents[$id_category]) AND sizeof($resultParents[$id_category]) AND (Configuration::get('BLOCK_CATEG_MAX_DEPTH') == 0 OR $currentDepth < Configuration::get('BLOCK_CATEG_MAX_DEPTH')))

foreach ($resultParents[$id_category] as $subcat)

$children[] = $this->getTree($resultParents, $resultIds, $subcat['id_category'], $currentDepth + 1);

if (!isset($resultIds[$id_category]))

return false;

return array('id' => $id_category, 'link' => $link->getCategoryLink($id_category, $resultIds[$id_category]['link_rewrite']),

'name' => Category::hideCategoryPosition($resultIds[$id_category]['name']), 'desc'=> $resultIds[$id_category]['description'],

'children' => $children);

}

 

function hookLeftColumn($params)

{

global $smarty;

 

/* ONLY FOR THEME OLDER THAN v1.0 */

global $link;

$smarty->assign(array(

'categories' => Category::getHomeCategories(intval($params['cookie']->id_lang), true),

'link' => $link

));

/* ELSE */

 

$result = Db::getInstance()->ExecuteS('

SELECT * FROM '._DB_PREFIX_.'category c

LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (c.id_category = cl.id_category AND id_lang = '.intval($params['cookie']->id_lang).')

WHERE level_depth <= '.intval(Configuration::get('BLOCK_CATEG_MAX_DEPTH')).'

AND c.active = 1

ORDER BY level_depth, cl.name ASC');

$resultParents = array();

$resultIds = array();

foreach ($result as $row)

{

$$row['name'] = Category::hideCategoryPosition($row['name']);

$resultParents[$row['id_parent']][]= $row;

$resultIds[$row['id_category']] = $row;

}

$blockCategTree = $this->getTree($resultParents, $resultIds);

 

$isDhtml = (Configuration::get('BLOCK_CATEG_DHTML') == 1 ? true : false);

$isCustomDhtml = (Configuration::get('BLOCK_CATEG_CUSTOMDHTML') == 1 ? true : false);

 

if (isset($_GET['id_category']))

$smarty->assign('currentCategoryId', intval($_GET['id_category']));

$smarty->assign('blockCategTree', $blockCategTree);

 

if (file_exists(_PS_THEME_DIR_.'modules/blockcategories/blockcategories.tpl'))

$smarty->assign('branche_tpl_path', _PS_THEME_DIR_.'modules/blockcategories/category-tree-branch.tpl');

else

$smarty->assign('branche_tpl_path', _PS_MODULE_DIR_.'blockcategories/category-tree-branch.tpl');

$smarty->assign('isDhtml', $isDhtml);

$smarty->assign('isCustomDhtml', $isCustomDhtml);

/* /ONLY FOR THEME OLDER THAN v1.0 */

 

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

}

 

function hookRightColumn($params)

{

return $this->hookLeftColumn($params);

}

}

 

?>

 

Will be great if anyone help me to sort out this issue.

 

Thanks

Link to comment
Share on other sites

Hello Vekia,

 

Thanks for attention. I am using fresh installed version of PS 1.5.1.0. The said php file belongs to that module which is developed by suleman & I have downloaded from below url.

 

www.marghoobsuleman.com/prestashop-modules/prestashop-modules-categories-custom-menu

 

If you tell me more in detail about below modification then that also fine for me. No use of the above issue.

 

http://www.prestashop.com/forums/topic/197781-module-block-categories-change-it-to-support-default-vertical-superfish-menu/

 

Thanks

Link to comment
Share on other sites

  • 2 weeks later...

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...