Bootstrap grid is not correctly aligning - php

On my search results page I have 2 posts per row (col-md-6). The grid works fine and everything is aligned correctly, except when the excerpt or the post title is longer than the other excerpts or post titles. On my test site I have all of the titles and excerpts of my posts 1 line, and than I have 1 post that has a post title of one line and an excerpt of two lines. Since the excerpt is two lines it messes with the alignment of the rest of the posts. How could I fix this issue so that all posts no matter the length of the excerpt are aligned correctly?
When the excerpts and post titles are the same length everything is aligned
When the excerpt is longer it screws up the alignment
I'm attaching all my php files that go along with my search page. However, the main file is list-search-template.php (the last one)
search.php
<?php get_header(); ?>
<div class="content-holder clearfix">
<div class="container">
<div class="search-results-search">
<form role="search" method="get" class="search-form-search form-inline-search" action="">
<div class="input-group-search">
<input type="search" value="" name="s" class="input-sm-search search-field-search form-control-search" placeholder="<?php echo $s ?>">
</div>
</form>
</div>
<div class="row">
<div class="col-md-12" >
<div class="grid js-masonry ajax-container row">
<?php
get_template_part("loop/loop-search"); ?>
</div>
<?php get_template_part('post-template/post-nav'); ?>
</div>
</div>
</div>
<footer class="footer">
<?php get_template_part('wrapper/wrapper-footer'); ?>
</footer>
<?php get_footer(); ?>
loop-search.php
<?php /* Loop Name: Loop list-posts blog */ ?>
<?php
if (have_posts()) :
while (have_posts()) : the_post();
?>
<div id="post-<?php the_ID(); ?>" class="post-list_h ajax-post-wrapper block col-xs-12 col-sm-6 col-md-6" >
<?php
get_template_part('post-template/list-search-template');
?>
</div>
<?php
endwhile; wp_reset_postdata(); ?>
<?php else: ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
list-search-template.php
<?php
/**
* Grid post template
*/
?>
<?php
?>
<div class="post_content">
<div class="post_content grid-block <?php echo esc_attr(); ?>">
<?php if(has_post_thumbnail()) { ?>
<?php
if(has_post_format('video')){
$embed = get_post_meta(get_the_ID(), 'novablog_video_embed', true);
$vimeo = strpos($embed, "vimeo");
$youtube = strpos($embed, "youtu");
if($youtube !== false){
$video_id = str_replace( 'http://', '', $embed );
$video_id = str_replace( 'https://', '', $video_id );
$video_id = str_replace( 'www.youtube.com/watch?v=', '', $video_id );
$video_id = str_replace( 'youtube.com/watch?v=', '', $video_id );
$video_id = str_replace( 'youtu.be/', '', $video_id );
$video_id = str_replace( '&feature=channel', '', $video_id );
$link = '//www.youtube.com/embed/'.esc_attr($video_id);
}
if($vimeo !== false){
//Get ID from video url
$video_id = str_replace( 'http://vimeo.com/', '', $embed );
$video_id = str_replace( 'http://www.vimeo.com/', '', $video_id );
$video_id = str_replace( 'https://vimeo.com/', '', $video_id );
$link = '//player.vimeo.com/video/'.esc_attr($video_id);
}
}
?>
<?php if(has_post_format('video')){ ?>
<a class="popup-youtube" href="<?php echo esc_attr($link); ?>" title="<?php the_title_attribute(); ?>">
<?php if(has_post_format('video')){
echo '<div class="cover-video"></div>';
} ?>
<?php } ?>
<div class="two-front-container">
<a title="<?php the_title_attribute(); ?>" href="<?php the_permalink(); ?>"><?php the_post_thumbnail('full', array('class' => 'medium-front-thumbnail')); ?></a>
</div>
<?php } ?>
</div>
<div>
<div class="front-page-date"><?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?></div>
<div class="front-page-post-title"><?php the_title(); ?></div>
<div class="post_content"><p class="front-page-post-excerpt"><?php echo get_the_excerpt(); ?></p><div class="clear"></div></div>
<div class="front-page-post-info">
<a class="moretext" href="<?php the_permalink(); ?>">Read more</a>
<?php get_template_part( 'includes/front-shop-the-post' ); ?>
<?php get_template_part( 'includes/share-buttons' ); ?>
<div class="front-comments"><?php comments_popup_link ('0', '1', '%', 'comment-count', 'none'); ?></div>
</div>
</div>
</div>

The simplest way I've found to solve this is using a clearfix, but using Bootstrap's responsive utilities to only use the clearfix at the viewport sizes you want. You don't need to worry about opening and closing rows.
Here's a screenshot of a JSFiddle demonstration:
Note the JSFiddle uses http://lorempixel.com/ for images, and they can be slow to load sometimes - give it time.
To implement this in your code, simply add a $count in loop-search.php, and include the clearfix every 2nd post:
<?php /* Loop Name: Loop list-posts blog */
$count = 0;
if (have_posts()) :
while (have_posts()) : the_post();
$count++;
?>
<div id="post-<?php the_ID(); ?>" class="post-list_h ajax-post-wrapper block col-xs-12 col-sm-6 col-md-6" >
<?php get_template_part('post-template/list-search-template'); ?>
</div>
<?php if ($count%2 === 0) { ?>
<div class="clearfix hidden-xs hidden-sm"></div>
<?php }
<?php endwhile; wp_reset_postdata(); ?>
<?php else: ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
The clearfix is not applied for xs and sm viewports, so only becomes effective at md and larger - which is what you want.
Note - you have js-masonry classes in your code, if you're really using Masonry.js that will probably mess things up. Maybe you were experimenting with it instead of trying to get this horizontal alignment working? If you're not using it now make sure you've removed the JS links and remove the classes to avoid confusion.

Since you're keeping them all in the same row, there's no clearfix. Since you have widths of either 12 or 6 (full or half) you could close (and reopen) a new row every other post. In the cases where it's a small screen, the side by side height won't matter since each post will be on its own line anyway.
<?php /* Loop Name: Loop list-posts blog */ ?>
<?php
if (have_posts()) :
$postCount = 0; // Initialize counter
while (have_posts()) : the_post();
$postCount++; // Increment counter
?>
<div id="post-<?php the_ID(); ?>" class="post-list_h ajax-post-wrapper block col-xs-12 col-sm-6 col-md-6" >
<?php
get_template_part('post-template/list-search-template');
?>
</div>
<?php
// Print row if needed
if($postCount % 2 == 0):
?>
</div><div class="grid js-masonry ajax-container row">
<?php
endif;
endwhile; wp_reset_postdata(); ?>
<?php else: ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
<!-- end snippet -->

The following code will help you to properly add row after every 2 columns.
<?php /* Loop Name: Loop list-posts blog */ ?>
<?php
if (have_posts()) :
$counter = 0;
while (have_posts()) : the_post();
$post_count = $GLOBALS['wp_query']->post_count;
?>
<?php if($counter++%2==0){ ?>
<div class="row">
<?php } ?>
<div id="post-<?php the_ID(); ?>" class="post-list_h ajax-post-wrapper block col-xs-12 col-sm-6 col-md-6" >
<?php
get_template_part('post-template/list-search-template');
?>
</div>
<?php if($counter%2==0 || $counter == $post_count){ ?>
</div>
<?php } ?>
<?php
endwhile; wp_reset_postdata(); ?>
<?php else: ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
I think the issue with load more button will be because of lack of div closing tag.

