[Closed] missing content on translated pages

Home Support English Support [Closed] missing content on translated pages

This topic contains 9 replies, has 2 voices, and was last updated by  Sam W 10 months, 2 weeks ago. The support staff assigned to this topic is brooks.

Viewing 10 posts - 1 through 10 (of 10 total)
Author Posts
Author Posts
July 5, 2012 at 2:43 pm #66355

Sam W

I am making progress bringing multiple languages on select pages. I am translating the main <div> content but I am losing the sidebar <div> content in the translated pages. The <div>s are present but empty. They should contain menu and link content that I am not translating – it's generated in the template for the content page.

sam

July 5, 2012 at 8:23 pm #66418

brooks

Dear Sam,
I am not understandstanding your question quite well yet, could you please offer some more explanation.

July 6, 2012 at 6:12 pm #66541

Sam W

—-non-translated code—-

<div id="sidebarLeft">

<ul class="subnav subnavControls">
<li class="page_item page-item-13"><a href="http://localhost:8888/arasan/products/mobile-connectivity/">Mobile Connectivity</a>
<ul class='children'>
many more lines
</div>

——translated code ——
<div id="sidebarLeft">
 
</div>

July 6, 2012 at 8:58 pm #66554

brooks

I get you Sam :)

Please post here the php from the template that produced the code above.

July 6, 2012 at 9:44 pm #66557

Sam W

I didn't create the theme, but I think this is the section. It's basically a generated menu/submenu/subsubmenu.
I don't want to translate any of the menus – only the main content text (which is working). I also have items in the rightside that are generated – basically links to other pages or content. I don't want to translate them. But I do them to be present in English in any translation. thanks Sam

<?php

if ($post->post_parent) {
$ancestors=get_post_ancestors($post->ID);
$root=count($ancestors)-1;
$parent = $ancestors[$root];
} else {
$parent = $post->ID;
}

$children = wp_list_pages(
array(
"title_li" => "",
"child_of" => $parent,
"echo" => 0
)
);

if ($children) { ?>
<ul class="subnav subnavControls">
<?php echo $children; ?>
</ul>
<?php } else { ?>
 
<?php } ?>

July 9, 2012 at 8:29 am #66708

brooks

So far that code looks like it should work well with wpml,
If you extracted it from a specific theme template, Plaase post the code from that entire template so I can get more context that way.
Thanks.

July 9, 2012 at 2:59 pm #66777

Sam W

<?php
/*
Template Name: product section page
*/
require_once("db_connection.php");

?>
<?php get_header(); ?>
<!– sivanthi codings for phase 3 START –>

<?php $visitedurl=$_SERVER['REQUEST_URI']; ?>

<?PHP $db = new DbConnection();

$userid=$_SESSION['uid'];
$expurl=explode("/",$visitedurl);
if($userid!="" && $expurl[1]=='products' && $expurl[3]!="" && $_SESSION['products']=='')
{
mysql_query("insert into datasheet_downloads (uid,datasheet_url,emailed) values ('".$userid."','".$visitedurl."','0')");
$_SESSION['products']=1;
}

?>

<!– sivanthi codings for phase 3 END –>

<?php
$meta = get_post_custom();
$datasheet_id = get_field( "datasheet_attachment_id" ); // uses advanced custom fields plugin
?>

<script type="text/javascript">
$(document).ready( function() {
$("#sidebarLeft .subnav").initSideNav( "<?php bloginfo('template_url'); ?>/images");
});
function logDownload(datasheetUrl){
var url = "<?php echo bloginfo('template_url');?>/datasheet.php";
$.post(url, "datasheet_url=" + datasheetUrl);
return true;
}
</script>

<!– sivanthi codings for phase 3 START –>

<?php $visitedurl=$_SERVER['REQUEST_URI']; ?>

<?PHP $db = new DbConnection();

$userid=$_SESSION['uid'];
$date=date('Y-m-d');
$detectquery=mysql_query("select id,datasheet_url from datasheet_downloads where uid='".$userid."' and date(date)='".$date."' and datasheet_url like '/products%'");
$exists=mysql_num_rows($detectquery);
if($exists==0 & $userid!='')
{
mysql_query("insert into datasheet_downloads (uid,datasheet_url,emailed) values ('".$userid."','".$visitedurl."','0')");

}

$query=mysql_query("select id,datasheet_url from datasheet_downloads where uid='".$userid."' and date(date)='".$date."'");

while($row=mysql_fetch_array($query))
{
$id=$row['id'];
$datasheet=$row['datasheet_url'];
$exploded=explode("/",$datasheet);
if($exploded[1]=='products')
{
mysql_query("update datasheet_downloads set datasheet_url='".$visitedurl."' where id='".$id."' and date(date)='".$date."'");

}

}

?>

<!– sivanthi codings for phase 3 END –>

<div id="sidebarLeft">

<?php get_sidebar('products'); ?>

</div>

<div id="main">
<?php if (have_posts()) : ?>

<?php while (have_posts()) : the_post(); ?>

