Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Questions before buy: Two difficult challenges

Questions before buy: Two difficult challenges

Hi,

First of all my congratulations about this amazing component, I´m really impressed.

Well, I have 2 problems since I begin working with joomla that I have never been able to solve, perhaps you can help me, I have read the whole documentation but I have found nothing about these issues.

1 - I need to change the virtuemart THEME depending on the url string, categories and so on. Is it possible to achieve this with chameleon pro? how?

2 - This is even harder. I´m wrappering another cms inside joomla. It is in the same server and I need to change the css of this second cms depeding on the menu item, url string.... Is it possible by autocreating a css file or something like that? I mean, in the wrappered cms I link a css file that can be modified throught chameleon pro...

Any ideas?

Sorry for my poor english.

Thanks a lot in advance. Keep the the good work!!

juanon
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Questions before buy: Two difficult challenges

Hi juanon,

I've got a cool solution for (1), allowing you to change the theme using Chameleon. Can you tell me what EXACT version of VM you are using so I can check that it will work with it?

For (2), that is definitely harder. How are you doing the wrapping? Is it in a frame/iframe?
The main problem there is that if it's inside a frame/iframe, then the URL of the "outside" page (i.e. the Joomla page that's wrapping the other cms) does not change when you click on internal links in the wrapped page.

If, however, you mean that you want to call a css file from inside the wrapped page, and have that file altered with Chameleon, then that may be possible but is probably not a good way to achieve the results you are looking for. Could you perhaps describe a little more thoroughly what you want to happen, and why? There are probably better ways to tackle it.

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Questions before buy: Two difficult challenges

Hi Stephen,

Great support!!

Well. I'm working with vm 1.1.9 right now, but, you know, thinking about give the big jump to
2.0 for being able to use joomla 1.7...

For the "second problem" I will try to explain it better:

I'm the proud owner of a component for hotel reservations made for the elxis cms.

This cms is also mambo fork but it followed a different way than joomla. The truth is that I'm really really happy with this component. Joomla is my favorite cms but it hasn't nothing similar and so well coded. Believe me, I have test every single component for this task made for joomla.

Well, said that I would like to offer two different designs to my customers: one for searching a hotel in one city, andthe other one for searching a hotel in a whole country...

I know the right solution would be that that component was joomla compatible or chameleon was elxis compatible, but this is not a perfect world..

So my idea was to set two menu items in joomla menu. both wrapping elxis cms (installed in the same server) and depending of the menu item choosen show the hotel page in one style or another. Of course the best would be to change the whole template in elxis (that work similar to joomla) but this must be very hard...

I have been thinking a lot about this and perhaps a middle solution could be to set a cookie with chameleon depending on menu item choosen and then custom code a way to chose a css file or better a temlate based in this cookie, but the truth is I don't know how to do this...

Thanks a lot in advace, my friend.

juanon
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Questions before buy: Two difficult challenges

Ok, I see what you mean now, thanks for the explanation.

Since the Elxis cms is a mambo fork, I assume that it has templates rather like Joomla does. e.g. templates/templatename/index.php contains HTML code for the basic structure of the page, plus module position, CSS and JS file includes etc. Correct?

If that's the case then it shouldn't be hard to do this:
1 - use Chameleon to set cookies when particular pages are hit, e.g. the pages where Elxis is going to be embedded

2 - in the Elxis template index.php file, pick up the cookie and use it to determine which css file to include.

How does that sound to you?

Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Questions before buy: Two difficult challenges

Great Stephen,

It´s more or less the same I had thought... I will try it when I have some free time and I will keep you informed. :-)

What about the solution for virtuemart themes?

Do I need the pro version to achieve these solutions?

Thanks, thanks and thanks again for your help and support!!

juanon
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Questions before buy: Two difficult challenges

Hi Juanon,

I'll post my solution for the VM theme switching tomorrow. Need some sleep now! Doesn't need Pro version, but I'd be very happy for you to go Pro since I spent time on the solution - but it's up to you.

Best regards,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Questions before buy: Two difficult challenges

Ok, here's how to get Chameleon to control the theme based on any conditions within Chameleon.

1 - create a folder inside each of the VM themes you are going to use. Call it "user_class". e.g. a folder called components/com_virtuemart/themes/default/user_class