There is a very easy solution. You need to follow 2 steps.
Remove <div class="grid js-masonry ajax-container row"> from "search.php".
Edit "loop-search.php" with the below code:
<?php /* Loop Name: Loop list-posts blog */ ?>
<?php
if (have_posts()) :
$cnt = 1;
$endRow = false;
while (have_posts()) : the_post();
?>
<?php
if($cnt%2 != 0){
$endRow = true;
?>
<div class="grid js-masonry ajax-container row">
<?php } ?>
<div id="post-<?php the_ID(); ?>" class="post-list_h ajax-post-wrapper block col-xs-12 col-sm-6 col-md-6" >
<?php get_template_part('post-template/list-search-template'); ?>
</div>
<?php
if($cnt%2 == 0){
$endRow = false;
?>
</div>
<?php } ?>
<?php
$cnt++;
endwhile; wp_reset_postdata(); ?>
<?php else: ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>

The proper workaround for this issue is to use css property display:flex see fiddle
But in your case you are using bootstrap i think, what you can do is to get the highest height of the div and apply it to all div using jquery eg:
jQuery(document).ready(function($){
var $divs = $('.row > div');
var highest = [];
$.each($divs, function($index, $item) {
highest.push($($item).height()); // Push all divs height into array
})
function compareNumbers(a, b) {
return b - a;
}
//console.log();
highest = highest.sort(compareNumbers); // sort Array
$('.row > div').height(highest[0]) // Apply the highest height to all divs
});
See live demo here

Give excerpt a fixed height using css. Then if the text is available or not. It would take that height.

