Doesn't work with my theme's "portfolio" section

Having Problems? Need Help? Post here!

Doesn't work with my theme's "portfolio" section

Postby l736k » Sat May 26, 2012 8:44 am

Hi, i have a "portfolio" section in my theme but the plugin doesn't work here. It prints the 3 languages in sequence (so it doesn't detect the languages). I've tried both with [:en] or <!--en--> tags. I post here the portfolio section's code as it's not long, hope the problem is something here:

Code: Select all
<?php
/**
* Template Name: Portfolio
* The main template file for display portfolio page.
*
* @package WordPress
*/

session_start();

if(!isset($hide_header) OR !$hide_header)
{
   get_header();
}

if(isset($_SESSION['pp_portfolio_style']))
{
   $pp_portfolio_style = $_SESSION['pp_portfolio_style'];
}
else
{
   $pp_portfolio_style = get_option('pp_portfolio_style');
}

if(empty($pp_portfolio_style))
{
   $pp_portfolio_style = '2';
}

include (TEMPLATEPATH . "/templates/template-portfolio-".$pp_portfolio_style.".php");

?>
l736k
 
Posts: 11
Joined: Thu Apr 21, 2011 10:50 pm

Re: Doesn't work with my theme's "portfolio" section

Postby l736k » Mon May 28, 2012 9:03 pm

up please...
l736k
 
Posts: 11
Joined: Thu Apr 21, 2011 10:50 pm

Re: Doesn't work with my theme's "portfolio" section

Postby Nikola Nikolov » Wed May 30, 2012 2:05 am

