News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Custom Fields Not working after 2 to 3 upgrade

Started by afri-can, April 15, 2015, 09:40:32 AM

Previous topic - Next topic

afri-can

Hi

I have just updated a VM site to version 3 and all my custom fields have stopped working
I did not set up the original site so I am not sure what was done



I understand that thing work a bit differently in VM3 with Custom Fields

There are two Area's that should show Custom Fields
$links and div id="tabs"

Any help or direction will be appreciated

The override for the page is as follows:

<?php

error_reporting
(0);

vmdebug('$this->category '.$this->category->category_name);

// Check to ensure this file is included in Joomla!

defined('_JEXEC') or die('Restricted access');



JHTML::_'behavior.modal' );





$modules_sub_category_children  JModuleHelper::getModules('sub-category-children');



function 
get_image_sizes($sourceImageFilePath,$maxResizeWidth$maxResizeHeight) {



  
// Get width and height of original image

  
$size getimagesize($sourceImageFilePath);

  if(
$size === FALSE) return FALSE// Error

  
$origWidth $size[0];

  
$origHeight $size[1];



  
// Change dimensions to fit maximum width and height

  
$resizedWidth $origWidth;

  
$resizedHeight $origHeight;

  if(
$resizedWidth $maxResizeWidth) {

    
$aspectRatio $maxResizeWidth $resizedWidth;

    
$resizedWidth round($aspectRatio $resizedWidth);

    
$resizedHeight round($aspectRatio $resizedHeight);

  }

  if(
$resizedHeight $maxResizeHeight) {

    
$aspectRatio $maxResizeHeight $resizedHeight;

    
$resizedWidth round($aspectRatio $resizedWidth);

    
$resizedHeight round($aspectRatio $resizedHeight);

  }



  
// Return an array with the original and resized dimensions

  
return array($origWidth$origHeight$resizedWidth,$resizedHeight);

}



?>






<div class="catalog">


    <!-- sub category product -->

    <?php if(!empty($this->products)): ?>



        <?php

        $product 
$this->products[0];

        
$product_id $product->virtuemart_product_id;

        
$link $product->link;

        
$name $product->product_name;

        
$text $product->product_desc;

        
$img_id $product->images[0]->virtuemart_media_id;

        if(
$img_id != 0){

            
$img $product->images[0]->file_url;

            
//diffrent size for twinstar image

            
if($product_id == 46 || $product_id == 443$arr get_image_sizes($img,304,176);

            else 
$arr get_image_sizes($img,304,91);

            
$img_desc $product->images[0]->file_description;

        }



        
$children '';

        
$links '';





        
/* custom fields id's only access: Category_Mechanical Design, Category_Architecture, Category_Applications Modules, Category_Features, Category_Specifications, Category_Configurations */

        
$include_arr = array(65,66,67,68,69,70);



        
/* array for all the relevant custom fields for tabs */

        
$tabs_arr = array();



        if(isset(
$product->customfields)){

            foreach(
$product->customfields as $customfield){

                
$id $customfield->virtuemart_custom_id;

                switch(
$id){

                    case 
3// creates products childrens list

                        
$children $customfield->display;

                        break;

                    case 
54// creates links under the main Image and equals to "category_Links" custome field.

                        
$links $customfield->custom_value;

                        break;

                    case (
in_array($id,$include_arr)): 

// creates All the Custome Field Tabs via The Product Managent (Back office)

                        
$title str_replace('Category_','',$customfield->custom_title);

                        
$value $customfield->custom_value;

                        
$tabs_arr[$id]['title'] = $title;

                        
$tabs_arr[$id]['value'] = $value;

                        break;

                    default:

                }

            }

        }

        
?>




        <div class="sub-category-product">



            <!-- name -->

            <h1><?php echo $name ?></h1>



            <div class="content">



                <!-- full description -->

                <div class="text">



                    <div class="right-container">



                        <!-- image -->

                        <?php if($img_id != 0): ?>

                        <a href="<?php echo $img ?>" title="<?php echo $name ?>" class="image" rel="product-image">

                            <div class="top"></div>

                            <div class="mid">

                                <img src="<?php echo $img ?>" alt="<?php echo $name ?>" width="<?php echo $arr[2?>" height="<?php echo $arr[3?>"/>

                                <span><?php echo $img_desc ?></span>

                            </div>

                            <div class="bottom"></div>

                        </a>

                        <?php endif ?>



                        <!-- links -->

                        <div class="links"><?php echo $links ?></div>



                    </div>



                    <?php echo $text ?>

                   

                    <div class="clr"></div>

                </div>

            </div>



            <!-- Twinster -->

            <?php if($product_id == 46): //special case XE?>

                <div class="products-links">

                    <h3>TwinStar Products</h3>

                    <?php $_SESSION['anova-counter'] = 0;

                    
$_SESSION['anova-sub-category'][0]['id'] = 32;

                    
$_SESSION['anova-sub-category'][0]['layout'] = 'list';

                    foreach(
$modules_sub_category_children as $module) echo JModuleHelper::renderModule($module);

                    unset(
$_SESSION['anova-sub-category']);

                    unset(
$_SESSION['anova-counter']);?>


                </div>

            <?php endif ?>



            <!-- Twinster -->

            <?php if($product_id == 443): //special case CXE?>

                <div class="products-links">

                    <h3>TwinStar Products</h3>

                    <?php $_SESSION['anova-counter'] = 0;

                    
$_SESSION['anova-sub-category'][0]['id'] = 76;

                    
$_SESSION['anova-sub-category'][0]['layout'] = 'list';

                    foreach(
$modules_sub_category_children as $module) echo JModuleHelper::renderModule($module);

                    unset(
$_SESSION['anova-sub-category']);

                    unset(
$_SESSION['anova-counter']);?>


                </div>

            <?php endif ?>





            <?php if(!empty($tabs_arr)): ?>

            <div id="tabs" class="tabs">



                <ul>

                    <?php $counter 0 ?>

                    <?php foreach($include_arr as $key => $value): ?>

                        <?php $counter++ ?>



                        <!-- make sure that the tab's title order will be as the order in $include_arr -->

                        <?php if(array_key_exists($value,$tabs_arr)):?>

                            <li <?php if($counter == count($tabs_arr)): ?><?php endif ?>><a href="#tabs-<?php echo $value ?>"><?php echo $tabs_arr[$value]['title'?></a></li>

                        <?php endif ?>



                    <?php endforeach ?>

                </ul>



                <?php foreach($include_arr as $key => $value): ?>



                    <!-- make sure that the tab's content order will be as the order in $include_arr -->

                    <?php if(array_key_exists($value,$tabs_arr)):?>

                        <div id="tabs-<?php echo $value ?>">

                            <div class="tab-content">

                                <?php echo $tabs_arr[$value]['value'?>



                                <?php if($value == 70): //configuration TAB?>



                                    <ul class="anchors">

                                        <li><a href="#analog">Analog Models</a></li>

                                        <li><a href="#bri">BRI ISDN Models</a></li>

                                        <?php if($product_id != 24 /* xr 1000 */ && $product_id != 438 /* cxr 1000 */ ):?><li><a href="#pri">PRI/R2 Models</a></li><?php endif ?>

                                    </ul>

                                    <?php

                                    $counter 
0;

                                    
$_SESSION['anova-counter']= 0;

                                    foreach (
$this->category->children as $category ){

                                        
$catdesc $category->category_description;

                                        
$catid $category->virtuemart_category_id;

                                        
$_SESSION['anova-sub-category'][$counter]['id'] = $catid;

//echo $_SESSION['anova-sub-category'][$counter]['id'];

                                        
$_SESSION['anova-sub-category'][$counter]['layout'] = $catdesc;

//echo $_SESSION['anova-sub-category'][$counter]['layout'];

                                        
foreach($modules_sub_category_children as $module) echo JModuleHelper::renderModule($module); 

                                        
$counter++;

                                    }

                                    
?>




                                <?php endif ?>



                            </div>

                        </div>

                    <?php endif ?>



                <?php endforeach ?>



            </div>

            <?php endif ?>



        </div>



    <?php endif ?>





    <?php unset($_SESSION['anova-sub-category']); ?>

    <?php unset($_SESSION['anova-counter']); ?>



    <div class="extra-container">

        <div class="modify">Last Updated ( <?php echo JHtml::_('date'$this->item->modifiedJText::_('l, d M Y')) ?> )</div>



        <div class="social-buttons">

            <g:plusone size="medium" annotation="none"></g:plusone>



            <!-- addthis -->

            <a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=250&amp;pubid=xa-504717bc255fec7c"><img src="http://s7.addthis.com/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a>

            <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-504717bc255fec7c"></script>



            <!-- send -->

            <a class="send-friend" href="http://www.smartaddon.com/?share" title="Tell a Friend" onclick="return sa_tellafriend('','email')"></a>



            <div class="clr"></div>

        </div>

        <div class="clr"></div>

    </div>

</div>

GJC Web Design

have u tried the admin tools -> Update vm2 order format of customfields to vm3 format
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation