RtThemesSupport

Add General details field to single product

Nov 20th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.92 KB | None | 0 0
  1. <?php
  2. #
  3. # rt-theme product detail page
  4. #
  5.  
  6. //flush rewrite rules
  7. add_action('init', 'flush_rewrite_rules');
  8.  
  9. //taxonomy
  10. $taxonomy = 'product_categories';
  11.  
  12. //page link
  13. $link_page = get_permalink(get_option('rttheme_product_list'));
  14.  
  15. //category link
  16. $terms = get_the_terms($post->ID, $taxonomy);
  17. $i=0;
  18. if($terms){
  19.     foreach ($terms as $taxindex => $taxitem) {
  20.     if($i==0){
  21.         $link_cat=get_term_link($taxitem->slug,$taxonomy);
  22.         $term_slug = $taxitem->slug;
  23.         $term_id = $taxitem->term_id;
  24.         }
  25.     $i++;
  26.     }
  27. }
  28.  
  29. get_header();
  30. ?>
  31.  
  32.  
  33. <?php
  34. #
  35. # page layout - sidebar
  36. #
  37. $sidebar    =   (get_post_meta($post->ID, THEMESLUG.'custom_sidebar_position', true)) ? get_post_meta($post->ID, THEMESLUG.'custom_sidebar_position', true) : get_option(THEMESLUG."_sidebar_position_product");
  38.  
  39. #
  40. # content width
  41. #
  42. $content_width = ($sidebar=="full") ? 960 : 710;
  43.  
  44. #
  45. #   call sub page header
  46. #
  47. get_template_part( 'sub_page_header', 'sub_page_header_file' );
  48.  
  49. #
  50. #   call the sub content holder 1st part
  51. #
  52. sub_page_layout("subheader",$sidebar);
  53. ?>
  54.  
  55.     <?php
  56.     if (have_posts()) : while (have_posts()) : the_post();
  57.  
  58.         // featured images
  59.         $rt_gallery_images          = get_post_meta( $post->ID, THEMESLUG . "rt_gallery_images", true );
  60.         $rt_gallery_image_titles    = get_post_meta( $post->ID, THEMESLUG . "rt_gallery_image_titles", true );
  61.         $rt_gallery_image_descs         = get_post_meta( $post->ID, THEMESLUG . "rt_gallery_image_descs", true );
  62.    
  63.         //values
  64.         $rt_attached_documents          = get_post_meta($post->ID, THEMESLUG.'attached_documents', true);
  65.         $content                    = apply_filters('the_content',(get_the_content()));
  66.         $title                  = get_the_title();
  67.         $permalink              = get_permalink();
  68.         $order_button               = get_post_meta($post->ID, THEMESLUG.'order_button', true);
  69.         $order_button_text          = get_post_meta($post->ID, THEMESLUG.'order_button_text', true);
  70.         $order_button_link          = get_post_meta($post->ID, THEMESLUG.'order_button_link', true);
  71.         $related_products           = get_post_meta($post->ID, THEMESLUG.'related_products[]', true);
  72.         $short_desc             = get_post_meta($post->ID, THEMESLUG.'short_description', true);
  73.    
  74.  
  75.         //next and previous links
  76.         if(get_option(THEMESLUG.'_hide_product_navigation')){
  77.             $prev = mod_get_adjacent_post(true,true,'', $taxonomy,'date');
  78.             $next = mod_get_adjacent_post(true,false,'', $taxonomy,'date');
  79.             $prev_post_link_url     = ($prev) ? get_permalink( $prev->ID ) : "";
  80.             $next_post_link_url     = ($next) ? get_permalink( $next->ID ) : "";
  81.             $next_post_link     = ($next_post_link_url) ? '<a href="'.$next_post_link_url.'" title="" class="p_next"><span>'.__( 'Next →', 'rt_theme').'</span></a>' : false ;
  82.             $prev_post_link     = ($prev_post_link_url) ? '<a href="'.$prev_post_link_url.'" title="" class="p_prev"><span>'.__( '← Previous', 'rt_theme').'</span></a>': false ;              
  83.             $add_class          = ($prev_post_link==false) ? "single" : ""; // if previous link is empty add class to fix white border
  84.             $before_sidebar     = ($next_post_link || $prev_post_link) ? '<div class="post-navigations  margin-b20 '.$add_class.'">'.$prev_post_link. '' .$next_post_link.'</div>' : "";
  85.         }
  86.  
  87.         //free tabs count
  88.         $tab_count=3;
  89.         for($i=0; $i<$tab_count+1; $i++){
  90.             if (trim(get_post_meta($post->ID, THEMESLUG.'free_tab_'.$i.'_title', true)))  $tabbed_page="yes";
  91.         }
  92.     ?>
  93.  
  94.     <!-- product title  -->  
  95.     <div class="box one box-shadow margin-b30">  
  96.         <div class="head_text nomargin">
  97.             <div class="arrow"></div><!-- arrow -->
  98.             <h2 class="product"><?php the_title(); ?></h2>
  99.         </div>
  100.     </div>  
  101.     <!-- / product title  -->
  102.  
  103.     <!-- product images -->
  104.  
  105.         <?php if (is_array($rt_gallery_images)):
  106.                
  107.         //is crop active       
  108.         $crop = (get_option(THEMESLUG.'_single_product_image_crop')) ? true : false ;
  109.  
  110.  
  111.         //Thumbnail dimensions
  112.         $w = (get_option(THEMESLUG.'_single_product_image_width')) ? get_option(THEMESLUG.'_single_product_image_width') : 147; // image max width
  113.         $h = ($crop) ? (get_option(THEMESLUG.'_single_product_image_height')) ? get_option(THEMESLUG.'_single_product_image_height') : 147 : 10000; // image max height
  114.         ?>
  115.        
  116.             <?php if(count($rt_gallery_images)>1):?>
  117.                 <!-- product image slider -->
  118.    
  119.                     <?php  
  120.                     //Product Photos
  121.                     $imagesHTML = "";
  122.                     $maxHeight  = 0;
  123.  
  124.  
  125.                         for ($i=0; $i < (count($rt_gallery_images)); $i++) {
  126.                            
  127.                             //resize the photo  
  128.                             $photo_url      = find_image_org_path(trim($rt_gallery_images[$i]));
  129.                             $image_thumb        = @vt_resize( '', trim(trim($rt_gallery_images[$i])), $w, $h, $crop );                                                 
  130.                             $maxHeight      = ($image_thumb['height']>$maxHeight) ? $image_thumb['height'] : $maxHeight ;
  131.                              
  132.                             $imagesHTML .=  '<li><a class="imgeffect magnifier" href="'.$photo_url.'" data-gal="prettyPhoto[rt_theme_products]" title="'.$rt_gallery_image_descs[$i].'"><img src="'.$image_thumb['url'].'" width="'.$w.'" alt="'.$rt_gallery_image_titles[$i].'" /></a></li>';
  133.  
  134.                         }
  135.  
  136.                     ?>
  137.                    
  138.                 <div class="carousel box-shadow" style="height:<?php echo $maxHeight+42;?>px;overflow:hidden;"><ul id="product_thumbnails" class="jcarousel-skin-rt"><?php echo $imagesHTML;?></ul></div>
  139.                 <div class="space margin-t10 margin-b20"></div>
  140.             <?php endif;?>
  141.         <?php endif;?>
  142.     <!-- / product images -->  
  143.    
  144.  
  145.     <!-- PRODUCT TABS -->
  146.  
  147.     <!-- TABS WRAP -->             
  148.        
  149.         <?php if(@$tabbed_page):?>
  150.         <div class="taps_wrap box-shadow">
  151.             <!-- the tabs -->
  152.             <ul class="tabs">
  153.                 <?php if($content):?>
  154.                 <?php if (trim(get_post_meta($post->ID, THEMESLUG.'general_details_title', true))) {
  155.                         echo '<li><a href="#">'.get_post_meta($post->ID, THEMESLUG."general_details_title", true).'</a></li>';
  156.                     }
  157.                 else   
  158.                     {  
  159.                         echo '<li><a href="#">';
  160.                         _e("General Details","rt_theme");
  161.                         echo '</a></li>';
  162.                 }
  163.                 ?>
  164.                 <?php endif;?>
  165.                 <?php
  166.                 #
  167.                 #   Free Tabs
  168.                 #  
  169.                 for($i=0; $i<$tab_count+1; $i++){
  170.                     if (trim(get_post_meta($post->ID, THEMESLUG.'free_tab_'.$i.'_title', true))){
  171.                         echo '<li><a href="#">'.get_post_meta($post->ID, THEMESLUG.'free_tab_'.$i.'_title', true).'</a></li>';
  172.                     }
  173.                 }
  174.                
  175.                 #
  176.                 #   Attached Documents
  177.                 #      
  178.                 if($rt_attached_documents){
  179.                     echo '<li><a href="#">'.__('Attached Documents','rt_theme').'</a></li>';
  180.                 }
  181.                 ?>
  182.        
  183.             </ul>
  184.         <?php endif;?>
  185.        
  186.         <?php if($content):?>                              
  187.         <!-- General Details -->
  188.        
  189.         <?php if(@$tabbed_page):?><div class="pane"><?php else:?><div class="box one box-shadow margin-b30"><?php endif;?>
  190.             <div>
  191.             <?php if(is_array($rt_gallery_images) && count($rt_gallery_images)==1): // only 1 image for this product ?>
  192.                 <?php
  193.                 //resize the photo  
  194.                 $photo_url      = (is_array($rt_gallery_images)) ? find_image_org_path($rt_gallery_images[0]) : "";
  195.                 $image_thumb        = @vt_resize( '', trim($photo_url), 300, 600, false ); 
  196.                 //echo $rt_gallery_image_descs[0]; die;
  197.                 ?>
  198.                 <a href="<?php echo $photo_url;?>" title="<?php echo $rt_gallery_image_descs[0];?>" data-gal="prettyPhoto[rt_theme_products]" class="imgeffect magnifier alignleft" ><img src="<?php echo $image_thumb['url'];?>" alt="" /></a>
  199.             <?php endif;?>
  200.            
  201.             <?php echo $content;?>
  202.             </div>
  203.             <div class="clear"></div>
  204.         </div>
  205.         <?php endif;?>
  206.  
  207.         <?php
  208.         #
  209.         #   Free Tabs' Content
  210.         #  
  211.         for($i=0; $i<$tab_count+1; $i++){
  212.             if (trim(get_post_meta($post->ID, THEMESLUG.'free_tab_'.$i.'_title', true))){
  213.                  
  214.                  
  215.                 echo '<div class="pane">';
  216.                 echo (apply_filters('the_content',get_post_meta($post->ID, THEMESLUG.'free_tab_'.$i.'_content', true)));
  217.                 echo '<div class="clear"></div></div>';
  218.             }
  219.         }
  220.         ?>
  221.  
  222.         <?php if($rt_attached_documents):?>
  223.        
  224.        
  225.  
  226.                
  227.             <?php if(@!$tabbed_page):?><div class="line"></div><?php endif;?>
  228.             <div class="pane">
  229.                 <!-- document icons -->
  230.                 <ul class="doc_icons">
  231.                    
  232.                     <?php
  233.  
  234.                     if(trim($rt_attached_documents)):
  235.                         $rt_attached_documents  = trim(preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $rt_attached_documents));  
  236.                         $rt_attached_documents  = explode("\n", $rt_attached_documents);
  237.                     endif;
  238.                    
  239.                     if(is_array($rt_attached_documents)){
  240.                         foreach($rt_attached_documents as $fileURL){
  241.                            
  242.                             if(strpos($fileURL, ".doc")){
  243.                                 echo '<a href="'.$fileURL.'" title="'.__('Download Word File','rt_theme').'"><img src="'.THEMEURI.'/images/assets/icons/Word.png" alt="'.__('Download Word File','rt_theme').'" class="png" /></a>';
  244.                             }
  245.  
  246.                             elseif(strpos($fileURL, ".xls")){
  247.                                 echo '<a href="'.$fileURL.'" title="'.__('Download Excel File','rt_theme').'"><img src="'.THEMEURI.'/images/assets/icons/File_Excel.png" alt="'.__('Download Excel File','rt_theme').'" class="png" /></a>';
  248.                             }
  249.  
  250.                             elseif(strpos($fileURL, ".pdf")){
  251.                                 echo '<a href="'.$fileURL.'" title="'.__('Download PDF File','rt_theme').'"><img src="'.THEMEURI.'/images/assets/icons/File_Pdf.png" alt="'.__('Download PDF File','rt_theme').'" class="png" /></a>';
  252.                             }                          
  253.  
  254.                             elseif(strpos($fileURL, ".ppt")){
  255.                                 echo '<a href="'.$fileURL.'" title="'.__('Download PowerPoint File','rt_theme').'"><img src="'.THEMEURI.'/images/assets/icons/File_PowerPoint.png" alt="'.__('Download PowerPoint File','rt_theme').'" class="png" /></a>';
  256.                             }                          
  257.  
  258.                             else{
  259.                                 echo '<a href="'.$fileURL.'" title="'.__('Download File','rt_theme').'"><img src="'.THEMEURI.'/images/assets/icons/File.png" alt="'.__('Download File','rt_theme').'" class="png" /></a>';
  260.                             }
  261.                            
  262.                         }
  263.                     }
  264.                     ?>
  265.  
  266.                 </ul>
  267.                 <!-- document icons -->
  268.             </div>
  269.         <?php endif;?>
  270.                
  271.                
  272.         <?php if(@$tabbed_page):?>        
  273.         </div><div class="clear"></div>
  274.         <?php endif;?>
  275.  
  276.     <!-- / PRODUCT TABS -->
  277.  
  278.             <?php
  279.                     if($sidebar=="full"){
  280.                         echo $before_sidebar;
  281.                     }
  282.             ?>
  283.  
  284.  
  285.     <div class="space v_10"></div>
  286.     <!-- / content -->     
  287.  
  288.    
  289.     <!-- RELATED PRODUCTS -->
  290.         <?php
  291.         if(is_array($related_products)){
  292.         ?>
  293.                         <!-- title -->
  294.                 <div class="box one box-shadow margin-b30">
  295.                         <!-- page title -->
  296.                         <div class="head_text nomargin">
  297.                             <div class="arrow"></div><!-- arrow -->
  298.                             <h4 class="product"><?php echo __("Related Products",'rt_theme');?></h4>
  299.                         </div>
  300.                         <!-- /page title -->
  301.                 </div>
  302.                
  303.         <?php
  304.             //taxonomy
  305.             $args=array(
  306.                 'post_type'           => 'products',
  307.                 'post_status'         => 'publish',
  308.                 'orderby'             => 'menu_order',
  309.                 'ignore_sticky_posts' => 1,
  310.                 'posts_per_page'      => 1000,
  311.                 'post__in'            => $related_products
  312.             );
  313.  
  314.             //item width - column count
  315.             $item_width = get_option(THEMESLUG."_related_product_layout");
  316.             get_template_part( 'product_loop', 'product_categories' );
  317.         echo '<div class="space margin-b30"></div>';
  318.         }
  319.         ?>
  320.  
  321.     <!-- / RELATED PRODUCTS -->
  322.  
  323.     <?php endwhile;?>
  324.    
  325.     <?php else: ?>
  326.         <p><?php _e( 'Sorry, no page found.', 'rt_theme'); ?></p>
  327.     <?php endif; ?>
  328.    
  329.    
  330. <?php
  331. #
  332. #   call the sub content holder 2nd part
  333. #
  334. sub_page_layout("subfooter",$sidebar);
  335.  
  336. get_footer();
  337. ?>
Advertisement
Add Comment
Please, Sign In to add comment