Can you please post the code from "/templates/template-portfolio-2.php" and perhaps "/templates/template-portfolio-1.php" (I'm not sure about the exact name of the template files, but it should be similar to "/templates/template-portfolio-*.php" - if you find other templates, that match this pattern, share them as well).

In case the code is too long, here is what you should be looking for:
Code: Select all
$*->post_title

Where * is any string(it's quite-likely be "portfolio" or "portfolio_item"). What you need to do is replace the above code(wherever you find it) with the following:
Code: Select all
get_the_title($*->ID)


This should fix your problem.

Please make a back-up copy of all files, before you start modifying them ;)
Nikola Nikolov
 
Posts: 175
Joined: Wed May 16, 2012 3:46 pm

Re: Doesn't work with my theme's "portfolio" section

Postby l736k » Wed May 30, 2012 8:42 am

thanks a lot moonwatch! it worked for the title...now the problem remains on the content, it still shows up as the concatenation of the translated texts...
i have 5 files that match your pattern...here's one of them:
template-portfolio-f2.php
Code: Select all
<?php
/**
* The main template file for display portfolio page.
*
* @package WordPress
*/

if(!isset($hide_header) OR !$hide_header)
{
   get_header();
}

$caption_class = "page_caption";
$portfolio_sets_query = '';

if(!empty($term))
{
   $portfolio_sets_query.= $term;
   
   $obj_term = get_term_by('slug', $term, 'portfoliosets');
   $custom_title = 'Sets / '.$obj_term->name;
}
else
{
   $custom_title = get_the_title();
}

/**
*   Get Current page object
**/
$page = get_page($post->ID);

/**
*   Get current page id
**/

if(!isset($current_page_id) && isset($page->ID))
{
    $current_page_id = $page->ID;
}

$caption_style = get_post_meta($current_page_id, 'caption_style', true);

if(empty($caption_style))
{
   $caption_style = 'Title & Description';
}

if(!isset($hide_header) OR !$hide_header)
{
?>            
      <div class="page_caption">
         <div class="caption_inner">
            <div class="caption_header">
               <h1 class="cufon"><?php echo $custom_title; ?></h1>
            </div>
            <div class="caption_desc">
               <?php
                  $page_desc = get_post_meta($current_page_id, 'page_desc', true);
                  
                  if(!empty($page_desc))
                  {
                     echo $page_desc;
                  }
               ?>
            </div>
         </div>
         <br class="clear"/>
      </div>
      
      </div>
      
      <div id="header_pattern"></div>
      <br class="clear"/>
      <!-- Begin content -->
      <div id="content_wrapper">
         
         <div class="inner">
         
            <!-- Begin main content -->
            <div class="inner_wrapper">
            
            <div class="standard_wrapper">
               <br class="clear"/><hr/><br/>
<?php
}
?>   
                        
                           <?php
                              if(!isset($hide_header) OR !$hide_header && !empty($page->post_content))
                              {
                           ?>
                              <div style="width:100%;margin-bottom:40px">
                                 <?php echo $page->post_content; ?>
                              </div>
                           <?php
                              }
                              elseif(!empty($pp_homepage))
                              {
                                 $page_obj = get_page($pp_homepage);
                           ?>
                              <div style="width:100%;margin-bottom:40px">
                                 <?php echo $page_obj->post_content; ?>
                              </div>
                           <?php   
                              }
                           ?>
                        
                           <?php 
                           $pp_portfolio_display_set = get_option('pp_portfolio_display_set');
                                                      
                           if(!empty($pp_portfolio_display_set))
                           {
                              $sets_arr = get_terms('portfoliosets', 'hide_empty=0&hierarchical=0&parent=0');
                              
                              if(!empty($sets_arr))
                              {
                           ?>
                              <h2 class="widgettitle" style="width:100%">Filter by Set</h2>
                              <ul class="portfolio-main filter full">
                                 <li class="all-projects active"><a href="javascript:;">All</a></li>
                                 <?php
                                    foreach($sets_arr as $key => $set_item)
                                    {
                                 ?>
                                 <li class="cat-item <?php echo $set_item->slug; ?>" data-type="<?php echo $set_item->slug; ?>" style="clear:none">
                                    <a href="javascript:;" title="<?php echo $set_item->name; ?>"><?php echo $set_item->name; ?></a>
                                 </li>
                                 <?php
                                    }
                                 ?>
                              </ul>
                              
                           <?php
                              }
                           ?>
                           <br class="clear"/><br/>
                           <?php
                           }
                           ?>
                        

                  
                  <br class="clear"/>
                  
                  <!-- Begin portfolio content -->
                  
                  <?php
                     $menu_sets_query = '';

                     $portfolio_items = -1;
                     
                     $portfolio_sort = get_option('pp_portfolio_sort');
                     if(empty($portfolio_sort))
                     {
                        $portfolio_sort = 'DESC';
                     }
                     
                     //prepare data for pagintion
                     $offset_query = '';
                     if(!isset($_GET['page']) OR empty($_GET['page']) OR $_GET['page'] == 1)
                     {
                         $current_page = 1;
                     }
                     else
                     {
                         $current_page = $_GET['page'];
                         $offset = (($current_page-1) * $portfolio_items);
                     }
                     
                     $args = array(
                        'numberposts' => $portfolio_items,
                        'order' => $portfolio_sort,
                        'orderby' => 'date',
                        'post_type' => array('portfolios'),
                        'offset' => $offset,
                     );
                     if(!empty($term))
                     {
                        $args['portfoliosets'].= $term;
                     }
                     
                     $page_photo_arr = get_posts($args);
                     
                     
                     //Get all portfolio items for paging
                     
                     $args = array(
                        'numberposts' => -1,
                        'order' => $portfolio_sort,
                        'orderby' => 'date',
                        'post_type' => array('portfolios'),
                     );
                     if(!empty($term))
                     {
                        $args['portfoliosets'].= $term;
                     }
                     
                     $all_photo_arr = get_posts($args);
                     $total = count($all_photo_arr);
                     $cur_post = 0;
      
                     if(isset($page_photo_arr) && !empty($page_photo_arr))
                     {
                        
                  ?>
                        <div class="portfolio-content section content clearfix" style="920px">
                                 <?php

                                    foreach($page_photo_arr as $key => $portfolio_item)
                                    {
                                       $image_url = '';
                        
                                       if(has_post_thumbnail($portfolio_item->ID, 'large'))
                                       {
                                          $image_id = get_post_thumbnail_id($portfolio_item->ID);
                                          $image_url = wp_get_attachment_image_src($image_id, 'full', true);
                                       }
                                       
                                       $last_class = ' last';
                                       $line_break = '<br class="clear"/>';
                                       
                                       $portfolio_link_url = get_post_meta($portfolio_item->ID, 'portfolio_link_url', true);
                                       
                                       if(empty($portfolio_link_url))
                                       {
                                          $permalink_url = get_permalink($portfolio_item->ID);
                                       }
                                       else
                                       {
                                          $permalink_url = $portfolio_link_url;
                                       }
                                       
                                       $portfolio_item_set = '';
                                       $portfolio_item_sets = wp_get_object_terms($portfolio_item->ID, 'portfoliosets');
                                       //pp_debug($portfolio_item_sets);
                                       
                                       $portfolio_item_set = '';
                                       if(is_array($portfolio_item_sets))
                                       {
                                          foreach($portfolio_item_sets as $set)
                                          {
                                             $portfolio_item_set.= $set->slug.' ';
                                          }
                                       }
                                       
                                       $pp_portfolio_image_height = 227;
                                 ?>
                                             <div data-id="post-<?php echo $key+1; ?>" class="<?php echo $portfolio_item_set; ?> project" data-type="<?php echo $portfolio_item_set; ?>" style="width:920px;margin-bottom:50px;height:<?php echo $pp_portfolio_image_height+10; ?>px">
                                             <div style="float:left;width:640px">
                                             <?php
                                                $portfolio_type = get_post_meta($portfolio_item->ID, 'portfolio_type', true);
                                                $portfolio_video_id = get_post_meta($portfolio_item->ID, 'portfolio_video_id', true);
                                                switch($portfolio_type)
                                                {
                                                case 'External Link':
                                                default:
                                             ?>
                                             <div class="portfolio642_shadow">
                                                <a title="<?php echo get_the_title($portfolio_item->ID); ?>" href="<?php echo $permalink_url; ?>">
                                                   <img src="<?php echo get_stylesheet_directory_uri(); ?>/timthumb.php?src=<?php echo $image_url[0]?>&amp;h=<?php echo $pp_portfolio_image_height; ?>&amp;w=640&amp;zc=1" alt="" class="img_nofade frame" width="640" height="<?php echo $pp_portfolio_image_height; ?>"/>
                                                </a>
                                                <img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_zoom.png" style="margin-top:-30px;margin-left:300px;z-index:9999"/>
                                             </div>
                                             
                                             <?php
                                                break;
                                                //end external link
                                                
                                                case 'Image':
                                             ?>
                                             <div class="portfolio642_shadow">
                                                <a title="<?php echo get_the_title($portfolio_item->ID); ?>" href="<?php echo $image_url[0]; ?>" class="img_frame">
                                                   <img src="<?php echo get_stylesheet_directory_uri(); ?>/timthumb.php?src=<?php echo $image_url[0]?>&amp;h=<?php echo $pp_portfolio_image_height; ?>&amp;w=640&amp;zc=1" alt="" class="img_nofade frame" width="640" height="<?php echo $pp_portfolio_image_height; ?>"/>
                                                </a>
                                                <img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_zoom.png" style="margin-top:-30px;margin-left:300px;z-index:9999"/>
                                             </div>
                                             
                                             <?php
                                                break;
                                                //end image
                                                
                                                case 'Youtube Video':
                                             ?>
                                             <div class="portfolio642_shadow">
                                                <a title="<?php echo get_the_title($portfolio_item->ID); ?>" href="#video_<?php echo $portfolio_video_id; ?>" class="lightbox_youtube">
                                                   <img src="<?php echo get_stylesheet_directory_uri(); ?>/timthumb.php?src=<?php echo $image_url[0]?>&amp;h=<?php echo $pp_portfolio_image_height; ?>&amp;w=640&amp;zc=1" alt="" class="img_nofade frame" width="640" height="<?php echo $pp_portfolio_image_height; ?>"/>
                                                </a>
                                                <img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_play.png" style="margin-top:-30px;margin-left:300px;z-index:9999"/>
                                             </div>
                                                
                     <div style="display:none;">
                         <div id="video_<?php echo $portfolio_video_id; ?>" style="width:640px;height:385px">
                            
                             <object type="application/x-shockwave-flash" data="http://www.youtube.com/v/<?php echo $portfolio_video_id; ?>" style="width:640px;height:385px">
                                 <param name="movie" value="http://www.youtube.com/v/<?php echo $portfolio_video_id; ?>" />
                             </object>
                            
                         </div>   
                     </div>
                                             
                                             <?php
                                                break;
                                                //end image
                                             
                                             case 'Vimeo Video':
                                             ?>
                                             <div class="portfolio642_shadow">
                                                <a title="<?php echo get_the_title($portfolio_item->ID); ?>" href="#video_<?php echo $portfolio_video_id; ?>" class="lightbox_vimeo">
                                                   <img src="<?php echo get_stylesheet_directory_uri(); ?>/timthumb.php?src=<?php echo $image_url[0]?>&amp;h=<?php echo $pp_portfolio_image_height; ?>&amp;w=640&amp;zc=1" alt="" class="img_nofade frame" width="640" height="<?php echo $pp_portfolio_image_height; ?>"/>
                                                </a>
                                                <img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_play.png" style="margin-top:-30px;margin-left:300px;z-index:9999"/>
                                             </div>
                                                
                     <div style="display:none;">
                         <div id="video_<?php echo $portfolio_video_id; ?>" style="width:601px;height:338px">
                        
                             <object width="601" height="338" data="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $portfolio_video_id; ?>&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" type="application/x-shockwave-flash">
                                 <param name="allowfullscreen" value="true" />
                                 <param name="allowscriptaccess" value="always" />
                                 <param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=<?php echo $portfolio_video_id; ?>&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" />
                            </object>
                            
                         </div>   
                     </div>
                                             
                                             <?php
                                                break;
                                                //end image
                                             ?>
                                             
                                             <?php
                                                }
                                             ?>
                                             </div>
                                                
                                                <div class="portfolio_desc" style="width:240px;float:right;">
                                                   <strong><?php echo get_the_title($portfolio_item->ID)?></strong>
                                                   <?php
                                                      $pp_portfolio_display_desc = get_option('pp_portfolio_display_desc');
                                                      
                                                      if(!empty($pp_portfolio_display_desc))
                                                      {
                                                   ?>                              
                                                   <br/>
                                                   <span>
                                                   <?php echo pp_substr(strip_tags(strip_shortcodes($portfolio_item->post_content)), 140); ?>                                                   
                                                   </span>
                                                   <?php
                                                      }
                                                   ?>
                                                </div>
                                             </div>
                                 
                                  <?php

                                    }
                                    //End foreach loop
                                    
                                  ?>
                                 
                     <?php
                        
                     }
                     //End if have portfolio items
                     ?>
                     
                     </div>
            
<?php
if(!isset($hide_header) OR !$hide_header)
{
?>            
         </div>
         <!-- End main content -->
            
         </div>
         
      </div>
      <!-- End content -->
            

<?php get_footer(); ?>
<?php
}
?>

i guess the fix should be something similar to what you already told me but i'm not sure on how exactly it should be...
l736k
 
Posts: 11
Joined: Thu Apr 21, 2011 10:50 pm

Re: Doesn't work with my theme's "portfolio" section

Postby Nikola Nikolov » Wed May 30, 2012 10:18 am

Here is what you have to replace:
Code: Select all
$page->post_content
with:
apply_filters('the_content', $page->post_content)


Basically when you have a title that needs to be translated, you use "get_the_title("$*->ID")" function with the post's ID as argument. When you need the content translated, you use the "apply_filters('the_content', $*->post_content)" function with the post's content as an argument. When you need something else translated(for example there is some description, that won't be translated as well), use the "__()" function with the variable that holds that text(for example if you have "echo $page_desc;" , replace it with "echo __($page_desc);"). This is a translation function, to which qTranslate is hooked - if the string can be translated, it will be. :)
Nikola Nikolov
 
Posts: 175
Joined: Wed May 16, 2012 3:46 pm

Re: Doesn't work with my theme's "portfolio" section

Postby l736k » Sun Jun 17, 2012 1:24 pm

hi moonwatch...sorry for the delay of my reply but i had some exams to prepare :?

i tried to follow your instruction but can't get out with success. the text is still untranslated. can i send you a rar file with the template files in it? if you would be so gentile, just send me your mail address via PM.

thanks :oops:
l736k
 
Posts: 11
Joined: Thu Apr 21, 2011 10:50 pm

Re: Doesn't work with my theme's "portfolio" section

Postby Nikola Nikolov » Sun Jun 17, 2012 8:27 pm

Hi there

I hope you did well on your exams :)

Well this forum seems to lack the convenience of personal messaging(if you find it - send me a PM :D ). So here is my email: nikolov{dot}tmw{at}gmail{dot}com - you can send me the files of the theme(or just the one you need to change if you had it figured-out) there and I'll fix it for you :)
Nikola Nikolov
 
Posts: 175
Joined: Wed May 16, 2012 3:46 pm

Re: Doesn't work with my theme's "portfolio" section

Postby l736k » Tue Jun 19, 2012 8:27 am

didn't get out of exams yet...hope to make it thanks :)

i sent you the archive with the theme files, let me know if there are problems. thanks!! ;)
l736k
 