2 - inside that folder, create a php file called ps_config.php

3 - copy and paste the contents of the following code into the new ps_config.php file:

Code:

<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );


class ps_config extends vm_ps_config {   
   
    function writeconfig(&$d) {
        global $my, $db, $vmLogger, $VM_LANG, $mosConfig_live_site;

        $df_theme = $db->getEscaped($d['conf_THEME']);

        $group_id = intval( $d['conf_VM_PRICE_ACCESS_LEVEL'] );
// TODO: (J! 1.5) Is there a better way to handle this difference between Joomla versions?
        if( vmIsJoomla(1.5) ) {
            $db->query( 'SELECT name FROM #__core_acl_aro_groups WHERE id=\''.$group_id.'\'' );
        } else {
            $db->query( 'SELECT name FROM #__core_acl_aro_groups WHERE group_id=\''.$group_id.'\'' );
        }
        $db->next_record();
        $d['conf_VM_PRICE_ACCESS_LEVEL'] = $db->f('name');

        if (!is_writable(ADMINPATH ."virtuemart.cfg.php")) {
            $vmLogger->err( $VM_LANG->_('VM_CONFIGURATION_CHANGE_FAILURE',false).' ('. ADMINPATH ."virtuemart.cfg.php)" );
            return false;
        }


        if ( empty($d['VM_CHECKOUT_MODULES']['CHECK_OUT_GET_SHIPPING_ADDR']['enabled']) ) {
            $d['conf_NO_SHIPTO'] = '1';
        }
        else {
            $d['conf_NO_SHIPTO'] = '';
        }
        if( empty( $d['conf_SHIPPING'] ) || empty($d['VM_CHECKOUT_MODULES']['CHECK_OUT_GET_SHIPPING_METHOD']['enabled']) ) {
            $d['VM_CHECKOUT_MODULES']['CHECK_OUT_GET_SHIPPING_METHOD']['enabled'] = '';
            $d['conf_NO_SHIPPING'] = '1';
        }

        $d['conf_PSHOP_OFFLINE_MESSAGE'] = vmGet($d, 'conf_PSHOP_OFFLINE_MESSAGE', '', VMREQUEST_ALLOWHTML );

        /** Prevent this config setting from being changed by no-backenders  **/
        if (!defined('_PHSHOP_ADMIN') && !stristr($my->usertype, "admin")) {
            $d['conf_PSHOP_ALLOW_FRONTENDADMIN_FOR_NOBACKENDERS'] = PSHOP_ALLOW_FRONTENDADMIN_FOR_NOBACKENDERS;
        }
        $my_config_array = array(
        "PSHOP_IS_OFFLINE"  =>      "conf_PSHOP_IS_OFFLINE",
        "PSHOP_OFFLINE_MESSAGE"  =>      "conf_PSHOP_OFFLINE_MESSAGE",
        "USE_AS_CATALOGUE"  =>      "conf_USE_AS_CATALOGUE",
        "VM_TABLEPREFIX"  =>      "conf_VM_TABLEPREFIX",
        "VM_PRICE_SHOW_PACKAGING_PRICELABEL"  =>      "conf_VM_PRICE_SHOW_PACKAGING_PRICELABEL",
        "VM_PRICE_SHOW_INCLUDINGTAX"  =>      "conf_VM_PRICE_SHOW_INCLUDINGTAX",
        "VM_PRICE_ACCESS_LEVEL"  =>      "conf_VM_PRICE_ACCESS_LEVEL",
        "VM_REGISTRATION_TYPE"  =>      "conf_VM_REGISTRATION_TYPE",
        "VM_BROWSE_ORDERBY_FIELD"  =>      "conf_VM_BROWSE_ORDERBY_FIELD",
        "VM_GENERALLY_PREVENT_HTTPS"  =>      "conf_VM_GENERALLY_PREVENT_HTTPS",
        "VM_ALLOW_EXTENDED_CLASSES"  =>      "conf_VM_ALLOW_EXTENDED_CLASSES",
        "VM_SHOW_REMEMBER_ME_BOX"  =>      "conf_VM_SHOW_REMEMBER_ME_BOX",
        "VM_REVIEWS_MINIMUM_COMMENT_LENGTH"  =>      "conf_VM_REVIEWS_MINIMUM_COMMENT_LENGTH",
        "VM_REVIEWS_MAXIMUM_COMMENT_LENGTH"  =>      "conf_VM_REVIEWS_MAXIMUM_COMMENT_LENGTH",
        "VM_SHOW_PRINTICON"  =>      "conf_VM_SHOW_PRINTICON",
        "VM_SHOW_EMAILFRIEND"  =>      "conf_VM_SHOW_EMAILFRIEND",
        "PSHOP_PDF_BUTTON_ENABLE" => "conf_PSHOP_PDF_BUTTON_ENABLE",
        "VM_REVIEWS_AUTOPUBLISH"  =>      "conf_VM_REVIEWS_AUTOPUBLISH",
        "VM_PROXY_URL"  =>      "conf_VM_PROXY_URL",
        "VM_PROXY_PORT"  =>      "conf_VM_PROXY_PORT",
        "VM_PROXY_USER"  =>      "conf_VM_PROXY_USER",
        "VM_PROXY_PASS"  =>      "conf_VM_PROXY_PASS",
        "VM_ONCHECKOUT_SHOW_LEGALINFO"  =>      "conf_VM_ONCHECKOUT_SHOW_LEGALINFO",
        "VM_ONCHECKOUT_LEGALINFO_SHORTTEXT"  =>      "conf_VM_ONCHECKOUT_LEGALINFO_SHORTTEXT",
        "VM_ONCHECKOUT_LEGALINFO_LINK"  =>      "conf_VM_ONCHECKOUT_LEGALINFO_LINK",
        "ENABLE_DOWNLOADS"  =>      "conf_ENABLE_DOWNLOADS",
        "DOWNLOAD_MAX"  =>      "conf_DOWNLOAD_MAX",
        "DOWNLOAD_EXPIRE"  =>      "conf_DOWNLOAD_EXPIRE",
        "ENABLE_DOWNLOAD_STATUS"  =>      "conf_ENABLE_DOWNLOAD_STATUS",
        "DISABLE_DOWNLOAD_STATUS"  =>      "conf_DISABLE_DOWNLOAD_STATUS",
        "DOWNLOADROOT"  =>      "conf_DOWNLOADROOT",
        "VM_DOWNLOADABLE_PRODUCTS_KEEP_STOCKLEVEL"  =>      "conf_VM_DOWNLOADABLE_PRODUCTS_KEEP_STOCKLEVEL",
        "_SHOW_PRICES"      =>      "conf__SHOW_PRICES",
        "ORDER_MAIL_HTML"   =>      "conf_ORDER_MAIL_HTML",
        "HOMEPAGE"        =>    "conf_HOMEPAGE",
        "CATEGORY_TEMPLATE"        =>    "conf_CATEGORY_TEMPLATE",
        "FLYPAGE"        =>    "conf_FLYPAGE",
        "PRODUCTS_PER_ROW"        =>    "conf_PRODUCTS_PER_ROW",
        "ERRORPAGE"        =>    "conf_ERRORPAGE",
        "NO_IMAGE"        =>    "conf_NO_IMAGE",
        "DEBUG"        =>    "conf_DEBUG",
        "SHOWVERSION"    =>      "conf_SHOWVERSION",
        "TAX_VIRTUAL"     =>      "conf_TAX_VIRTUAL",
        "TAX_MODE"             =>      "conf_TAX_MODE",
        "MULTIPLE_TAXRATES_ENABLE"             =>      "conf_MULTIPLE_TAXRATES_ENABLE",
        "PAYMENT_DISCOUNT_BEFORE" => "conf_PAYMENT_DISCOUNT_BEFORE",
        "PAYMENT_DISCOUNT_VAT_ID" => "conf_PAYMENT_DISCOUNT_VAT_ID",
        "PSHOP_ALLOW_REVIEWS" => "conf_PSHOP_ALLOW_REVIEWS",
        "PSHOP_AGREE_TO_TOS_ONORDER" =>      "conf_PSHOP_AGREE_TO_TOS_ONORDER",
        "SHOW_CHECKOUT_BAR"    =>    "conf_SHOW_CHECKOUT_BAR",
        "CHECK_STOCK"    =>    "conf_CHECK_STOCK",
        "ENCODE_KEY"    =>    "conf_ENCODE_KEY",
        "NO_SHIPPING"        =>      "conf_NO_SHIPPING",
        "NO_SHIPTO"        =>      "conf_NO_SHIPTO",
        "AFFILIATE_ENABLE"        =>      "conf_AFFILIATE_ENABLE",
        "PSHOP_ALLOW_FRONTENDADMIN_FOR_NOBACKENDERS" => "conf_PSHOP_ALLOW_FRONTENDADMIN_FOR_NOBACKENDERS",
        "PSHOP_IMG_RESIZE_ENABLE" => "conf_PSHOP_IMG_RESIZE_ENABLE",
        "PSHOP_IMG_WIDTH" => "conf_PSHOP_IMG_WIDTH",
        "PSHOP_IMG_HEIGHT" => "conf_PSHOP_IMG_HEIGHT",
        "PSHOP_COUPONS_ENABLE" => "conf_PSHOP_COUPONS_ENABLE",
        "PSHOP_SHOW_PRODUCTS_IN_CATEGORY" => "conf_PSHOP_SHOW_PRODUCTS_IN_CATEGORY",
        "PSHOP_SHOW_TOP_PAGENAV"            =>      "conf_PSHOP_SHOW_TOP_PAGENAV",
        "PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS"          =>      "conf_PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS",
        "VM_CURRENCY_CONVERTER_MODULE" => "conf__VM_CURRENCY_CONVERTER_MODULE",
        "VM_CONTENT_PLUGINS_ENABLE" => "conf_VM_CONTENT_PLUGINS_ENABLE",
        "VM_ENABLE_COOKIE_CHECK" => "conf_VM_ENABLE_COOKIE_CHECK",
        'VM_FEED_ENABLED' => 'conf_VM_FEED_ENABLED',
        'VM_FEED_CACHE' => 'conf_VM_FEED_CACHE',
        'VM_FEED_CACHETIME' => 'conf_VM_FEED_CACHETIME',
        'VM_FEED_TITLE' => 'conf_VM_FEED_TITLE',
        'VM_FEED_TITLE_CATEGORIES' => 'conf_VM_FEED_TITLE_CATEGORIES',
        'VM_FEED_SHOW_IMAGES' => 'conf_VM_FEED_SHOW_IMAGES',
        'VM_FEED_SHOW_PRICES' => 'conf_VM_FEED_SHOW_PRICES',
        'VM_FEED_SHOW_DESCRIPTION' => 'conf_VM_FEED_SHOW_DESCRIPTION',
        'VM_FEED_DESCRIPTION_TYPE' => 'conf_VM_FEED_DESCRIPTION_TYPE',
        'VM_FEED_LIMITTEXT' => 'conf_VM_FEED_LIMITTEXT',
        'VM_FEED_MAX_TEXT_LENGTH' => 'conf_VM_FEED_MAX_TEXT_LENGTH',
        'VM_STORE_CREDITCARD_DATA' => 'conf_VM_STORE_CREDITCARD_DATA',
        'VM_ENCRYPT_FUNCTION' => 'conf_ENCRYPT_FUNCTION',
        'VM_COMPONENT_NAME' => 'option',
           "VM_LOGFILE_ENABLED"     =>      "conf_VM_LOGFILE_ENABLED",
           "VM_LOGFILE_NAME"     =>         "conf_VM_LOGFILE_NAME",
           "VM_LOGFILE_LEVEL"     =>         "conf_VM_LOGFILE_LEVEL",
           "VM_DEBUG_IP_ENABLED"     =>      "conf_VM_DEBUG_IP_ENABLED",
           "VM_DEBUG_IP_ADDRESS"     =>      "conf_VM_DEBUG_IP_ADDRESS",
           "VM_LOGFILE_FORMAT"       =>      "conf_VM_LOGFILE_FORMAT",

        // Begin Arrays
        "VM_BROWSE_ORDERBY_FIELDS"          =>      "conf_VM_BROWSE_ORDERBY_FIELDS",
        "VM_MODULES_FORCE_HTTPS"          =>      "conf_VM_MODULES_FORCE_HTTPS",
        "VM_CHECKOUT_MODULES"    =>    "VM_CHECKOUT_MODULES",
        "PSHOP_SHIPPING_MODULE"     =>      "conf_SHIPPING"
        );
        if( !vmisJoomla('1.5')) {
            $url = '$mosConfig_live_site.$app';
        } else {
            $url = "'".$db->getEscaped(vmGet($d,'conf_URL', $mosConfig_live_site ))."'";
        }
        $config = "<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
/**
* The configuration file for VirtueMart
*
* @package VirtueMart
* @subpackage core
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/

global \$mosConfig_absolute_path,\$mosConfig_live_site;
if( !class_exists( 'jconfig' )) {
    \$global_lang = \$GLOBALS['mosConfig_lang'];

    @include( dirname( __FILE__ ).'/../../../configuration.php' );

    \$GLOBALS['mosConfig_lang'] = \$mosConfig_lang = \$global_lang;
}
// Check for trailing slash
if( \$mosConfig_live_site[strlen( \$mosConfig_live_site)-1] == '/' ) {
    \$app = '';
}
else {
    \$app = '/';
}
// these path and url definitions here are based on the Joomla! Configuration
define( 'URL', $url );
define( 'SECUREURL', '".$db->getEscaped($d['conf_SECUREURL'])."' );

if ( (!empty(\$_SERVER['HTTPS']) && \$_SERVER['HTTPS'] != 'off') || \$_SERVER['SERVER_PORT'] == '443' ) {
    define( 'IMAGEURL', SECUREURL .'components/com_virtuemart/shop_image/' );
    \$path = SECUREURL;
} else {
    define( 'IMAGEURL', URL .'components/com_virtuemart/shop_image/' );
    \$path = URL;
}

\$DEFAULTTHEME = '$df_theme';

if (!defined('VM_THEMEURL')) {
    \$path .= 'components/com_virtuemart/themes/';
    define('VM_THEMEURL', \$path . (defined('CHAM_VM_THEME') ? CHAM_VM_THEME : \$DEFAULTTHEME ) . '/');
}

if (!defined('VM_THEMEPATH')) {
    define( 'VM_THEMEPATH', \$mosConfig_absolute_path.'/components/com_virtuemart/themes/'.(defined('CHAM_VM_THEME') ? CHAM_VM_THEME : \$DEFAULTTHEME).'/' );
}

define( 'COMPONENTURL', URL .'administrator/components/com_virtuemart/' );
define( 'ADMINPATH', \$mosConfig_absolute_path.'/administrator/components/com_virtuemart/' );
define( 'CLASSPATH', ADMINPATH.'classes/' );
define( 'PAGEPATH', ADMINPATH.'html/' );
define( 'IMAGEPATH', \$mosConfig_absolute_path.'/components/com_virtuemart/shop_image/' );\n\n";

        // LOOP THROUGH ALL CONFIGURATION VARIABLES
        while (list($key, $value) = each($my_config_array)) {
            if( $key == 'ENCODE_KEY' ) {
                $encode_key = vmGet( $d, $value );
                $config .= "define('ENCODE_KEY', '".str_replace('\'', "\'", $encode_key )."');\n";
                if( $encode_key != ENCODE_KEY ) {
                    // The ENCODE KEY has been changed! Now we need to re-encode the credit card information and transaction keys
                    $db->query( 'UPDATE #__{vm}_order_payment SET order_payment_number = '. VM_ENCRYPT_FUNCTION . '(' . VM_DECRYPT_FUNCTION . '(order_payment_number,\'' . $db->getEscaped(ENCODE_KEY).'\'), \''.$db->getEscaped($encode_key).'\')');
                    $db->query( 'UPDATE #__{vm}_payment_method SET payment_passkey = ' . VM_ENCRYPT_FUNCTION . '(' . VM_DECRYPT_FUNCTION . '(payment_passkey,\'' . $db->getEscaped(ENCODE_KEY) . '\'), \''.$db->getEscaped($encode_key).'\')');
                }
            }
            elseif( $key == 'VM_ENCRYPT_FUNCTION') {
                if( !defined('VM_ENCRYPT_FUNCTION')) define('VM_ENCRYPT_FUNCTION', 'ENCODE');
                if( empty( $d[$value] )) {
                    $d[$value] = 'ENCODE';
                }
                if( $d[$value] != VM_ENCRYPT_FUNCTION ) {
                    $encode_key = vmGet( $d, 'conf_ENCODE_KEY' );
                    $reencode_key = $encode_key != ENCODE_KEY ? $encode_key : ENCODE_KEY;
                    if( $d[$value] == 'ENCODE' ) $decryptor = 'DECODE';
                    elseif( $d[$value] == 'AES_ENCRYPT' ) $decryptor = 'AES_DECRYPT';
                    else $d[$value] = VM_ENCRYPT_FUNCTION;
                    // The Encryption Function has been changed. We need to decode and re-encrypt now!
                    $db->query( "UPDATE #__{vm}_order_payment SET order_payment_number = " . $d[$value] . '(' . VM_DECRYPT_FUNCTION . "(order_payment_number,'" . $db->getEscaped($reencode_key)."'), '" . $db->getEscaped($reencode_key)."')");
                    $db->query( 'UPDATE #__{vm}_payment_method SET payment_passkey = '.$d[$value] . '(' . VM_DECRYPT_FUNCTION . '(payment_passkey,\'' . $db->getEscaped($reencode_key) . '\'), \'' . $db->getEscaped($reencode_key).'\')');
                }
                $config .= "define('$key', '".$d[$value]."');\n";
            }
            elseif( $key == "PSHOP_SHIPPING_MODULE" ) {
                $config .= "\n/* Shipping Methods Definition */\nglobal \$PSHOP_SHIPPING_MODULES;\n";
                $i = 0;
                if( empty( $d['conf_SHIPPING'] )) $d['conf_SHIPPING'] = array('no_shipping');
                foreach( $d['conf_SHIPPING'] as $shipping_module) {
                    $config.= "\$PSHOP_SHIPPING_MODULES[$i] = \"$shipping_module\";\n";
                    $i++;
                }
            }
            elseif( $key == "VM_BROWSE_ORDERBY_FIELDS" ) {
                $config .= "\n/* OrderByFields */\nglobal \$VM_BROWSE_ORDERBY_FIELDS;\n";
                $config .= "\$VM_BROWSE_ORDERBY_FIELDS = array( ";
                $i= 0;
                if( empty( $d['conf_VM_BROWSE_ORDERBY_FIELDS'] ) ) {
                    $d['conf_VM_BROWSE_ORDERBY_FIELDS'] = array();
                }
                foreach( $d['conf_VM_BROWSE_ORDERBY_FIELDS'] as $orderbyfield) {
                    $config.= "'$orderbyfield'";
                    if( $i+1 < sizeof( $d['conf_VM_BROWSE_ORDERBY_FIELDS'] )) {
                        $config .= ',';
                    }
                    $i++;
                }
                $config.= " );\n";
            }
            elseif( $key == 'VM_MODULES_FORCE_HTTPS' ) {
                $config .= "\n/* Shop Modules that run with https only*/\nglobal \$VM_MODULES_FORCE_HTTPS;\n";
                $config .= "\$VM_MODULES_FORCE_HTTPS = array( ";
                $i= 0;
                if( empty( $d['conf_VM_MODULES_FORCE_HTTPS'] )) $d['conf_VM_MODULES_FORCE_HTTPS'] = array();
                foreach( $d['conf_VM_MODULES_FORCE_HTTPS'] as $https_module) {
                    $config.= "'".$db->getEscaped($https_module )."'";
                    if( $i+1 < sizeof( $d['conf_VM_MODULES_FORCE_HTTPS'] )) {
                        $config .= ',';
                    }
                    $i++;
                }
                $config.= " );\n";
            }
            elseif( $key == 'VM_CHECKOUT_MODULES' ) {
                $config .= "\n// Checkout Steps and their order\nglobal \$VM_CHECKOUT_MODULES;\n";
                $config .= "\$VM_CHECKOUT_MODULES = array( ";
                $i= 0;
                $max = 0;
                foreach( $d['VM_CHECKOUT_MODULES'] as $step ) {
                    $max = (int)$step['order'] > $max ? (int)$step['order'] : $max;
                    if( $step['name'] == 'CHECK_OUT_GET_FINAL_CONFIRMATION' ) {
                        $step['order'] = max( $max, $step['order'] ); // In case someone wants the final confirmation not as last step (so we force it to be the last step)
                    }
                    $enabled = !empty($step['enabled']) || $step['name'] == 'CHECK_OUT_GET_PAYMENT_METHOD' || $step['name'] == 'CHECK_OUT_GET_FINAL_CONFIRMATION';
                    $config.= "'".$step['name']."'=>array('order'=>".(int)$step['order'].",'enabled'=>".(int)$enabled.")";
                    if( $i+1 < sizeof( $d['VM_CHECKOUT_MODULES'] )) {
                        $config .= ",\n";
                    }
                    $i++;
                }
                $config.= " );\n";
            }
            elseif( $key == 'PSHOP_OFFLINE_MESSAGE' || $key == 'VM_ONCHECKOUT_LEGALINFO_SHORTTEXT'  ) {
                $config_val = str_replace("'","\'",vmGet( $d, $value) );
                $config .= "define('".$key."', '".$config_val."');\n";
            }
            else {
                $config_val = vmGet( $d, $value);
                $config_val = str_replace("'","\'", $config_val );
                $config_val = str_replace("\\\\","\\\\\\\\", $config_val );
                $config .= "define('".$key."', '".$config_val."');\n";
            }
        }

        $config .= "?>";

        file_put_contents(ADMINPATH ."virtuemart.cfg.php", $config );

        if( !empty($_REQUEST['ajax_request'] )) {
            $vmLogger->info( $VM_LANG->_('VM_CONFIGURATION_CHANGE_SUCCESS',false) );
        } else {
            vmRedirect( $_SERVER['PHP_SELF']."?page=admin.show_cfg&option=com_virtuemart", $VM_LANG->_('VM_CONFIGURATION_CHANGE_SUCCESS') );
        }
        return true;


    } // end function writeconfig
   
}

