If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > php sidebar element needs fixing - help please

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-07-11, 17:32
yvonnedev yvonnedev is offline
Registered User
 
Join Date: Jul 2011
Posts: 1
php sidebar element needs fixing - help please

Hi

I am building some Wordpress sidebar templates in php and need some help to fix two of them:

I have included below all three (second one works fine) - Sidebar 1 and Sidebar 3 need fixing - I have pasted in the elements that dont work from another longer file - please help....

Can you show me to correct the code so that they work like sidebar 2 does - Thanks


---------------------------
sidebar 1 - not working
(- elements needed to include: NEWS - TESTIMONIALS - BROCHURE)
---------------------------

<?php // begin l_sidebar ?>
<?php
$boxStart = '<div class="box2" style="background: white; margin-bottom: 7px;">
<div style="margin:10px">';
$boxEnd = '
</div>
</div>';
?>

<?php
$arrTitle = array('ABOUT US');
$oCategory = array();
if (is_int(get_the_ID())){
$oCategory = get_the_category(get_the_ID());
}

$arrAboutUs = array('LATEST NEWS', 'NEWS ARCHIVE', 'OUR NEWS:', 'LEGAL UPDATES:');
if (!empty($oCategory[0]->name)){
if (in_array(strtoupper($oCategory[0]->name), $arrAboutUs)){
$parentTitle = 'ABOUT US';
}
}

if (in_array($parentTitle, $arrTitle)){
?>
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Left') ) {?>
<?php } ?>
<?php
}
else{
//if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Front Page Left') ) {

//}
?>
<?php }

// news element
echo $boxStart;
echo '<span class="title02" >';
echo 'Latest News';
echo '</span>';
echo '<ul style="list-style-type:square;">';
$args = array(
'post_type' => 'page',
'numberposts' => 5
);
$posts = get_posts($args);
//print_r($posts);
foreach($posts as $post) {
echo '<li style="list-style-type:square;">';
echo '<a href="';
the_permalink();
echo '">';
the_title();
echo '</a>';
echo '</li>';
}
echo '</ul>';
echo $boxEnd;


?>


<?php

// testimonials sidebar element to go in here

echo $boxStart;

