Magento recently viewed products not working - magento-1.9.1

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.

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>

Wordpress Loop with Bootstrap 3.0

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; ?>

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"/>
}

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>

Warning: Cannot modify header information (something wrong with a localization PHP file) [duplicate]

This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 9 years ago.
My web server shows me the following warning, and I think know where is the problem:
WARNING: CANNOT MODIFY HEADER
INFORMATION - HEADERS ALREADY SENT BY
(OUTPUT STARTED AT
/WWW/ZXQ.NET/A/L/E/ALEXCHEN/HTDOCS/TEST/INDEX.PHP:10)
IN
/WWW/ZXQ.NET/A/L/E/ALEXCHEN/HTDOCS/TEST/LOCALIZATION.PHP
ON LINE 14
But I don't know exactly how to solve it.
Any suggestions?
localization:
<?php
//set session and cookies
session_start();
header('Cache-control: private'); // IE 6 FIX
function get_lang(){
if(!empty($_GET['lang'])) return $_GET['lang'];
if(!empty($_SESSION['lang'])) return $_SESSION['lang'];
if(!empty($_COOKIE['lang'])) return $_COOKIE['lang'];
return 'en';
}
function set_lang($lang){
setcookie("lang", $lang, time() + (3600 * 24 * 30)); //line 14
$_SESSION['lang'] = $lang;
}
function get_lang_file($lang){
$lang_file = "languages/lang.$lang.php";
if(file_exists($lang_file)) return $lang_file;
if($lang_file = get_lang_file('en')) return $lang_file;
return false;
}
//set translation helper function
function l($string){
static $localization;
if(!isset($localization)){
$lang = get_lang();
$lang_file = get_lang_file($lang);
if($lang_file) set_lang($lang);
$localization = include $lang_file;
}
return $localization[$string];
}
?>
index.php:
<?php
include_once 'localization.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta name="robots" content="index, follow"/>
<meta name="description" content="Web design and Translation / 網頁設計和翻譯" />
<meta name="keywords" content="web development, web developer, web design, web designer, translation, translator, taiwan, taipei, taichung, english, chinese, spanish, 網站開發者, 網頁設計, 網頁設計師, 翻譯, 翻譯著, 台灣, 台北, 台中, 英文, 中文, 西班牙文, html, css, javascript, php" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<title>Alex Chen - Web design and Translation / 網頁設計和翻譯</title>
<link rel="stylesheet" type="text/css" href="styles/reset.css" />
<link rel="stylesheet" type="text/css" href="styles/global.css" />
<link rel="stylesheet" type="text/css" href="fancybox/jquery.fancybox-1.3.1.css" />
<?php if(get_lang() == 'zh-tw' || get_lang() == 'zh-cn') {echo '<link rel="stylesheet" type="text/css" href="styles/chinese.css" />';} ?>
</head>
<body id="home">
<div id="header">
<div class="container">
<ul id="lang">
<li <?php if(get_lang() == 'en') {echo 'class="current"';} ?>>ENGLISH</li>
<li <?php if(get_lang() == 'es') {echo 'class="current"';} ?>>ESPAÑOL</li>
<li <?php if(get_lang() == 'zh-tw') {echo 'class="current"';} ?>>中文(繁體)</li>
<li <?php if(get_lang() == 'zh-cn') {echo 'class="current"';} ?>>中文(简体)</li>
</ul>
<div id="logo-bg">
<h1><a>ALEXCHEN</a></h1>
</div>
<div id="nav-bg">
<ul id="nav">
<li><?php echo l('nav1'); ?></li>
<li><?php echo l('nav2'); ?></li>
</ul>
</div>
</div><!-- .container -->
</div><!-- #header -->
<div id="content">
<div class="container">
<div class="showcase">
<div class="first">
<div id="nopic">
<p><?php echo l('tagline_p'); ?></p>
</div>
</div><!-- .first -->
<div class="pusher">
<h3><?php echo l('showcase1_h3'); ?></h3>
<p><?php echo l('showcase1_p'); ?></p>
<div class="pic">
<a id="showcase1" href="showcase/showcase1.php"><img src="images/showcase1t.png"/></a>
</div><!-- .pic -->
</div><!-- .pusher -->
<div class="pusher">
<h3><?php echo l('showcase2_h3'); ?></h3>
<p><?php echo l('showcase2_p'); ?></p>
<div class="pic">
<a id="showcase2" href="showcase/showcase2.php"><img src="images/showcase2t.png"/></a>
</div><!-- .pic -->
</div><!-- .pusher -->
<div class="pusher">
<h3><?php echo l('showcase4_h3'); ?></h3>
<p><?php echo l('showcase4_p'); ?></p>
<div class="pic">
<a id="showcase4" href="showcase/showcase4.php"><img src="images/showcase4t.png"/></a>
</div><!-- .pic -->
</div><!-- .pusher -->
<div class="pusher">
<h3><?php echo l('showcase9_h3'); ?></h3>
<p><?php echo l('showcase9_p'); ?></p>
<div class="pic">
<a id="showcase9" href="showcase/showcase9.php"><img src="images/showcase9t.png"/></a>
</div><!-- .pic -->
</div><!-- .pushed -->
<div class="pusher">
<h3><?php echo l('showcase5_h3'); ?></h3>
<p><?php echo l('showcase5_p'); ?></p>
<div class="pic">
<a id="showcase5" href="showcase/showcase5.php"><img src="images/showcase5t.png"/></a>
</div><!-- .pic -->
</div><!-- .pusher -->
<div class="pusher">
<h3><?php echo l('showcase8_h3'); ?></h3>
<p><?php echo l('showcase8_p'); ?></p>
<div class="pic">
<a id="showcase8" href="showcase/showcase8.php"><img src="images/showcase8t.png"/></a>
</div><!-- .pic -->
</div><!-- .pushed -->
<div class="pusher">
<h3><?php echo l('showcase6_h3'); ?></h3>
<p><?php echo l('showcase6_p'); ?></p>
<div class="pic">
<a id="showcase6" href="showcase/showcase6.php"><img src="images/showcase6t.png"/></a>
</div><!-- .pic -->
</div><!-- .pusher -->
<div class="pusher">
<h3><?php echo l('showcase7_h3'); ?></h3>
<p><?php echo l('showcase7_p'); ?></p>
<div class="pic">
<a id="showcase7" href="showcase/showcase7.php"><img src="images/showcase7t.png"/></a>
</div><!-- .pic -->
</div><!-- .pushed -->
</div><!-- .showcase -->
<div class="pusher">
<h3><?php echo l('showcase3_h3'); ?></h3>
<p><?php echo l('showcase3_p'); ?></p>
<div class="pic">
<a id="showcase3" href="showcase/showcase3.php"><img src="images/showcase3t.png"/></a>
</div><!-- .pic -->
</div><!-- .pusher -->
</div><!-- .container -->
</div><!-- #work -->
<div id="footer">
<div class="container">
<div id="footer-top">
<div id="about">
<h3><?php echo l('about_h3'); ?></h3>
<img src="images/profile.png"/>
<p><?php echo l('about_p'); ?></p>
</div>
<div id="info">
<h3><?php echo l('info_h3'); ?></h3>
<ul>
<li id="mobile"><p></p>0918051170</li>
<li id="gmail"><p></p>alexchen.net#gmail.com</li>
<li id="skype"><p></p>alexchen.net</li>
<li id="facebook">facebook</li>
</ul>
</div>
<div id="contact">
<h3><?php echo l('contact_h3'); ?></h3>
<p><?php echo l('contact_p'); ?></p>
<form id="sendmail" method="post" action="http://www.emailmeform.com/fid.php?formid=254816">
<label for="name"><?php echo l('form_label1'); ?></label>
<input type="text" id="name" name="FieldData0" />
<label for="email"><?php echo l('form_label2'); ?></label>
<input type="text" id="email" name="FieldData1" />
<label for="message"><?php echo l('form_label3'); ?></label>
<textarea type="text" id="message" name="FieldData2"></textarea>
<input id="button" type="submit" value="<?php echo l('submit'); ?>">
</form>
</div>
</div><!-- #footer-top -->
<div id="footer-bottom">
<div id="rights">
<p>Copyright © 2010 Alex Chen. All Rights Reserved. Hosted on Zymic. Contact form hosted on Email Me Form.</p>
</div>
<div id="ads">
<a id="nr" href="http://www.freedomain.co.nr/cheap_web_hosting.php" target="_blank"><img src="http://ruarmza.4u.com.ru/ch.gif" alt="Cheap Web Hosting Providers" width="88" height="31" border="0" /></a>
</div>
</div><!-- #footer-bottom -->
</div><!-- .container -->
</div><!-- #footer -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-13164175-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script><!-- google analytics -->
<script type="text/javascript" src="scripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="scripts/jquery.validate.min.js"></script>
<script type="text/javascript" src="fancybox/jquery.fancybox-1.3.1.pack.js"></script>
<script type="text/javascript" src="scripts/jquery.scroll.min.js"></script>
<script type="text/javascript" src="scripts/custom.js"></script>
<?php if(get_lang() =='en') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-en.js"></script>';} ?>
<?php if(get_lang() =='es') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-es.js"></script>';} ?>
<?php if(get_lang() =='zh-tw') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-zh-tw.js"></script>';} ?>
<?php if(get_lang() =='zh-cn') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-zh-cn.js"></script>';} ?>
</body>
</html>
The cause of this error is that modifying the HTTP header requires that the HTTP header is not already sent to the client. And this happens when the first data is put out (either implicitly or explicitly). So with the first data that is put out, the HTTP header is sent along to the client and cannot be modified afterwards.
In your case, according to the error message, some function call tries to modify the HTTP header at /TEST/LOCALIZATION.PHP on line 10 but the output has already started at /TEST/INDEX.PHP on line 1.
To fix this you either need to make sure that the modification of the HTTP header happens before the first output is done (input-process-output model) or you buffer any output with PHP’s output control functions.
The problem seems to be that the function l() calls set_lang(), after content is already sent to the browser. Meanwhile, set_lang() is trying to set a cookie, which must be done in the header, before any content is sent to the browser.
swap your localization.php for this one..
<?php
session_start();
header('Cache-control: private'); // IE 6 FIX
get_localization();
function get_localization()
{
static $localization;
if( empty($localization) ) {
$lang = 'en';
if(!empty($_GET['lang'])) $lang = $_GET['lang'];
if(!empty($_SESSION['lang'])) $lang = $_SESSION['lang'];
if(!empty($_COOKIE['lang'])) $lang = $_COOKIE['lang'];
setcookie("lang", $lang, time() + (3600 * 24 * 30)); //line 14
$_SESSION['lang'] = $lang;
$lang_file = "languages/lang.$lang.php";
if( !file_exists($lang_file) ) {
if( !$lang_file = get_lang_file('en') ) {
return false;
}
}
include $lang_file;
$localization = $lang;
}
return $localization;
}
function l($string){
$l = get_localization();
return is_array($l) && isset($l[$string]) ? $l[$string]: $string;
}
?>
should sort it
make sure that there is no output before calling header(). also, check if your files have BOM(which comes before <?php and thus is output..).