<?php if (function_exists('dimox_breadcrumbs')) dimox_breadcrumbs( "products" ); ?>

<?php the_content('Read the rest of this entry »'); ?>

<?php endwhile; ?>

<?php else : ?>

<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>

<?php endif; ?>

<?php
// figure out if we're on a bottom-level product page
$ancestors = get_post_ancestors($post->ID);
array_unshift( $ancestors, $post->ID ); // include self in ancestors

$pagekids = get_children( $post->ID );

$is_product = true;

//echo "<script>console.log('start: is_product = $is_product, post id = " . $post->ID . ", pagekids length = " . count($pagekids) . "');</script>";

$first_ancestor = get_post( $ancestors[1] );

if ( $first_ancestor->post_name == "products" ) {
$is_product = false;
} else {
if ($pagekids) {
foreach( $pagekids as $pagekid ) {
$pagekid_id = $pagekid->ID;
$pagekid_post_name = $pagekid->post_name;
$pagekid_post_type = $pagekid->post_type;

if ( substr( $pagekid_post_name, 0, 1 ) != "_" && $pagekid_post_type != "attachment" ) {
$is_product = false;
}
}
}
}
?>

<?php if ($is_product) : ?>

<div class="tabs">
<?php
the_secondary_content(5);
the_secondary_content(2);
the_secondary_content(3);
the_secondary_content(4);
?>
</div>

<script type="text/javascript">
$(document).ready( function() {
$("#main .tabs").initTabs();
});
</script>

<?php endif; ?>

</div><!– end main –>

<div id="sidebarRight">

<?php if ( $datasheet_id && is_logged_in() ) : ?>
<?php $datasheet_url = wp_get_attachment_url( $datasheet_id ); ?>

<?php if ( $datasheet_url ) : ?>
<div class="sidebarItem sidebarItemDownloadDatasheet">
<div class="box">
<div class="box2">

<?php if (( $datasheet_id ) == "4068") : ?>
<p>M-PHY for UFS</p>
<?php endif; ?>
<a onclick='logDownload("<?php echo $datasheet_url; ?>");' href="<?php echo $datasheet_url;?>">Download the datasheet »</a>

</div>
</div>
</div>

<!– If M-PHY load 2nd datasheet Sam Beal Apr2012–>

<?php if (( $datasheet_id ) == "4068") : ?>
<?php $datasheet_url2 = wp_get_attachment_url( '4433') ; ?>
<?php if ( $datasheet_url2 ) : ?>
<div class="sidebarItem sidebarItemDownloadDatasheet">
<div class="box">
<div class="box2">
<p>M-PHY for LLI</p>
<a onclick='logDownload("<?php echo $datasheet_url2; ?>");' href="<?php echo $datasheet_url2;?>">Download the datasheet »</a>

</div>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
<!– If M-PHY load two datasheets –>
<?php endif; ?>

<!– sivanthi modification for related items START –>

<?php
// look for related content in first secondary content box
$secondary_content = get_secondary_content(1);
?>

<?php if ( $secondary_content && $secondary_content != "" ) : ?>
<div class="related">
<h3>Related Items</h3>
<?php echo $secondary_content; ?>
</div>
<?php else : ?>
<?php
// look for related links in custom variables (related_item_text_[n], related_item_url_[n])
$relatedArr = array();
for ($i = 0; $i < 15; $i++) {
if ( $meta["related_item_text_".$i][0] && $meta["related_item_text_".$i][0] != "" && $meta["related_item_url_".$i][0] && $meta["related_item_url_".$i][0] != "" ) {
$u = $meta["related_item_url_".$i][0];
$u = ( strpos( $u, "http") !== false ) ? $u : "http://" . $u;
array_push( $relatedArr, array($meta["related_item_text_".$i][0], $u) );
}
}
?>
<?php if ( count($relatedArr) > 0 ) : ?>
<div class="related">
<h3>Related Items</h3>
<p>See also:
<?php
for ( $i = 0; $i < count( $relatedArr ); $i++ ) {
echo "<a href='" . $relatedArr[$i][1] . "' title='" . $relatedArr[$i][0] . "'>" . $relatedArr[$i][0] . "</a>";
if ( ($i + 1) < count( $relatedArr ) ) echo ", ";
}
?>
</p>
</div>
<?php endif; ?>
<?php endif; ?>

<!– sivanthi modification for related items END –>

<!– If M-PHY insert two Sign In boxes SWB 4-12-12 –>

<?php elseif ( $datasheet_id ) : ?>
<?php if (( $datasheet_id ) =="4068") : ?>
<p><span style="margin: -20px 10px 0px 26px; font-size: 13px; text-align: left; color: #003399;">M-PHY for UFS or LLI</span></p>
<?php endif; ?>
<div class="sidebarItem sidebarItemSignin">
<div class="box">
<div class="box2">
<?php insertPageContent( "products/_sidebar_signin" ); ?>

</div>

</div>
</div>