Posts: 11
Joined: Thu Apr 21, 2011 10:50 pm

Re: Doesn't work with my theme's "portfolio" section

Postby kikinoutch » Tue Jun 19, 2012 10:42 am

Hi everyone,

I get almost the same problem, it would be great if you can share your solution.

My portfolio description don t want to be translate..

i try this

[:en]English [:fr]Français
<!--:fr-->Français<!--:--><!--:en-->English<!--:-->


but it s not working properly,

Image



I check to the code of the page and i get this:

Code: Select all
<p class="short"><?php echo $custom["description"][0];?></p>



I need to add some php code... but I don t really know..
I hope someone have some ideas!

thanks in advance for your support,
kikinoutch
 
Posts: 1
Joined: Tue Jun 19, 2012 10:23 am

Re: Doesn't work with my theme's "portfolio" section

Postby Nikola Nikolov » Tue Jun 19, 2012 3:54 pm

If the code you posted above is the one that displays your text, simply replace it with the following:
Code: Select all
<p class="short"><?php echo __($custom["description"][0]);?></p>

You can notice the "__()" that wraps the variable containing the description. This is a translation function and qTranslate is hooked to it and will strip any excess language(if the text is in multiple languages).
Nikola Nikolov
 
Posts: 175
Joined: Wed May 16, 2012 3:46 pm

Next

Return to qTranslate Support Forum

Who is online

Users browsing this forum: Google [Bot] and 5 guests