Perhaps you could force having 1 line titles and excerpts. Check the example below.
.caption h3, .caption p {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 100%;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="thumbnail">
<img src="http://i68.tinypic.com/161z3fc.jpg" alt="" width="" height="">
<div class="caption">
<h3 title="Card 1 is not like the rest cards. It's title is longer than the others.">Card 1 is not like the rest cards. It's title is longer than the others.</h3>
<p>Short excerpt</p>
</div>
</div>
</div>
<div class="col-md-6">
<div class="thumbnail">
<img src="http://i68.tinypic.com/161z3fc.jpg" alt="" width="" height="">
<div class="caption">
<h3 title="Card 2">Card 2</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis auteirure dolor in reprehenderit in voluptate velit esse</p>
</div>
</div>
</div>
<div class="col-md-6">
<div class="thumbnail">
<img src="http://i68.tinypic.com/161z3fc.jpg" alt="" width="" height="">
<div class="caption">
<h3 title="Card 3">Card 3</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis auteirure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
</div>
<div class="col-md-6">
<div class="thumbnail">
<img src="http://i68.tinypic.com/161z3fc.jpg" alt="" width="" height="">
<div class="caption">
<h3 title="Card 4">Card 4</h3>
<p>Another short excerpt</p>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
EDIT
If you choose to force having one line only, card Titles and excerpts, then try adding also title attribute in card titles. For example.
<h3 title="Card 1 is not like the rest cards. It's title is longer than the others.">Card 1 is not like the rest cards. It's title is longer than the others.</h3>

Related

Php Loop in bootstrap

I please need an explanation on how to express a loop in a manner that it collapses the bootstrap using a counter and a foreach loop but it looks like i am not getting the right response as i want it.
<?php
$views = ['First View','Second View','Third View'];
$messages = [
"FIRST MESSAGE Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad",
"SECOND MESSAGE Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad",
"THIRD MESSAGE Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad",
];
?>
<section>
<div class="row">
<div class="col-md-12"><div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<?php
foreach($views as $view): $count = 1;?>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading<?php echo $count; ?>">
<h4 class="panel-title">
<a class="<?php echo ($count == 1 ? '' : 'collapse'); ?>" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse<?php echo $count; ?>" aria-expanded="<?php echo ($count == 1 ? 'true' : 'false'); ?>" aria-controls="collapse<?php echo $count; ?>">
<?php echo strtoupper(" $view "); ?>
</a>
</h4>
</div>
<div id="collapse<?php echo $count; ?>" class="panel-collapse <?php echo ($count == 1 ? 'collapse in' : 'collapse'); ?>" role="tabpanel" aria-labelledby="heading<?php echo $count; ?>">
<div class="panel-body">
<?php foreach($messages as $message): ?>
<?php echo "$count, $message"; ?>
<?php endforeach; ?>
</div> <!-- end body -->
</div>
</div> <!-- end default -->
<?php $count++; endforeach; ?>
</div> <!-- end 12 -->
</div> <!-- end accordion -->
</div> <!-- END OF ROW
-->
</section>
in your loop you're setting $count = 1; which means that count will ALWAYS be 1.
I'm assuming you want that var to increment to count your loops. Put it outside the loop and add 1 to it inside the loop.
$count = 1;
foreach($whatever as $something):
// do stuff
$count++;
endforeach;

First post with different style and others post with different style

i've this problem with WP_Query and the HTML output:
The Query:
<!-- Category posts -->
<!-- Entretencion -->
<article class="six column">
<?php
$caps = new WP_Query();
$caps->query('posts_per_page=4&category_name=entretencion');
while($caps->have_posts()) {
$caps->the_post();
$count++;
if($count == 1) {
?>
<!--First post -->
<h4 class="cat-title"><?php $category = get_the_category(); echo $category[0]->cat_name; ?></h4>
<div class="post-image">
<img src="<?php bloginfo( 'template_url' ); ?>/upload/imagepost1.jpg" alt="">
</div>
<div class="post-container">
<h2 class="post-title">Create a Flexible Folded Paper Effect Using CSS3 Features</h2>
<div class="post-content">
<p>Venenatis volutpat orci, ut sodales augue tempor nec. Integer tempus ullamcorper felis eget dipiscing. Maecenas orci justo, mollis at tempus ac, gravida non</p>
</div>
</div>
<div class="post-meta">
<span class="comments">24</span>
<span class="author">nextwpthemes</span>
<span class="date">13 Jan 2013</span>
</div>
<!-- End of first post -->
<?php } if($count >= 2) { //Contador ?>
<!-- Second and others posts -->
<div class="other-posts">
<ul class="no-bullet">
<!-- Repeat this list with post 2, 3, and 4 -->
<li id="<?php echo $post->ID; ?>">
<img src="<?php bloginfo( 'template_url' ); ?>/upload/thumb1.jpg" alt="">
<h3 class="post-title">Check Out the New Recommended Resources on Webdesigntuts+</h3>
<span class="date">13 Jan 2013</span>
</li>
</ul>
</div>
<?php } // Fin contador ?>
<?php } ?>
</article>
But the HTML output repeat 3 div with class other-post.
The problem (left) the original (right)
How to repeat only li tags?
<!-- Category posts -->
<!-- Entretencion -->
<article class="six column">
<?php
$count = '';
$perpage = 4;
$caps = new WP_Query();
$caps->query('posts_per_page='.$perpage.'&category_name=entretencion');
while($caps->have_posts()) {
$caps->the_post();
$count++;
if($count == 1) {
?>
<!--First post -->
<h4 class="cat-title"><?php $category = get_the_category(); echo $category[0]->cat_name; ?></h4>
<div class="post-image">
<img src="<?php bloginfo( 'template_url' ); ?>/upload/imagepost1.jpg" alt="">
</div>
<div class="post-container">
<h2 class="post-title">Create a Flexible Folded Paper Effect Using CSS3 Features</h2>
<div class="post-content">
<p>Venenatis volutpat orci, ut sodales augue tempor nec. Integer tempus ullamcorper felis eget dipiscing. Maecenas orci justo, mollis at tempus ac, gravida non</p>
</div>
</div>
<div class="post-meta">
<span class="comments">24</span>
<span class="author">nextwpthemes</span>
<span class="date">13 Jan 2013</span>
</div>
<!-- End of first post -->
<?php
}
//only on second post/loop
if($count == 2) {
?>
<!-- Second and others posts -->
<div class="other-posts">
<ul class="no-bullet">
<?php
}
if($count >= 2) { //Contador
?>
<!-- Repeat this list with post 2, 3, and 4 -->
<li id="<?php echo $post->ID; ?>">
<img src="<?php bloginfo( 'template_url' ); ?>/upload/thumb1.jpg" alt="">
<h3 class="post-title">Check Out the New Recommended Resources on Webdesigntuts+</h3>
<span class="date">13 Jan 2013</span>
</li>
<?php
}
//again, only on final loop
if($count == $perpage) {
?>
</ul>
</div>
<?php
}
}
?>
</article>
That will only output one li in the second loop, and by the end of $perpage (i keep those 4 perpage you ask to the original WP_Query).
It's ugly, but should works.

Issue with page scrolling horizontally

I'm having an issue with this page http://goo.gl/Vdu4Q0 having extra space on the x axis and have no clue why. I searched this forum for answers as well, but didn't find anything that applied, so I apologize if something is out there that I overlooked. I rechecked my HTML structure to see if there were any unclosed divs, but I'm not seeing anything. Does anyone have any ideas? Here's the Wordpress structure:
HEADER
<header class="full left header-bg">
<div class="container">
<div class="container-inside left">
<div class="sixteen columns">
<h1 class="logo abs">
<a href="<?php echo get_option('home'); ?>"/>
<img src="<?php echo get_stylesheet_directory_uri();?>/images/logo.png"/></a>
</a>
</h1>
<nav>
<?php st_navbar(); ?>
</nav>
</div>
</div>
</div><!--container-->
</header>
>
LOOP PAGE
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<?php if (!is_page_template('onecolumn-page.php')) { ?>
<?php if (is_front_page() && !get_post_meta($post->ID, 'hidetitle', true)) { ?>
<div class="full left secondary-bg">
<div class="container">
<div class="sixteen columns">
<div class="eight columns offset-by-four">
<div class="hp-text-bg">
<?php the_content(); ?>
</div>
</div>
</div>
</div>
</div>
<div class="full left home-posts-bg">
<div class="container">
<div class="sixteen columns">
<div class="five columns post-bg alpha">
<div class="post-bg-wrapper">
<h2>TATTOO OF THE WEEK</h2>
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<div class="center img">
<img src="<?php echo get_stylesheet_directory_uri();?>/images/tow-img.png"/>
</div>
<p class="primary-link">Read More</p>
</div>
</div>
<div class="six columns post-bg">
<div class="post-bg-wrapper">
<h2>JEWELRY</h2>
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<div class="center img">
<img src="<?php echo get_stylesheet_directory_uri();?>/images/jewelry.png"/>
</div>
<p class="primary-link">Read More</p>
</div>
</div>
<div class="five columns post-bg omega">
<div class="post-bg-wrapper">
<h2>AFTERCARE</h2>
<p class="p-description-blue"> Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<div class="center img">
<img src="<?php echo get_stylesheet_directory_uri();?>/images/aftercare.png"/>
</div>
<p class="primary-link">Read More</p>
</div>
</div>
</div>
</div><!--container-->
</div>
<?php } elseif (!get_post_meta($post->ID, 'hidetitle', true)) { ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php } else {
echo '<br />';
} ?>
<?php } ?>
<div class="full left">
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'skeleton' ), 'after' => '</div>' ) ); ?>
<?php edit_post_link( __( 'Edit', 'skeleton' ), '<span class="edit-link">', '</span>' ); ?>
</div><!-- .entry-content -->
<?php comments_template( '', true ); ?>
<?php endwhile; // end of the loop. ?>
FOOTER
<!-- start of footer -->
<footer>
<div class="full left pre-footer-bg">
<div class="container ">
<div class="sixteen columns">
<div class="five columns alpha">
<h5>CONNECT</h5>
<img src="<?php echo get_stylesheet_directory_uri();?>/images/icon-fb.png"/>
<img src="<?php echo get_stylesheet_directory_uri();?>/images/icon-mail.png"/>
</div>
<div class="six columns">
<h5>CALL</h5>
<p>303.830.7272<br />
303.832.8282</p>
</div>
<div class="five columns omega">
<h5>GET TO US</h5>
<p>1332 East Colfax Ave<br />
Denver, CO 80218 | Map
</p>
</div>
</div>
</div><!--container-->
</div>
<div class="full left bottom-footer-bg">
<div class="container">
<div class="sixteen columns">
<p class="bottom-footer-text">© <?php echo date('Y'); ?> Bound By Design Tattoo | Site by brentthelendesign</p>
</div>
</div>
</div>
</footer>
<script type="text/javascript" src="<?php echo get_stylesheet_directory_uri();?>/javascripts/plugins.js"></script>
<script type="text/javascript" src="<?php echo get_stylesheet_directory_uri();?>/javascripts/nav.js"></script>
<script type="text/javascript" src="<?php echo get_stylesheet_directory_uri();?>/javascripts/script.js"></script>
<?php wp_footer();?>
</body>
in style.css please add this css you are using 100% width and also applying padding that y its happening
.bottom-footer-bg,.home-posts-bg,.secondary-bg{
width:100%;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
}
If you're able to use css3, you can use box-sizing on your footer. You have a width of 100% set and a padding on top of that. Try:
.full {
box-sizing: border-box;
}