4 - Go into the VirtueMart admin backend, and click on "Configuration"

5 - in the Configuration tab, below "Generally prevent https connections" there's a setting called "Allow the inclusion of extended classes from the theme-directory". Turn it ON. Note: this setting is only available from VM 1.1.4.

6 - make sure you save your VM configuration TWICE after making the setting above (even if the setting above was already made). This ensures that the new code is used for creating the config file. i.e. save once to get VM to allow overrides, then once more to allow the override to create the new configuration file.

7 - In the SUCCEED Action or FAIL action of any Chameleon rule, you can use the following PHP code:

define('CHAM_VM_THEME', 'my_new_theme');

This will cause VM to use the theme components/com_virtuemart/themes/my_new_theme/

Bear in mind that you can only define a constant like this ONCE, so you can't have a series of Chameleon rules that each try to set a new value for the constant.


This was tested on VM 1.1.9 and works very well for me.

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Questions before buy: Two difficult challenges

This is really great support.Thanks for the help.

DonaldMartin
Beginner Modder
ranks
useravatar
Offline
1 Posts
Administrator has disabled public posting

Re: Questions before buy: Two difficult challenges

Hi Stephen,

First of all, THANKS A LOT for you effort and great support. I will buy pro.

I would like to know something about this comment:

"Bear in mind that you can only define a constant like this ONCE, so you can't have a series of Chameleon rules that each try to set a new value for the constant."

I would like to have 5 different themes based in 5 diferent urls, is it impossible with this method then?

Thanks again

juanon
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Questions before buy: Two difficult challenges

Ok, I need to clarify that a bit.

It's absolutely fine to have a series of rules that each check for a condition, then each set the constant (then exit the rule system).

What is not ok, is if you have 1 rule that succeeds and sets the constant to one value, then the next rule succeeds and tries to set the constant to a 2nd value. PHP will not allow you to do that.

The easiest way to prevent this from happening is to always exit the rule system after you've set a constant value. You do that with the control marked "Stop Processing". Then you can do as many different rules as you like.

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1684
Total Polls:
6
Total Posts:
5940
Posts this week:
1
User Info:
 
Total Users:
5162
Newest User:
david30x73
Members Online:
0
Guests Online:
90

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked