Wordpress Loop with Bootstrap 3.0 - twitter-bootstrap-3

Hey guys below I have a interesting problem.... I am trying to setup a left and right side post so that I can take things like read more, post date or author and have them be in the col-md-4 and have the title and the post content along with read more be inside the col-md-8
I have a feeling I am going about this pretty strange as I am rusty as hell with my php and wordpress so any help in achieving this would be helpful. Interesting problem is I have two read more's put in place with one having a display:none for WHATEVER reason if I remove that my read more's go bonkers on the page.
The code:
<?php
$myposts = get_posts('numberposts=5
&category=homeposts');
foreach($myposts as $post) :?>
<div class="col-md-8" style="background:#000;">
<h3><a href="<?php echo the_permalink($post->ID); ?>" title="<?php echo $post->post_title;?>">
<?php echo $post->post_title ?></a></h3>
<?php echo substr($post->post_content,0,500) ?>
<a class="btn btn-default" style="display:none;" role="button" href="<?php echo get_permalink(); ?>">Read More</a>
</div>
<div class="col-md-4" style="background:#000;"><a class="btn btn-default" role="button" href="<?php echo get_permalink(); ?>">Read More</a></div>
<?php endforeach; ?>

ok so what is wrong with this....
<?php
$myposts = get_posts('numberposts=5
&category=homeposts');
foreach($myposts as $post) :?>
<div class="col-md-8">
<h3><a href="<?php echo the_permalink($post->ID); ?>" title="<?php echo $post->post_title;?>">
<?php echo $post->post_title; ?></a></h3>
<?php echo $post->the_excerpt; ?>
<a class="btn btn-default" style="display:none;" role="button" href="<?php echo get_permalink(); ?>">Read More</a>
</div>
<?php endforeach; ?>

Related

dijit.layout.ContentPane shifts right on page load

I have a problem which I am unable to fix, maybe somebody can help?
I have a dijit.layout.ContentPane at the top of my page, this sits in a dijit.layout.BorderContainer. On page load the contents of the container shift right and down by about 15px. All other elements work fine.
I have isolated the issue to dijit.layout.ContentPane. In side the container I am running some php if statements and drawing some simple buttons:
<!-- Here are the common buttons above the tabs -->
<div id="toolPane" dojoType="dijit.layout.ContentPane" region="top" >
<?php
if($this->restrict == 1){
if($this->teammembers == 1 || $this->newleaders == 1 || $this->newadminleaders == 1){
if ($this->mayUpdateSummary){
?><span style="white-space:nowrap;" ><?php echo $this->issueActionLink($issue, 'Create report', 'report', 'reportLink'); ?></span>
<span style="white-space:nowrap;" ><a class="emailLink" href="mailto:?subject=Task%20%23<?php echo $issue->id; ?>&body=<?php echo urlencode($this->serverUrl(true)); ?>">Share link</a></span><?php
}
}
}else if($this->restrict == 2){
if ($this->mayUpdateSummary){
?><span style="white-space:nowrap;" ><?php echo $this->issueActionLink($issue, 'Create report', 'report', 'reportLink'); ?></span>
<span style="white-space:nowrap;" ><a class="emailLink" href="mailto:?subject=Task%20%23<?php echo $issue->id; ?>&body=<?php echo urlencode($this->serverUrl(true)); ?>">Share link</a></span><?php
}
}
?>
<?php if ($this->mayUpdateSummary): ?>
<span style="white-space:nowrap;" ><?php echo $this->issueActionLink($issue,'Edit summary', 'progress-summary', 'editbutton'); ?></span>
<?php endif; ?>
<?php if ($closeButton): ?>
<span style="white-space:nowrap;" ><?php echo $closeButton; ?></span>
<?php endif; ?>
<?php if ($reopenButton): ?>
<span style="white-space:nowrap;" ><?php echo $reopenButton; ?></span>
<?php endif; ?>
</div>
Ok, we have decided to hide the page until the dijit elements have loaded. To do this we have added this script which fades in the page giving it time to sort itself out before it is displayed:
<script type="text/javascript">
$(document).ready(function(){
$(".content").hide();
});
$(window).load(function(){
$(".content").fadeIn("fast");
});
</script>
<div class="content">
[faded in content goes here]
</div>

Magento recently viewed products not working

I am facing a problem with showing the recently viewed products in my product page.
Here is my local.xml code:
<catalog_product_view translate="label"> reference name="root"> <action method="setTemplate">page/1column.phtml <block type="reports/product_viewed" name="product.recently.viewed" as="product_recently_viewed" template="reports/product_viewed.phtml"/></block></reference>
Here is my footer.phtml code:
<div class="footer-container">
<div class="footer">
<?php $maniPage = $this->getUrl('');
$currentUrl = Mage::helper('core/url')->getCurrentUrl();
$url = Mage::getSingleton('core/url')->parseUrl($currentUrl);
if ($maniPage == $currentUrl){
echo $this->takeCategory(12,1) /*12 = brands category 1 = show images*/ ;
}
?>
<div class="block-content">
<?php echo $this->getChildHtml('product_recently_viewed') ?>
</div>.....
Here is my product_viewed.phtml (standard file from core)
<?php if ($_products = $this->getRecentlyViewedProducts()): ?>
<div class="block block-list block-viewed">
<div class="block-title">
<strong><span><?php echo $this->__('Recently Viewed Products') ?></span></strong>
</div>
<div class="block-content">
<ol id="recently-viewed-items">
<?php foreach ($_products as $_item): ?>
<li class="item">
<p class="product-name"><?php echo $this->helper('catalog/output')->productAttribute($_item, $_item->getName() , 'name') ?></p>
</li>
<?php endforeach; ?>
</ol>
<script type="text/javascript">decorateList('recently-viewed-items');</script>
</div>
</div>
<?php endif; ?>
When I inspect the elements, the from the footer is empty. All files posted are in my theme. I have my own css so may be it won't be shown as expected, but at least the div should have any data inside, right? Could you please help me with this one. Thank you in advance.

How to resize media images in magento?

I am using magento 1.7 version.I have some images with product.Now I want to show as a slider in detail page.my code is below:-
<?php if (count($_product->getMediaGalleryImages()) > 0): ?>
<div class="more-views">
<div class="productsmallImage">
<div id="slider2">
<a class="buttons prev" href="javascript:;">left</a>
<div class="viewport">
<ul class="overview">
<?php foreach ($_product->getMediaGalleryImages() as $_image):?>
<li>
<!--No lightbox on click of image-->
<a href="<?php echo $_image->getUrl();?>" title="<?php echo $_image->getName();?>" onclick="$('image').src = this.href; return false;">
<img src="<?php echo $_image->getUrl(); ?>" width="56" height="56" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" />
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
<a class="buttons next" href="javascript:;">right</a>
</div>
</div>
In this count($_product->getMediaGalleryImages()) has value 4.All the images showing but need to resize them.Please help to do this.
Try to use the following construction for images output:
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail', $_image->getFile())->resize(56) ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" />
foreach ($_product->getMediaGalleryImages() as $image) {
Fixed width of 600px
$image_Url = Mage::helper('catalog/image')
->init($_product, 'image')
->constrainOnly(TRUE)
->keepAspectRatio(TRUE)
->keepFrame(FALSE)
->resize(600,null)
?>
Fixed height of 600px
$image_Url = Mage::helper('catalog/image')
->init($_product, 'image')
->constrainOnly(TRUE)
->keepAspectRatio(TRUE)
->keepFrame(FALSE)
->resize(null,600)
The following code will resize image proportionally and not let
the image be greater than height and width specified.
$_image_Url = Mage::helper('catalog/image')
->init($_product, 'image', $image->getFile())
->keepFrame(true)
->keepAspectRatio(TRUE)
->constrainOnly(true)
->resize(600,600);
<img src="<?php echo $_imageUrl; ?>" alt="" class="normal"/>
}

Dividing date/time elements displayed from sql call, into sperate divs?

This sql call,
<div class="dateOnAd"><?php print $row['dttm_modified']; ?></div>
outputs:
2012-05-22 15:07:28.
I need to figure out a way to divide the output into different divs
<div class="example-date">
<span class="day">31</span>
<span class="month">July</span>
<span class="year">2009</span>
</div>
<div class="example-date">
<span class="day"><?php echo date('d', $row['ddtm_modified']); ?></span>
<span class="month"><?php echo date('F', $row['ddtm_modified']); ?></span>
<span class="year"><?php echo date('Y', $row['ddtm_modified']); ?></span>
</div>
You can read more about the date() function here: date.

Sort on custom field

I need your help with my widget type code for wordpress. I have a custom field called ordermetakey. I need this below box to sort the posts on this custom field ASC. Its a numeric timestamp.
<div class="list-block">
<ul>
<?php $postslist = get_posts('numberposts=5'); foreach ($postslist as $post) : setup_postdata($post); ?>
<li>
<p><strong><a title="Post: <?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></strong><br \> <span><?php echo get_post_meta($post->ID, 'standplaats', true); ?></span></p>
</li>
<?php endforeach; ?>
</ul>
</div>
<div class="list-block">
<ul>
<?php $postslist = get_posts( array(
'meta_key' => 'ordermetakey',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'posts_per_page' => 5
);
foreach ($postslist as $post) : setup_postdata($post); ?>
<li>
<p><strong><a title="Post: <?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></strong><br \> <span><?php echo get_post_meta($post->ID, 'standplaats', true); ?></span></p>
</li>
<?php endforeach; ?>
</ul>
</div>