Friday 27 April 2012

Add module in artical in joomla

To insert a module inside an article, use the {loadposition xx} command, as follows:
Create a module and set its position to any value that doesn’t conflict with an existing template position. You can type in the position value instead of selecting it from the drop-down list. For example, use the position myposition.
Assign the module to the Menu Items that contain the articles that you want the module to show in. You can also just assign the module to all Menu Items.
Edit the articles where you want this module to appear and insert the text {loadposition myposition} in the article at the place where you want the module.

wysiwyg editor in Magento Custom Module

Step 1 – Go to app/code/local/Webkul/Faq/Block here webkul is namespace and faq is module name , under your _prepareLayout() function add this code
public function _prepareLayout()
{
if (Mage::getSingleton(‘cms/wysiwyg_config’)->isEnabled() && ($block = $this->getLayout()->getBlock(‘head’))) {
$block->setCanLoadTinyMce(true);
}
return parent::_prepareLayout();
}
Then go to app/code/local/Webkul/Faq/Block/Adminhtml/Faq/Edit/Tab
and add following code in your _prepareForm() function below your setform() . $this->setForm($form);
$wysiwygConfig = Mage::getSingleton(‘cms/wysiwyg_config’)->getConfig(array(‘add_variables’ => false, ‘add_widgets’ => false,’files_browser_window_url’=>$this->getBaseUrl().’admin/cms_wysiwyg_images/index/’));
then define this as $fieldset
$fieldset->addField(‘body’, ‘editor’, array(
‘name’ => ‘body’,
‘label’ => Mage::helper(‘faq’)->__(‘Content’),
‘title’ => Mage::helper(‘faq’)->__(‘Content’),
‘style’ => ‘width:700px; height:500px;’,
‘state’ => ‘html’,
‘config’ => $wysiwygConfig,
‘wysiwyg’ => true,
‘required’ => true,
));
This post is original on webkul

Friday 6 April 2012

magento display attribute in dropdown

Create a attribute
and then
edit app/code/core/Mage/Catalog/Block/Navigation.php

public function getAllManu()
{
$product = Mage::getModel(‘catalog/product’);
$attributes = Mage::getResourceModel(‘eav/entity_attribute_collection’)
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter(‘attribute_code’, ‘manufacturer’); //can be changed to any attribute
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
$manufacturers = $attribute->getSource()->getAllOptions(false);
return $manufacturers;
}
and then
edit app/design/frontend/default/default/template/catalog/navigation/top.phtml

  1. <select id=“select-manufacturer” onchange=“window.location.href=this.value”>
  2. <option value=“#” selected=“selected”>–Select Manufacturer–</option>
  3.     <?php foreach ($this->getAllManu() as $manufacturer): ?>
  4.         <option value=“/catalogsearch/advanced/result/?manufacturer[]=<?php echo $manufacturer['value'] ?>”><?php echo $manufacturer['label'] ?></option>
  5.     <?php endforeach; ?>
  6.     </select>

captcha (alpha numeric) in php

<?php
$RandomStr = md5(microtime());// md5 to generate the random string
$ResultStr = substr($RandomStr,0,8);
$im = @imagecreate(110, 20)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, $RandomStr, $text_color);
imagejpeg($im,$ResultStr.'.jpg');
imagedestroy($im);
//echo '’.$randval.”;
?>

ebooks of drupal 6 and drupal 7

magento free ebook download