Pages

Wednesday, March 6, 2013

Get resource id from resource name in modx revolution


$resource = $modx->getObject('modResource',Resource_Id);
$longTitle = $resource->get('pagetitle');

Here, from above code you can get pagetitle from resource id(Resource_Id).



Get resource id from resource name

$resource = $modx->getObject('modResource','Resource_Name');
$longTitle = $resource->get('id');

in this code you can get resource id from resource pagetitle('Resource_Name').

Get template id from template name modx revolution

$templateObj = $modx->resource->getOne('Template',array('templatename'=>'Template_Name'));
$templateid = $templateObj->get('id');

Here, in this code "Template_Name" is template name from which user want to get template id.

Wednesday, December 12, 2012

TV image preview modx Revo

There is a bug in modx revo that in manager i can't see image preview in TV.

Solutions is :

So, following the method mentioned in the bug report, I simply changed Line 219 in core/model/phpthumb/phpthumb.class.php:

From :
$this->config_document_root = (@$_SERVER['DOCUMENT_ROOT'] ? $_SERVER['DOCUMENT_ROOT'] : $this->config_document_root);

To :
$this->config_document_root = (@$_SERVER['DOCUMENT_ROOT'] ? '/home/username/public_html' : $this->config_document_root);

and it's worked for me.

Thursday, May 10, 2012

Display product list Randomly and limited numbers in 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
paste step1 to contact area. click save.

step 1.

{{block type="catalog/product_list_random"  category_id="4" template="catalog/product/product_list.phtml"}}

now open product_list.phtml use the code below to display 4 products at once

step 2.
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
    if ($_productCollection->count()):
    $_productCollection = $_productCollection->getItems();

    $i = 0;
             foreach ($_productCollection as $_product):
        if ($i < 4):
                             // Product Data With CSS
        endif;
    $i++;
     endforeach;
    endif;

?>
 Now you can show your index page product list randomly with 3 limited number products.

Comment it and share it.

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 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.gif
and 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!

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

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.