<?php if (( $datasheet_id ) =="4433") : ?>
<br /><br />
<p><span style="margin: -20px 10px 0px 26px; font-size: 14px; text-align: center; color: #003399;">M-PHY for LLI</span></p>

<div class="sidebarItem sidebarItemSignin">
<div class="box">
<div class="box2">
<?php insertPageContent( "products/_sidebar_signin" ); ?>

</div>

</div>
</div>

<?php endif; ?>

</div>
<?php else : ?>

<?php
// get product brief sidebar based on if self or any parents are a family page
$family = "";

foreach( $ancestors as $id ) {
$ancestor_post = get_post($id);
$ancestor_post_name = $ancestor_post->post_name;
//echo "<script>console.log('ancestor post name = $ancestor_post_name');</script>";

if ( $ancestor_post_name == "general-connectivity" ) {
$family = "general-connectivity";
break;
} else if ( $ancestor_post_name == "mobile-connectivity" ) {
$family = "mobile-connectivity";
break;
} else if ( $ancestor_post_name == "mobile-storage" ) {
$family = "mobile-storage";
break;
}
}

//echo "<script>console.log('family = $family');</script>";

if ( $family != "" ) {
foreach( $pagekids as $kid ) {
$t = $kid->post_title;
if ( $t == "_sidebar_productbrief" ) {
$sidebar_location = "products/$family/_sidebar_productbrief";
?>

<div class="sidebarItem sidebarItemProductBrief">
<div class="box">
<div class="box2">
<?php insertPageContent( $sidebar_location ); ?>
</div>
</div>
</div>

<?php
}
}
}

// if there totalip urls are set as custom variables, add totalip sidebar
?>

<?php endif; ?>

<?php if ( $meta["totalip_url_ip"][0] || $meta["totalip_url_phy"][0] || $meta["totalip_url_sw"][0] || $meta["totalip_url_vip"][0] || $meta["totalip_url_hdp"][0] ) : ?>

<div class="sidebarItem">
<div class="totalip">
<div class="totalip2">
<h3>Total IP Solution</h3>
<ul>
<li class="ip"><?php if ( $meta["totalip_url_ip"][0] ) : ?><a href="<?php echo $meta["totalip_url_ip"][0]; ?>">Digital Cores</a><?php else : ?><span>Digital Cores</span><?php endif; ?></li>
<li class="phy"><?php if ( $meta["totalip_url_phy"][0] ) : ?><a href="<?php echo $meta["totalip_url_phy"][0]; ?>">Analog PHYs</a><?php else : ?><span>Analog PHYs</span><?php endif; ?></li>
<li class="sw"><?php if ( $meta["totalip_url_sw"][0] ) : ?><a href="<?php echo $meta["totalip_url_sw"][0]; ?>">Software</a><?php else : ?><span>Software</span><?php endif; ?></li>
<li class="vip"><?php if ( $meta["totalip_url_vip"][0] ) : ?><a href="<?php echo $meta["totalip_url_vip"][0]; ?>">Verification IP</a><?php else : ?><span>Verification IP</span><?php endif; ?></li>
<li class="hdp"><?php if ( $meta["totalip_url_hdp"][0] ) : ?><a href="<?php echo $meta["totalip_url_hdp"][0]; ?>">Hardware Platform</a><?php else : ?><span>Hardware Platform</span><?php endif; ?></li>
</ul>
</div>
</div>
</div>
<?php endif; ?>

<?php
// add other sidebars
$pagekids = orderPostArray( $pagekids );

foreach( $pagekids as $kid ) {
//echo "<script>console.log('kid post name = " . $kid->post_name . ", kid post title = " . $kid->post_title . "');</script>";
//print_r($kid);

$t = $kid->post_title;
if (
strpos( $t, "_sidebar" ) !== false &&
$t != "_sidebar_signin" &&
$t != "_sidebar_productbrief"
) {
?>

<div class="sidebarItem">
<div class="box">
<div class="box2">
<?php echo $kid->post_content; ?>
</div>
</div>
</div>

<?php
}
}
?>

</div><!– end sidebarRight –>

<?php get_footer(); ?>

July 10, 2012 at 6:57 am #66838

brooks

I looked through the code and it seemed ok, then I went back to revise the post and realized you mentioned that you had not translated the menus, that's why they are not appearing! If you want untranslated links appearing on the translated language, you could create them using a text widget otherwise wpml filters them from the output.

July 10, 2012 at 7:24 am #66840

Sam W

I have no idea how a "text widget" will help with generated menus. I do not want to translate individual product pages – the terminology is better left in English. That is the main flaw with simply using Google Translate across the entire site.

Is there no way to instruct WPML to ignore menus or sidebars?

July 10, 2012 at 7:34 am #66841

Sam W

I just discovered "copy content from English". I tested one product and it populated in the menu.
think I can use this to work around the issue.

thx
Sam

Viewing 10 posts - 1 through 10 (of 10 total)

The topic ‘[Closed] missing content on translated pages’ is closed to new replies.