// Testimonials element - not working
} elseif ($post->ID == 1073) {

echo '<div class="box2" style="background: white; margin-bottom: 7px; height:222px;"><div style="margin:10px">';
echo '<div style="float:left; width:100%;">';
echo '<h4 style="border-bottom: 1px solid #ccc; color:#333;">';
the_title();
echo '<a href="#" style="float:right;"> View All &rarr; </a>';
echo '</h4></div>';
echo '<div>';
echo $post->post_content;
echo '</div>';
echo $endBox;

echo $boxEnd;


?>

<?php

// brochure sidebar element to go in here

echo $boxStart;

// Brochure element - not working

if ($post->ID == 1055) {
$the_content = get_post_meta($post->ID, "the_content");
echo $startBox;
echo '<div style="float:left; width:178px;"><a class="rightLink" href="';
the_permalink();
echo '"></a><span class="title02" >';
echo '</span></div>';
echo '<div>';
echo $post->post_content;
echo '</div>';
echo $endBox;



echo $boxEnd;


?>



<?php
echo $endBox;
endforeach; ?>





<?php // end l_sidebar ?>
-----------------------------------------------------------
sidebar 2 - working just fine
(- elements needed to include: NEWS - NEWSLETTER ** I got his one working fine **) - this is how I want the others to work
---------------------------

<?php // begin l_sidebar ?>
<?php
$boxStart = '<div class="box2" style="background: white; margin-bottom: 7px;">
<div style="margin:10px">';
$boxEnd = '
</div>
</div>';
?>

<?php
$arrTitle = array('ABOUT US');
$oCategory = array();
if (is_int(get_the_ID())){
$oCategory = get_the_category(get_the_ID());
}

$arrAboutUs = array('LATEST NEWS', 'NEWS ARCHIVE', 'OUR NEWS:', 'LEGAL UPDATES:');
if (!empty($oCategory[0]->name)){
if (in_array(strtoupper($oCategory[0]->name), $arrAboutUs)){
$parentTitle = 'ABOUT US';
}
}

if (in_array($parentTitle, $arrTitle)){
?>
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Left') ) {?>
<?php } ?>
<?php
}
else{
//if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Front Page Left') ) {

//}
?>
<?php }

//news element
echo $boxStart;
echo '<span class="title02" >';
echo 'Latest News';
echo '</span>';
echo '<ul style="list-style-type:square;">';
$args = array(
'post_type' => 'page',
'numberposts' => 5
);
$posts = get_posts($args);
//print_r($posts);
foreach($posts as $post) {
echo '<li style="list-style-type:square;">';
echo '<a href="';
the_permalink();
echo '">';
the_title();
echo '</a>';
echo '</li>';
}
echo '</ul>';
echo $boxEnd;


?>
<?php

//newsletter element
$startBox = '
<div class="box2" style="background: #fff; margin-bottom: 7px;">
<div style="margin:10px">
';
$endBox = '
</div>
</div>
';
global $post;
$args = array( 'numberposts' => 5, 'offset'=> 1, 'category' => 8 );
$results = query_posts( array ( 'category_name' => 'side-bar-front-page', 'posts_per_page' => 1, 'offset'=> 4, ) );
foreach( $results as $post ) : //setup_postdata($post);
if( get_post_meta($post->ID, "thumb", true) ){
$thumbPic = get_post_meta($post->ID, "thumb", $single = true);
}
if( get_post_meta($post->ID, "anotheTitle", true) ){
$anotheTitle = get_post_meta($post->ID, "anotheTitle", $single = true);
}


echo $startBox;
echo '
<div style="float:left; width:178px;">
<a class="rightLink" href="';
the_permalink();
echo '"><span class="title02" >';
the_title();
echo '</span></a>
</div>';
echo '<div style="width:208px;">';
echo'<a href="';
the_permalink();
echo '"><img src="'.$thumbPic.'" /></a>
</div>';


?>

<?php
echo $endBox;
endforeach; ?>





<?php // end l_sidebar ?>
----------------------------------------------------------------------------------
sidebar 3 - not working
(- elements I need to include NEWS - TESTIMONIALS - NEWSLETTER)
---------------------------
<?php // begin l_sidebar ?>
<?php
$boxStart = '<div class="box2" style="background: white; margin-bottom: 7px;">
<div style="margin:10px">';
$boxEnd = '
</div>
</div>';
?>

<?php
$arrTitle = array('ABOUT US');
$oCategory = array();
if (is_int(get_the_ID())){
$oCategory = get_the_category(get_the_ID());
}

$arrAboutUs = array('LATEST NEWS', 'NEWS ARCHIVE', 'OUR NEWS:', 'LEGAL UPDATES:');
if (!empty($oCategory[0]->name)){
if (in_array(strtoupper($oCategory[0]->name), $arrAboutUs)){
$parentTitle = 'ABOUT US';
}
}

if (in_array($parentTitle, $arrTitle)){
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Left') ) {
}
}
else{
$startBox = '
<div class="box2" style="background: white; margin-bottom: 7px;">
<div style="margin:10px">
';
$endBox = '
</div>
</div>
';
global $post;
$args = array( 'numberposts' => 5, 'offset'=> 1, 'category' => 8 );
$results = query_posts( array ( 'category_name' => 'side-bar-front-page', 'posts_per_page' => 7 ) );
$results = array_reverse($results);
foreach( $results as $post ) { //setup_postdata($post);

if( get_post_meta($post->ID, "thumb", true) ){
$thumbPic = get_post_meta($post->ID, "thumb", $single = true);
}
if( get_post_meta($post->ID, "anotheTitle", true) ){
$anotheTitle = get_post_meta($post->ID, "anotheTitle", $single = true);
}
if( get_post_meta($post->ID, "the_content", true) ){
$the_content = get_post_meta($post->ID, "the_content", $single = true);
}


// News element

if ($post->ID == 1242) {
echo '<div class="box2" style="background: white; margin-bottom: 7px; height:222px;"><div style="margin:10px">';
echo '<div style="float:left; width:100%;">';
echo '<h4 style="border-bottom: 1px solid #ccc; color:#333;">';
the_title();
echo '<a href="#" style="float:right;"> View All &rarr; </a>';
echo '</h4></div>';
echo '<div style="list-style-type:square;">';
echo $post->post_content;
echo '</div>';
echo $endBox;


// Testimonials element
} elseif ($post->ID == 1073) {

echo '<div class="box2" style="background: white; margin-bottom: 7px; height:222px;"><div style="margin:10px">';
echo '<div style="float:left; width:100%;">';
echo '<h4 style="border-bottom: 1px solid #ccc; color:#333;">';
the_title();
echo '<a href="#" style="float:right;"> View All &rarr; </a>';
echo '</h4></div>';
echo '<div>';
echo $post->post_content;
echo '</div>';
echo $endBox;

// Newsletter element
} elseif ($post->ID == 909) {

echo $startBox;
echo '
<div style="float:left; width:178px;">
<a class="rightLink" href="';
the_permalink();
echo '"><span class="title02" >';
the_title();
echo '</span></a>
</div>';
echo '<div style="width:208px;">';
echo'<a href="';
the_permalink();
echo '"><img src="'.$thumbPic.'" /></a>
</div>';
echo $endBox;

}

if (!in_array($post->ID, array(1242,1073,909))) {

echo $startBox;
echo '
<div style="float:left; width:178px;">
<a class="rightLink" href="';
the_permalink();
echo '"><span class="title02" >';
the_title();
echo '</span></a>
<br /><br />
<span class="title03">'.$anotheTitle.'</span>
</div>';
echo '<div style="float:right; width:81px; margin-bottom: 7px;">';
echo'<a href="';
the_permalink();
echo '"><img src="'.$thumbPic.'" /></a>
</div>';
echo $endBox;
}
}

//echo $startBox;
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Front Page Right') ) {
}
//echo $endBox;
}
?>
Reply With Quote
Reply

Tags
code, help needed, newbie, php

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On