How to extricate tag image from post?

I have responsive template which working well.
I want to convert it to theme wordpress.
Inside the template there is gallery contains image and description and title link.
Since the gallery build in the template and everything(responsive) work well.
I want to embedded/convert the gallery to theme as a post, add link to
Gallery.js and generate the tag html as it seems in the template.
The source code of the template:
<!--orginal---------->
<div class="main">
<div id="carousel" class="es-carousel-wrapper">
<div class="es-carousel">
<ul>
<li>
<div class="box-1">
<img src="images/page1-img1.jpg" alt="" /> bora-bora
<span>from $458</span>
<p>Praesent vestibulum aenean
<br>nonummy hendrerit mauris.</p>
</div>
</li>
</ul>
</div>
</div>
</div>
I need to generate only the :
<img src="images/page1-img1.jpg" alt="" /> bora-bora
<span>from $458</span>
<p>Praesent vestibulum aenean
<br>nonummy hendrerit mauris.</p>
I create new post.
in the title I write: BORA-BORA
in the content post I add image from the Media
under the image I add the description image" Praesent vestibulum aenean
nonummy hendrerit mauris.".
in the Excpert I write: from $458
and after this I add code which generate the html tag gallery as you can see below:
<div class="main">
<div id="carousel" class="es-carousel-wrapper">
<div class="es-carousel"><ul>
<?php $hot_deals = new WP_Query('showposts=2&category_name=hot_deals'); ?>
<?php if($hot_deals->have_posts()) : ?>
<?php while($hot_deals->have_posts()) : $hot_deals->the_post(); ?>
<li>
<div class="box-1">
<?php the_content(); ?><?php the_title(); ?>
<span><?php the_excerpt(); ?></span>
</div>
</li>
<?php endwhile; ?>
<?php endif; ?>
</ul></div>
</div>
</div>
the resualt are close but it is not working becose I need :
to extract the <img /> from <p><a><img /></p></a>.
to take out the <p> from <span><p>FROM $458</p></span>.
Many thanks How can I do that ?
<div class="main">
<div id="carousel" class="es-carousel-wrapper">
<div class="es-carousel"><ul>
<li>
<div class="box-1">
<p><a href="http://127.0.0.1/www/www1/wordpress/wordpressEng/wp-content/uploads/2012/09/page1-img2.jpg">
<img class="alignnone size-full wp-image-82" title="page1-img2" src="http://127.0.0.1/www/www1/wordpress/wordpressEng/wp-content/uploads/2012/09/page1-img2.jpg" alt="" width="219" height="124" />
</a>
</p>
<p>Praesent vestibulum aenean<br />
nonummy hendrerit mauris.</p>
bora-bora
<span><p>FROM $458</p></span>
</div>
</li>
</div>
</div>
</div>
You are not extracting, since you are just displaying the_content(). The only way you could do that without altering theme is that you just have to go to the HTML tab where you are editing your post content and delete the <a></a> tag.
But if you can/want to edit the theme you could add a custom meta box with image upload field and then upload image there and not into the content. That way you would have full control over it.

