RtThemesSupport

rt13- single-products.php

Aug 18th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.43 KB | None | 0 0
  1. <?php
  2. /*
  3. * rt-theme product detail page
  4. */
  5. global $which_theme;
  6.  
  7. //taxonomy
  8. $taxonomy = 'product_categories';
  9.  
  10. //page link
  11. $link_page=get_permalink(get_option('rttheme_product_list'));
  12.  
  13. //category link
  14. $terms = get_the_terms($post->ID, $taxonomy);
  15. $i=0;
  16. if($terms){
  17.     foreach ($terms as $taxindex => $taxitem) {
  18.     if($i==0){
  19.         $link_cat=get_term_link($taxitem->slug,$taxonomy);
  20.         $term_slug = $taxitem->slug;
  21.         $term_id = $taxitem->term_id;
  22.         }
  23.     $i++;
  24.     }
  25. }
  26.  
  27. //check tabbed page?
  28.  
  29. $embeded_tabs=array('rt_product_video','rt_chart_file_url','rt_excel_file_url','rt_pdf_file_url','rt_word_file_url');
  30.  
  31. foreach ($embeded_tabs as $tab_id) {
  32.     if(trim(get_post_meta($post->ID, $tab_id, true))) $tabbed_page="yes";
  33. }
  34.  
  35. //free tabs count
  36. $tab_count=2;
  37. for($i=0; $i<$tab_count+1; $i++){
  38.     if (trim(get_post_meta($post->ID, 'rt_free_tab_'.$i.'_title', true)))  $tabbed_page="yes";
  39. }
  40.  
  41. get_header();
  42. wp_reset_query();
  43. if ($terms) {    
  44. ?>
  45.  
  46.     <!-- Page navigation-->
  47.         <div class="breadcrumb"><?php  rt_breadcrumb($post->ID); ?></div>
  48.     <!-- /Page navigation-->
  49.    
  50.     <!--  page contents -->
  51.     <div class="content sub">
  52.        <div class="left">
  53.  
  54.         <!-- Page Title -->
  55.              <h2><?php the_title(); ?></h2>
  56.              <div class="line"></div>
  57.         <!-- / Page Title -->
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                
  64.                 <?php
  65.                 //photos
  66.                
  67.                 //default photo
  68.                 if(get_post_meta($post->ID, 'rt_product_image_url', true)):
  69.                     $default_photo  = get_post_meta($post->ID, 'rt_product_image_url', true);
  70.                     $total_photo = 1;
  71.                 endif;
  72.                
  73.                
  74.                 //other photos
  75.                 if(trim(get_post_meta($post->ID, 'rt_other_images', true))):
  76.                     $other_photos = trim(preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", get_post_meta($post->ID, 'rt_other_images', true)));  
  77.                     $total_photo=$total_photo + count( explode("\n", $other_photos) );
  78.                 endif;
  79.                
  80.                
  81.                 //merge all
  82.                 $product_photos=$default_photo ."\n".$other_photos;    
  83.  
  84.                 ?>  
  85.                    
  86.                 <?php if($total_photo>1 || (!$default_photo && $total_photo==1) ):?>
  87.                 <!-- image slider with scroller -->
  88.                
  89.                 <div class="thumbs product_detail">
  90.                  
  91.                                  
  92.                     <!-- "previous page" action -->
  93.                     <?php if($total_photo>3):?><a class="prev browse _left"></a><?php endif;?>
  94.                    
  95.                         <!-- root element for scrollable -->
  96.                         <div class="scrollable <?php if($total_photo<=3):?>noarrow<?php endif;?>">  
  97.                        
  98.                             <!-- root element for the items -->
  99.                             <div class="items">
  100.  
  101.                              
  102.                               <?php
  103.                         //Product Photos
  104.                         $photo_count = 0;
  105.                         if (trim($product_photos)){
  106.                               $product_photos_split=explode("\n", $product_photos);  
  107.                         foreach ($product_photos_split as &$photo_url) {
  108.                         ?>
  109.                               <div>
  110.                                 <?php
  111.                                 $photo_title="";
  112.                                 list($photo_url,$photo_title) = split('[|]', $photo_url);
  113.                                 ?>
  114.                                     <?php
  115.                                     // Resize Portfolio Image
  116.                                     $imgURL = find_image_org_path($photo_url);
  117.                                     $crop   = true;
  118.                                     if($imgURL) $image_thumb = @vt_resize( '', $imgURL, 0, 150, ''.$crop.'' );
  119.                                     ?>
  120.                                     <a href="<?php echo $photo_url; ?>" title="<?php echo $photo_title?>" rel="prettyPhoto[product]" class="imgeffect plus"><img src="<?php echo $image_thumb["url"];?>" alt="" /></a>
  121.                                    
  122.                                </div>
  123.                         <?php $photo_count++;}}?>
  124.                                
  125.                             </div>
  126.                         </div>
  127.                
  128.                     <!-- "next page" action -->
  129.                     <?php if($total_photo>4):?><a class="next browse _right"></a><?php endif;?>
  130.                 </div>
  131.                 <!-- image slider with scroller -->
  132.  
  133.                 <div class="line"></div>
  134.                 <?php endif;?>
  135.    
  136.    
  137.     <?php
  138.     $product_video = trim(get_post_meta($post->ID, 'rt_product_video', true));
  139.     $rt_other_images = trim(get_post_meta($post->ID, 'rt_other_images', true));
  140.     $rt_chart_file_url  =  get_post_meta($post->ID, 'rt_chart_file_url', true);
  141.     $rt_excel_file_url  =get_post_meta($post->ID, 'rt_excel_file_url', true);
  142.     $rt_pdf_file_url  =get_post_meta($post->ID, 'rt_pdf_file_url', true);
  143.     $rt_word_file_url  =get_post_meta($post->ID, 'rt_word_file_url', true);
  144.     ?>
  145.    
  146.     <?php if($tabbed_page):?>
  147.     <div class="taps_wrap">
  148.         <!-- the tabs -->
  149.         <ul class="tabs">
  150.             <?php if(get_the_content()):?><li><a href="#"><?php _e('General Details','rt_theme');?></a></li><?php endif;?>
  151.             <?php if($product_video):?><li><a href="#"><?php _e('Product Video','rt_theme');?></a></li><?php endif;?>
  152.             <?php if($rt_chart_file_url || $rt_excel_file_url || $rt_pdf_file_url ||$rt_word_file_url ):?><li><a href="#"><?php _e('Documents','rt_theme');?></a></li><?php endif;?>
  153.             <?php
  154.             /*
  155.             *
  156.             *   Free Tabs
  157.             *  
  158.             */             
  159.             for($i=0; $i<$tab_count+1; $i++){
  160.                 if (trim(get_post_meta($post->ID, 'rt_free_tab_'.$i.'_title', true))){
  161.                   echo '<li><a href="#">'.get_post_meta($post->ID, 'rt_free_tab_'.$i.'_title', true).'</a></li>';
  162.                 }
  163.             }
  164.             ?>
  165.         </ul>
  166.     <?php endif;?>
  167.    
  168.        
  169.         <?php if(get_the_content()):?>
  170.         <!-- General Details -->
  171.         <div class="pane">
  172.  
  173.                     <?php
  174.                     // Resize Portfolio Image
  175.                     $imgURL = find_image_org_path($default_photo);
  176.                     $crop   = true;
  177.                     if($imgURL){
  178.                         $singlethumb_1 = @vt_resize( '', $imgURL, 200, 0, ''.$crop.'' ); //200px
  179.                         $singlethumb_2 = @vt_resize( '', $imgURL, 180, 0, ''.$crop.'' );  //180px
  180.                     }
  181.                     ?>
  182.                  
  183.                    
  184.               <!--product image-->
  185.               <?php if($default_photo && $total_photo==1 && !$tabbed_page):?>
  186.               <span class="border alignleft">
  187.               <a href="<?php echo $default_photo;?>" title="<?php the_title(); ?>" class="plus imgeffect" rel="prettyPhoto[product]"><img src="<?php echo $singlethumb_1["url"];?>" alt="<?php the_title(); ?>" /></a>
  188.               </span>
  189.             <?php elseif($default_photo && $total_photo==1):?>
  190.             <a href="<?php echo $default_photo;?>" title="<?php the_title(); ?>" class="plus imgeffect" rel="prettyPhoto[product]"><img src="<?php echo $singlethumb_2["url"];?>" alt="<?php the_title(); ?>" class="alignleft" /></a>
  191.               <?php endif;?>
  192.                                    
  193.             <?php the_content(); ?>
  194.             <div class="clear"></div>
  195.         </div>
  196.         <?php endif;?>
  197.  
  198.  
  199.         <?php if($product_video):?>
  200.         <!-- Product Video -->
  201.         <div class="pane">
  202.             <?php echo $product_video; ?>
  203.             <div class="clear"></div>
  204.         </div>
  205.         <?php endif;?>
  206.  
  207.         <?php if($rt_chart_file_url || $rt_excel_file_url || $rt_pdf_file_url ||$rt_word_file_url ):?>
  208.         <!-- Documents -->
  209.         <div class="pane">
  210.        
  211.             <!--doc icons-->
  212.             <ul class="doc_icons">
  213.                <?php if(get_post_meta($post->ID, 'rt_chart_file_url', true)):?><li><a href="<?php echo get_post_meta($post->ID, 'rt_chart_file_url', true); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icons/Chart_1.png" alt="" class="png" /><?php _e('Donwload Charts','rt_theme');?></a></li><?php endif;?>
  214.                <?php if(get_post_meta($post->ID, 'rt_excel_file_url', true)):?><li><a href="<?php echo get_post_meta($post->ID, 'rt_excel_file_url', true); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icons/File_Excel.png" alt="" class="png" /><?php _e('Download Excel File','rt_theme');?></a></li><?php endif;?>
  215.                <?php if(get_post_meta($post->ID, 'rt_pdf_file_url', true)):?><li><a href="<?php echo get_post_meta($post->ID, 'rt_pdf_file_url', true); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icons/File_Pdf.png" alt="" class="png" /><?php _e('Download PDF File','rt_theme');?></a></li><?php endif;?>
  216.                <?php if(get_post_meta($post->ID, 'rt_word_file_url', true)):?><li><a href="<?php echo get_post_meta($post->ID, 'rt_word_file_url', true); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/icons/Word.png" alt="" class="png" /><?php _e('Download Word File','rt_theme');?></a></li><?php endif;?>                            
  217.             </ul>
  218.             <div class="clear"></div>
  219.         </div>
  220.         <?php endif;?>
  221.        
  222.         <?php
  223.         /*
  224.         *
  225.         *   Free Tabs' Content
  226.         *  
  227.         */             
  228.         for($i=0; $i<$tab_count+1; $i++){
  229.             if (trim(get_post_meta($post->ID, 'rt_free_tab_'.$i.'_title', true))){
  230.               echo '<div class="pane">'.do_shortcode(get_post_meta($post->ID, 'rt_free_tab_'.$i.'_content', true)).'<div class="clear"></div></div>';
  231.             }
  232.         }
  233.         ?>
  234.    
  235.    
  236.     <?php if($tabbed_page):?>        
  237.     </div>
  238.     <?php else:?>
  239.     <div class="line"></div>
  240.     <?php endif;?>
  241.  
  242.     <?php
  243.     /*  Related Products */
  244.    
  245.     if (trim(get_post_meta($post->ID, 'rt_related_products', true))):?>
  246.     <!-- Related Products -->        
  247.    
  248.      
  249.     <div class="related_products">
  250.         <h5><?php _e('Related Products','rt_theme');?></h5>
  251.         <div class="line"></div>
  252.     </div>
  253.  
  254.  
  255.         <!-- Related Products -->                    
  256.  
  257.             <?php
  258.                $related_products = true;
  259.             $product_ids=explode("\n",  get_post_meta($post->ID, 'rt_related_products', true));
  260.            
  261.                 $p_id_list = "";
  262.                 foreach ($product_ids as $k => $product_id) {
  263.                 if (trim($product_id)):
  264.                     $p_id_list.=$product_id.",";  
  265.                 endif;
  266.                 }
  267.                
  268.                 $p_id_list = explode(',',$p_id_list);
  269.  
  270.                 //taxonomy
  271.                 $args=array(
  272.                 'post_type'=> 'products',
  273.                 'post_status'=> 'publish',
  274.                 'orderby'=> 'menu_order',
  275.                 'ignore_sticky_posts'=>1,
  276.                 'post__in' =>$p_id_list
  277.                 );
  278.                 get_template_part( 'product_loop', 'product_categories' );
  279.             ?>
  280.  
  281.         <!-- / Related Products -->
  282.         <?php endif;?>
  283.  
  284.     <div class="clear"></div>
  285.     </div>
  286.  
  287.  
  288.     <!-- side bar -->
  289.     <div class="sidebar"><div class="sidebar_back">
  290.     <?php include(get_template_directory()."/sidebar.php"); ?>
  291.     </div></div><div class="clear"></div>
  292.     <!-- / side bar -->
  293.    
  294.    
  295.  
  296.  
  297. <?php }else{ echo "<h3>No category has been selected for this product, please go Wordpress Admin -> Products -> (This Product) and select at least one category for this product!</h3>";} ?>
  298.    
  299.     </div>
  300. <?php get_footer();?>
Advertisement
Add Comment
Please, Sign In to add comment