Joomla Sharing by Krunal Mehta
Thursday, May 10, 2012
Display Product List Radomly and limited numbers on Magento HomePage
Create new file product_list.phtml and copy content from list.phtml to product_list.phtml, log in to your magento admin go to cms -> pages -> home page
<?php
Labels:
Magento
Wednesday, May 9, 2012
Replace default email logo in welcome email Magento
You can create a new theme and place it there.
This isn't as difficult as it sounds because of the way themes fall
back onto defaults in Magento. If Magento can't find something in your
theme, it will fall back onto the base theme by looking in the
For example, in a store that you maintain, you uploaded your own version of the e-mail logo image in
and in the Administration panel, you went to System > Configuration > Design > Themes and set
Why does this work?
In the e-mail templates, Magento specifies the
If you delete your image, it doesn't break! Instead, although Magento would still first search in your theme directory as described above, it would discover that it doesn't exist and fall back onto the one in
Good luck, and hope this helps!
default folder.For example, in a store that you maintain, you uploaded your own version of the e-mail logo image in
/skin/frontend/{package}/{my-theme-name}/images/logo_email.gifand in the Administration panel, you went to System > Configuration > Design > Themes and set
Default to {your-theme-name}.Why does this work?
In the e-mail templates, Magento specifies the
src of the logo image as {{skin url="images/logo_email.gif" _area='frontend'}}. This is Magento template gibberish for "find the images/logo_email.gif in the frontend area of the current theme." So Magento looks in for /frontend/{package}/{your-theme-name}/images/logo_email.gif, finds it, and uses that path when dishing out the HTML.If you delete your image, it doesn't break! Instead, although Magento would still first search in your theme directory as described above, it would discover that it doesn't exist and fall back onto the one in
/frontend/{package}/default/images/logo_email.gif.Good luck, and hope this helps!
Labels:
Magento
Tuesday, May 8, 2012
Magento Backend user edit in account information checkboxes values show and update code
You have to customize in couple of file for showing checked value and update those checkboxes in magento backend Account Information page.
for showing checked value
app/code/core/Mage/Adminhtml/controllers/CustomerController.php
and for update checkboxes value
else if ($inputType == 'checkbox') {
$customer11 = Mage::registry('current_customer');
if($customer11->getData($attribute->getAttributeCode()) == '1' || $customer11->getData($attribute->getAttributeCode()) != '')
$element->setChecked('1');
else if($customer11->getData($attribute->getAttributeCode()) == '0' || $customer11->getData($attribute->getAttributeCode()) == '')
$element->setChecked('0');
}
for showing checked value
app/code/core/Mage/Adminhtml/controllers/CustomerController.php
and for update checkboxes value
app/code/core/Mage/Adminhtml/Block/Widget/form.php
else if ($inputType == 'checkbox') {
$customer11 = Mage::registry('current_customer');
if($customer11->getData($attribute->getAttributeCode()) == '1' || $customer11->getData($attribute->getAttributeCode()) != '')
$element->setChecked('1');
else if($customer11->getData($attribute->getAttributeCode()) == '0' || $customer11->getData($attribute->getAttributeCode()) == '')
$element->setChecked('0');
}
set this codition in function _setFieldset in form.php file for showing your checkbox is checked or not in backend Account infomation page in magento.
$emailprefs = array(
'ATTRIBUTECODE1','ATTRIBUTECODE2','ATTRIBUTECODE3',...,
);
// Prepare customer saving data
if (isset($data['account'])) {
foreach($emailprefs as $pref){
$data['account'][$pref] = isset($data['account'][$pref]) ? 1 : 0;
}
if (isset($data['account']['email'])) {
$data['account']['email'] = trim($data['account']['email']);
}
$customer->addData($data['account']);
}
Put this code in function saveAction() in CustomerController.php page for updating your checkboxes values in backend Account infomation page in magento. Replace 'ATTRIBUTECODE' with your checkboxes attribute codes.
$emailprefs = array(
'ATTRIBUTECODE1','ATTRIBUTECODE2','ATTRIBUTECODE3',...,
);
// Prepare customer saving data
if (isset($data['account'])) {
foreach($emailprefs as $pref){
$data['account'][$pref] = isset($data['account'][$pref]) ? 1 : 0;
}
if (isset($data['account']['email'])) {
$data['account']['email'] = trim($data['account']['email']);
}
$customer->addData($data['account']);
}
Put this code in function saveAction() in CustomerController.php page for updating your checkboxes values in backend Account infomation page in magento. Replace 'ATTRIBUTECODE' with your checkboxes attribute codes.
Labels:
Magento
Magento update checkboxes in frontend edit registration page code
app\code\core\Mage\Customer\controllers\AccountController.php
/**
* we would like to preserver the existing group id
*/
if ($this->_getSession()->getCustomerGroupId()) {
$customer->setGroupId($this->_getSession()->getCustomerGroupId());
}
/**
* Custom coding for Promoted Update & Rented Update by Leo
*/
if ($this->getRequest()->getParam('ATTRIBUTE_CODE')) {
$customer->setATTRIBUTE_CODE(1);
} else {
$customer->setATTRIBUTE_CODE(0);
}
/**
* End
*/
From this customizing user can update checkboxes values from edit registration page frontside in Magento if user has checkbox fields in registration of his magento site. Replace 'ATTRIBUTE_CODE' with your checkbox attribute code.
Labels:
Magento
Thursday, May 3, 2012
Find number of total checkboxes in form or page Javascript
var formobj = document.getElementById('FORM_ID');
var counter = 0;
for (var j = 0; j < formobj.elements.length; j++)
{
if (formobj.elements[j].type == "checkbox")
{
if (formobj.elements[j].checked)
{
counter++;
}
}
}
alert('Total Checked = ' + counter);
This javascript is using to find number of total checkboxes in form or page and also
user can find from all checkboxes how many is checked. In this 'FORM_ID' is the id
of <form>.
Saturday, February 25, 2012
How to check if GD Library is installed?
Try this:
You could also spit some info about your GD version by doing this:
php Code:
<?php
if (extension_loaded('gd') && function_exists('gd_info')) {
echo "It looks like GD is installed";
}
?>
<?php
if (extension_loaded('gd') && function_exists('gd_info')) {
echo "It looks like GD is installed";
}
?>
You could also spit some info about your GD version by doing this:
php Code:
<?php
echo "<pre>"; var_dump(gd_info()); echo "</pre>";
?>
<?php
echo "<pre>"; var_dump(gd_info()); echo "</pre>";
?>
You will definitely get the ans of your GD Library is installed or not.
Labels:
PHP
Inserting and Updating Records Using JDatabase in Joomla
When you are doing simple single table inserts and updates you can
use the JDatabase methods to do so. The advantages of using the
JDatabase methods is it saves your time from hand coding sql and
will escape and correctly quote your inputs for you.
The following will insert a new record into a table:
Here is more info on using JTable.
The following will insert a new record into a table:
<?php
$db = JFactory::getDBO();
//Create data object
$row = new JObject();
$row->title = 'The Title';
$row->author = 'Bob Smith';
//Insert new record into #__book table.
$ret = $db->insertObject('#__book', $row);
//Get the new record id
$new_id = (int)$db->insertid();
?>
This will update an existing record:<?php
$db = JFactory::getDBO();
//Create data object
$row = new JObject();
//Record to update
$row->rec_id = 200;
$row->title = 'The Title';
$row->author = 'Bob Smith';
//Update the record. Third parameter is table id field that will be used to update.
$ret = $db->updateObject('#__book', $row,'rec_id');
?>
You can also use JTable to insert and update records, but requires
more initial setup since you have to create a new JTable class for each
table you want to modify. Using JTable is preferred if table has many
fields to update from a form submit. JTable will automatically bind the
form fields to corresponding table fields using the bind() method.Here is more info on using JTable.
Labels:
Joomla 1.5,
joomla 1.7,
SQL in Joomla
Subscribe to:
Posts (Atom)