magento - Show product reviews in review summary

I am trying to redesign the review summary for the product page, so it shows the list of reviews and the form to add a new review.
The form works, but the list does not. I add the summary from view.phtml like this:
<?php echo $this->getReviewsSummaryHtml($_product, false, true)?>
My summary.phtml file return this error:
Fatal error: Call to a member function getItems() on a non-object in /home/content/41/6755141/html/keepwell/buy/app/design/frontend/fvm/default/template/review/helper/summary.phtml
for this line:
<?php $_items = $this->getReviewsCollection()->getItems();?>
My summary.phtml file looks like this:
<div id="column-one-left">
<?php if ($this->getReviewsCount()): ?>
<p class="title-noline"><?php echo $this->__('Customer Reviews') ?></p>
<div id="customer-reviews">
<?php $_items = $this->getReviewsCollection()->getItems();?>
<?php if (count($_items)):?>
<?php echo $this->getChildHtml('toolbar') ?>
<dl>
<?php foreach ($_items as $_review):?>
<div class="review">
<p class="review-title"><?php echo $this->htmlEscape($_review->getTitle()) ?></p>
<p class="review-name"><?php echo $this->__('by <span>%s</span>', $this->htmlEscape($_review->getNickname())) ?></p>
<p class="review-body"><?php echo nl2br($this->htmlEscape($_review->getDetail())) ?></p>
</div>
<hr class="review" />
<dt>
<?php echo $this->htmlEscape($_review->getTitle()) ?>
</dt>
<dd>
<?php $_votes = $_review->getRatingVotes(); ?>
<?php if (count($_votes)): ?>
<table class="ratings-table">
<col width="1" />
<col />
<tbody>
<?php foreach ($_votes as $_vote): ?>
<tr>
<th><?php echo $this->escapeHtml($_vote->getRatingCode()) ?></th>
<td>
<div class="rating-box">
<div class="rating" style="width:<?php echo $_vote->getPercent() ?>%;"></div>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php echo nl2br($this->htmlEscape($_review->getDetail())) ?>
<small class="date"><?php echo $this->__('(Posted on %s)', $this->formatDate($_review->getCreatedAt()), 'long') ?></small>
</dd>
<?php endforeach; ?>
</dl>
<?php echo $this->getChildHtml('toolbar') ?>
<?php endif;?>
<div class="review">
<p class="review-title">This is the Review Title / Summary</p>
<p class="review-name">by John Q. Doe</p>
<p class="review-body">Nunc hendrerit, nisi eget adipiscing hendrerit, enim mauris elementum nibh, nec ornare nisi neque in quam. Vivamus ac ligula a felis hendrerit euismod. Etiam condimentum semper massa, ac bibendum diam lacinia ut. Nullam porttitor porttitor mi in sodales. Ut a vestibulum eros.</p>
</div>
<hr class="review" />
</div>
<hr/>
<hr/>
<div class="ratings">
<?php if ($this->getRatingSummary()):?>
<div class="rating-box">
<div class="rating" style="width:<?php echo $this->getRatingSummary() ?>%"></div>
</div>
<?php endif;?>
<p class="rating-links">
<?php echo $this->__('%d Review(s)', $this->getReviewsCount()) ?>
<span class="separator">|</span>
<?php echo $this->__('Add Your Review') ?>
</p>
</div>
<?php elseif ($this->getDisplayIfEmpty()): ?>
<p class="title-noline"><?php echo $this->__('Be the first to review this product') ?> >></p>
<?php endif; ?>
</div>
<div id="column-one-right">
<?php echo $this->getLayout()->createBlock('review/form')->setBlockId('product.review.form')->toHtml(); ?>
</div>
You have to do a little bit of work in your layout.xml. The guys at Classy Llama make it easy:
http://www.magentocommerce.com/boards/viewthread/41882/#t142654

Categories