I had use a code in joomla 1.5 to laod mod_related_items in com_content >> article:
<?php
jimport('joomla.application.module.helper');
$module = &JModuleHelper::getModule('module_type(example:"mod_related_items")','Position-name');
echo JModuleHelper::renderModule($module);
?>
<?php echo $this->item->event->afterDisplayContent; ?>
I had use this code end of this file: components/com_content/views/article/tmpl/default.php
now i want use this code in joomla 2.5.
when i used it in jooma 2.5, I had these errors:
Notice: Trying to get property of non-object in
C:\wamp\www\kknews.ir\libraries\joomla\application\module\helper.php
on line 152
Notice: Trying to get property of non-object in
C:\wamp\www\kknews.ir\libraries\joomla\application\module\helper.php
on line 156
Notice: Trying to get property of non-object in
C:\wamp\www\kknews.ir\libraries\joomla\application\module\helper.php
on line 159
Notice: Undefined property: stdClass::$content in
C:\wamp\www\kknews.ir\templates\system\html\modules.php on line 16
please help me.
Try this,
$document = JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$Module = JModuleHelper::getModule('mod_fmDataGrid');
$Params = "param1=bruno\n\rparam2=chris";//If any params
$Module->params = $Params;//If any params
echo $renderer->render($Module);
Hope it works..
Related
I am using Gantry 5 template and I want to add php code in the header. I set some variables using php and access them in the script tag. For example
<?php
$id = $user->id;
$name = $user->username;
?>
<script>
var id = '<?php echo $id; ?>';
var name = '<?php echo $name; ?>';
</script>
I want to add the above code in head of Gantry 5 template. In we just add the code in index.php but this mechanism is different in Gantry 5. How this code can be added?
I have installed Magento CE 1.9 version and getting error after calling Catalog on Home page. Issue seems to be related with list.phtml.
ERROR : Fatal error: Call to a member function getSortedChildren() on
a non-object in
mageinc\app\design\frontend\rwd\default\template\catalog\product\list.phtml
on line 74
I didn't change anything after installation and it seems this issue came with Magento 1.9 edition.
Issue is occurring for both List and Grid view on Catalog page as it is being called for both views.
Is there any best solution to resolve this issue ?
you just have to delete the method ->getSortedChildren(); at line 134
$_nameAfterChildren = $this->getChild('name.after')->getSortedChildren();
so you have
$_nameAfterChildren = $this->getChild('name.after');
Add these lines in your block section layouts file
<block type="core/text_list" name="product_list.name.after" as="name.after"/>
<block type="core/text_list" name="product_list.after" as="after"/>
Replace the code by:
<?php
$_nameAfter = $this->getChild('name.after');
// New if here
if($_nameAfter):
$_nameAfterChildren = $_nameAfter->getSortedChildren();
foreach($_nameAfterChildren as $_nameAfterChildName):
$_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName);
$_nameAfterChild->setProduct($_product);
?>
<?php echo $_nameAfterChild->toHtml(); ?>
<?php endforeach; ?>
<?php endif; ?>
<?php
//set product collection on after blocks
$_afterChildren = $this->getChild('after');
if ($_afterChildren):
$_afterChildren = $this->getChild('after')->getSortedChildren();
foreach($_afterChildren as $_afterChildName):
$_afterChild = $this->getChild('after')->getChild($_afterChildName);
$_afterChild->setProductCollection($_productCollection);
?>
<?php echo $_afterChild->toHtml(); ?>
<?php endforeach; ?>
<?php endif; ?>
As seen in: https://magento.stackexchange.com/questions/20984/show-products-on-homepage-magento-1-9/20996#20996?newreg=c5c83466c28d45259ed36642cfe0a382
The solution of Pass TeT will throw the PHP Error "PHP Fatal error: Can't use method return value in write context" because PHP doesn't have concept of emptyness. It's better to use <?php if($this->getChild('name.after')): ?> what wouldn't throw an error.
Edit this file app/design/frontend/rwd/default/template/catalog/product/list.phtml
Add this code at 73 and 135 lines
<?php if(!empty($nameAfter = $this->getChild('name.after'))): ?>
just before:
$_nameAfterChildren = $nameAfter->getSortedChildren();
and add this code at 82 and 144 line
<?php endif; ?>
right after
<?php endforeach; ?>
Hey guys I had the same problem - but it was because I hadn't copied all the files from app/default/default
to
app/yourTheme/default
I was missing files in the default directory. From my understanding - all files need to be copied.
/etc
/layout
/local
/template
I added an attribute 'items' having input type textbox in admin.I want to show the value of that attribute in shopping cart.For that i have added this code in template/checkout/cart/sidebar-top.phtml which is below:
<?php
$productId = $_item->getId();
$productInfo = Mage::getModel("catalog/product")->load($productId);
echo $productInfo->getAttributeText('product_type');
?>
but when i am adding this above code showing
Fatal error: Call to a member function getId() on a non-object
if anyone knows this,please help me out.thanks!
Use the below code
$productId = $_item->getProduct()->getId();
$productInfo = Mage::getModel("catalog/product")->load($productId);
echo $productInfo->getAttributeText('product_type');
Are you talking about custom option or simple attribute?
For Simple attribute (text) and if you are on product page try belo code:
<?php $_item = $this->getItem()?>
<?php $_product= Mage::getSingleton('catalog/product')->load($_item->getProductId()) ?>
<?php echo $_product->getResource()->getAttribute('attribute_code')->getFrontend()->getValue($_product); ?>
If you are not on the product page then you can use the below code, load the product by sku and get your attribute value
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $_item->getSku());
echo $product->getResource()->getAttribute('attribute_code')->getFrontEnd()->getValue($product);
How can a joomla module be called inside the virtuemart shop.browse page. I tried the following code inside the browse_layouttable.tpl.php but it is not working for me. I am using joomla1.5.23 and the virtuemart version is 1.1.8. Any suggestion?
<?php
$modules =& JModuleHelper::getModules('logo');
foreach ($modules as $module)
{
echo JModuleHelper::renderModule($module)
}
?>
Try this
$document = &JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$Module = &JModuleHelper::getModule('mod_fmDataGrid');
$Params = "param1=bruno\n\rparam2=chris"; //if you want to pass params
$Module->params = $Params;
echo $renderer->render($Module);
I would suggest you use "Modules Anywhere" from NoNumber:
http://extensions.joomla.org/extensions/core-enhancements/coding-a-scripts-integration/embed-a-include/6402
After you install this plugin you can add module positions directly in your browse page PHP using this example:
{modulepos mynewposition}
This is a must have plugin for all Joomla users, because you can use it throughout your site.
I want create new table out of magento, in interface, without inheriting setup class. I tried to get resource model of setup. This didn't work:
require_once 'app/Mage.php';
Mage::init();
$setup = Mage::getResourceModel('catalog/setup');
I was also thinking about Mage::getResourceModel('core/resource_setup') but i have an error: Fatal error: Call to a member function startSetup() on a non-object in C:\xampp\
htdocs\LPP_MAGENTO_EE_CUSTOM\app\code\core\Mage\Core\Model\Resource\Setup.php on
line 944
Do you have any idea?
(I saw this question but it doesn't work for me)
I did it with $setup = Mage::getModel('eav/entity_setup', 'core_setup') example for create new attribute for Category within my code:
require_once 'app/Mage.php';
Mage::init();
$setup = Mage::getModel('eav/entity_setup', 'core_setup');
$setup->addAttribute('catalog_category', 'xxx', array(
...
));