Trying to make link with user id in joomla - php

I'm trying to add button with link to a seller store in my joomla component and I have no idea how can I do it.
I'm adding code from php file that has what I need but I don't know how to add it on another page. If someone can guide me with some how to step it would be awesome.
Here is the page that has the link to the store:
<?php
// no direct access
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
/** #var SellaciousViewProduct $this */
$sellers = $this->item->get('sellers');
if (!isset($sellers[0]) || (count($sellers) == 1 && $sellers[0]->seller_uid == $this->item->get('seller_uid')))
{
return;
}
$c_currency = $this->helper->currency->current('code_3');
?>
<div class="clearfix"></div>
<a name="also-selling"> </a>
<hr class="isolate"/>
<h4 class="center"><?php echo JText::_('COM_SELLACIOUS_PRODUCT_HEADING_BLOCK_SELLERS'); ?></h4>
<table class="product-sellers table table-striped table-hover table-bordered">
<thead>
<tr>
<th>SELLER </th>
<th>DELIVERY INFO</th>
<th>PRICE </th>
<th>ACTION </th>
</tr>
</thead>
<tbody>
<?php
foreach ($sellers as $i => $seller)
{
/** #var Registry $item */
$item = new Registry($seller);
$s_currency = $this->helper->currency->forSeller($item->get('seller_uid'), 'code_3');
// todo: Add this to config (show current one or not in more sellers) and move to model
if ($item->get('seller_uid') == $this->item->get('seller_uid'))
{
continue;
}
?>
<tr>
<td style="width: 220px;" class="nowrap">
<div class="seller-info">
<a href="<?php echo JRoute::_('index.php?option=com_sellacious&view=store&id=' . $item->get('seller_uid')); ?>">
<?php echo $item->get('seller_company', $item->get('seller_name')); ?></a>
<?php $rating = $item->get('seller_rating.rating'); ?>
<span class="label <?php echo ($rating < 3) ? 'label-warning' : 'label-success' ?>"><?php echo number_format($rating, 1) ?> / 5.0</span>
</div>
<?php if ($item->get('exchange_days')): ?>
<?php if ($item->get('exchange_tnc')):
$options = array(
'title' => '<strong>' . (int) $item->get('exchange_days') . ' Days</strong> Replacement Guarantee',
'backdrop' => 'static',
);
echo JHtml::_('bootstrap.renderModal', 'exchange_tnc-' . $item->get('code'), $options, $item->get('exchange_tnc'));
endif; ?>
<div class="replacement-info">
<i class="fa fa-refresh"></i>
<strong> <?php echo (int) $item->get('exchange_days') ?> Days</strong> Replacement
<?php if ($item->get('exchange_tnc')): ?>
[<i class="fa fa-question"></i>]
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($item->get('return_days')): ?>
<?php if ($item->get('return_tnc')):
$options = array(
'title' => '<strong>' . (int) $item->get('return_days') . ' Days</strong> Easy Return',
'backdrop' => 'static',
);
echo JHtml::_('bootstrap.renderModal', 'return_tnc-' . $item->get('code'), $options, $item->get('return_tnc'));
endif; ?>
<div class="replacement-info">
<i class="fa fa-refresh"></i>
<strong> <?php echo (int) $item->get('return_days') ?> Days</strong> Easy Return
<?php if ($item->get('return_tnc')): ?>
[<i class="fa fa-question"></i>]
<?php endif; ?>
</div>
<?php endif; ?>
<div>
<?php $allowed_listing_type = (array) $this->helper->config->get('allowed_listing_type'); ?>
<?php if (count($allowed_listing_type) != 1): ?>
<span class="label label-info margin-top-10">Condition:
<?php
$list_type = $item->get('listing_type');
// What if this is a not allowed listing type value
if ($list_type == 1):
echo JText::plural('COM_SELLACIOUS_PRODUCT_FIELD_LISTING_TYPE_VALUE', $list_type);
else:
$list_cond = $item->get('item_condition');
echo JText::plural('COM_SELLACIOUS_PRODUCT_FIELD_ITEM_CONDITION_VALUE', $list_type * 10 + (int) $list_cond);
endif;
?>
</span>
<?php endif; ?>
</div>
</td>
<td>
<div class="delivery-info">
<?php echo JHtml::_('date', '+ ' . rand(1, 30) . ' days', 'D, dS F'); ?>
<br>
<small><?php
$flat_ship = $item->get('flat_shipping');
$ship_fee = $item->get('shipping_flat_fee');
if ($flat_ship == 0)
{
echo JText::_('COM_SELLACIOUS_PRODUCT_SHIPPING_FEE_IN_CART');
}
elseif (round($ship_fee, 2) > 0)
{
$fee = $this->helper->currency->display($ship_fee, $s_currency, $c_currency, true);
echo JText::sprintf('COM_SELLACIOUS_PRODUCT_SHIPPING_FEE_FLAT', $fee);
}
else
{
echo JText::_('COM_SELLACIOUS_PRODUCT_SHIPPING_FEE_FREE');
}
?></small>
</div>
</td>
<td style="width:90px;" class="center">
<span class="product-price-sm"><?php
echo $this->helper->currency->display($item->get('price.sales_price'), $s_currency, $c_currency, true) ?></span>
</td>
<td style="width:100px;" class="nowrap">
<?php $link = JRoute::_('index.php?option=com_sellacious&view=product&p=' . $item->get('code')); ?>
<button class="btn btn-primary btn-cart-sm">DETAILS</button><br/>
<button type="button" class="btn btn-warning btn-cart-sm btn-add-cart" data-item="<?php echo $item->get('code') ?>">ДОБАВИ В КОЛИЧКАТА</button>
<!--<button type="button" class="btn btn-success btn-cart-sm btn-add-cart"
data-item="<?php /*echo $item->get('code') */?>" data-checkout="true">КУПИ СЕГА</button>-->
</td>
</tr>
<?php
}
?>
</tbody>
</table>
And this is the file I'm trying to import the part with the link to the sellers store
<?php
// no direct access.
defined('_JEXEC') or die;
jimport('sellacious.loader');
if (class_exists('SellaciousHelper'))
{
$helper = SellaciousHelper::getInstance();
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- favicon -->
<link rel="shortcut icon" href="templates/sellacious/images/favicon/favicon.ico" type="image/x-icon" />
<link rel="icon" href="templates/sellacious/images/favicon/favicon.ico" type="image/x-icon" />
<?php
$user = JFactory::getUser();
$doc = JFactory::getDocument();
$app = JFactory::getApplication();
$sitename = $app->get('sitename');
JHtml::_('script', 'media/com_sellacious/js/plugin/messagebox/jquery.messagebox.min.js', false, false);
JHtml::_('stylesheet', 'media/com_sellacious/js/plugin/messagebox/jquery.messagebox.css', null, false);
$doc->addStyleSheet('//fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,300,400,700');
$doc->addStyleSheet('templates/sellacious/css/bootstrap.min.css', 'text/css', 'screen');
$doc->addStyleSheet('templates/sellacious/css/font-awesome.min.css', 'text/css', 'screen');
$doc->addStyleSheet('templates/sellacious/css/joomla-icons.css', 'text/css', 'screen');
$doc->addStyleSheet('templates/sellacious/css/smartadmin-production.css', 'text/css', 'screen');
$doc->addStyleSheet('templates/sellacious/css/smartadmin-skins.css', 'text/css', 'screen');
$doc->addStyleSheet('templates/sellacious/css/custom-style.css', 'text/css', 'screen');
if ($this->direction == 'rtl')
{
$doc->addStyleSheet('templates/sellacious/css/smartadmin-rtl.css', 'text/css', 'screen');
}
JHtml::_('jquery.framework');
JHtml::_('bootstrap.tooltip');
$doc->addScript('templates/sellacious/js/libs/jquery-ui-1.10.3.min.js'); // jQuery UI full, not from joomla core's minimised one
$doc->addScript('templates/sellacious/js/plugin/fastclick/fastclick.js'); // FastClick: For mobile devices
$doc->addScript('templates/sellacious/js/plugin/jquery-touch/jquery.ui.touch-punch.min.js'); // JS TOUCH plugin for mobile drag-drop touch events
$doc->addScript('templates/sellacious/js/plugin/msie-fix/jquery.mb.browser.min.js'); // browser msie issue fix
$doc->addScript('templates/sellacious/js/bootstrap/bootstrap.min.js'); // Bootstrap JS
$doc->addScript('templates/sellacious/js/notification/SmartNotification.min.js'); // Custom notification
$doc->addScript('templates/sellacious/js/plugin/cookie/jquery.cookie.min.js'); // cookie
$doc->addScript('templates/sellacious/js/sellacious-core.js'); // Sellacious core functions to work template wide
$doc->addScript('templates/sellacious/js/sellacious-notifier.js'); // Sellacious notification per view page
?>
<script data-pace-options='{ "restartOnRequestAfter": true }' src="templates/sellacious/js/plugin/pace/pace.min.js"></script>
<jdoc:include type="head"/>
<!--[if IE 7]>
<h1>Your browser is out of date, please update your browser by going to www.microsoft.com/download</h1>
<![endif]-->
</head>
<?php $collapse = $app->input->cookie->get('collapsedmenu'); ?>
<body class="fixed-page-footer <?php echo $app->input->get('hidemainmenu') || $collapse ? 'minified' : '' ?>"><!--
The possible classes: smart-style-3, minified, fixed-ribbon, fixed-header, fixed-width -->
<!-- HEADER -->
<header id="header" class="btn-group-justified">
<div id="logo-group">
<?php
$logo = 'templates/sellacious/images/logo.png';
if (isset($helper) && $helper->access->isSubscribed()):
$altLogo = $helper->media->getImage('config.backoffice_logo', 1, false);
$logo = $altLogo ?: $logo;
endif;
?>
<span id="logo"><a class="pull-left" href="<?php echo JRoute::_('index.php') ?>">
<img src="<?php echo $logo ?>" alt="<?php echo htmlspecialchars($sitename) ?>"></a></span>
<?php if ($this->countModules('logo-group')) { ?>
<!-- OPTIMAL PLACE FOR NOTIFICATION MODULE -->
<jdoc:include type="modules" name="logo-group" style="none"/>
<?php } ?>
</div>
<?php if ($this->countModules('header-left')) { ?>
<!-- Project Context -->
<jdoc:include type="modules" name="header-left" style="none"/>
<?php } ?>
<!-- pulled right: nav area -->
<div class="pull-right" style="margin-right: 1px;">
<!-- logout button -->
<div id="logout" class="btn-header transparent pull-right cursor-pointer">
<?php $logout_url = 'index.php?option=com_login&task=logout&' . JSession::getFormToken() . '=1'; ?>
<span> <a href="<?php echo $logout_url ?>" title="Sign Out" data-action="userLogout" class="hasTooltip" data-placement="bottom"
data-logout-msg="You can improve your security further after logging out by closing this opened browser"><i
class="fa fa-sign-out"></i></a> </span>
</div>
<!-- end logout button -->
<!-- fullscreen button -->
<div id="fullscreen" class="btn-header transparent pull-right">
<span> <a href="javascript:void(0);" data-action="launchFullscreen" class="hasTooltip" data-placement="bottom"
title="Full Screen"><i class="fa fa-arrows-alt"></i></a> </span>
</div>
<!-- end fullscreen button -->
<!-- back to Joomla administrator button -->
<div id="my-tore" class="btn-header transparent pull-right cursor-pointer">
<span> <a href="../<?php echo basename(JPATH_ADMINISTRATOR); ?>/index.php" class="hasTooltip" data-placement="bottom"
title="Back to Joomla Administrator"><i class="fa fa-joomla"></i></a> </span>
</div>
<!-- end back to Joomla administrator button -->
<!-- Go to Joomla frontend button -->
<div id="joomla" class="btn-header transparent pull-right cursor-pointer">
<span> <a href="../index.php" target="_blank" class="hasTooltip" data-placement="bottom"
title="View Site"><i class="fa fa-external-link"></i></a> </span>
</div>
<!-- end Go to Joomla frontend button -->
<!-- Go to Joomla frontend button -->
<div id="hide-menu" class="btn-header transparent pull-right cursor-pointer">
<span> <a href="#" class="hasTooltip" data-placement="bottom" data-menu="hidemenu"
title="Menu"><i class="fa fa-reorder"></i></a> </span>
</div>
<!-- end Go to Joomla frontend button -->
<!-- Sync media button -->
<div id="sync-media" class="btn-header transparent pull-right cursor-pointer">
<span> <a href="javascript:void(0)" class="hasTooltip" data-placement="bottom" data-action="sync-media" style="width: 135px;"
title="Refresh Media Uploads"><i class="fa fa-refresh"></i> <span class="text-normal"> <?php
echo JText::_('COM_SELLACIOUS_MEDIA_SYNC_BUTTON_LABEL') ?> </span></a> </span>
</div>
<!-- end Sync media button -->
<?php if ($this->countModules('header-right')): ?>
<jdoc:include type="modules" name="header-right" style="none"/>
<?php endif; ?>
</div>
<!-- end pulled right: nav area -->
<?php if (isset($helper) && ($helper->access->check('config.edit') || !$helper->access->isSubscribed())): ?>
<div id="context-news" class="pull-right padding-5"><!-- dynamic news --></div>
<?php endif; ?>
</header>
<!-- END HEADER -->
<!-- Left panel : Navigation area -->
<?php if ($this->countModules('left-panel') || $this->countModules('menu')) { ?>
<!-- Note: This width of the aside area can be adjusted through LESS variables -->
<aside id="left-panel">
<div class="login-info">
<span> <!-- User image size is adjusted inside CSS, it should stay as it -->
<a style="cursor:auto;" id="show-shortcut" data-action="toggleShortcut" href="index.php?option=com_sellacious&view=profile">
<!--<img src="templates/sellacious/images/avatars/male.png" alt="me" class="online"/>-->
<i class="fa fa-user"></i>
<span><?php echo $user->get('name'); ?></span>
</a>
</span>
</div>
<!-- User info -->
<?php if ($this->countModules('left-panel')) { ?>
<jdoc:include type="modules" name="left-panel" style="none"/>
<?php } ?>
<!-- end user info -->
<!-- NAVIGATION : This navigation is also responsive
To make this navigation dynamic please make sure to link the node
(the reference to the nav > ul) after page load. Or the navigation will not initialize.
-->
<!-- User info -->
<?php if ($this->countModules('menu')) { ?>
<jdoc:include type="modules" name="menu" style="none"/>
<?php } ?>
<!-- end user info -->
<span class="minifyme"> <i class="fa fa-arrow-circle-left hit"></i> </span>
</aside>
<!-- END NAVIGATION -->
<?php } ?>
<!-- End Left panel : Navigation area -->
<!-- MAIN PANEL -->
<div id="main" role="main">
<!-- RIBBON -->
<div id="ribbon">
<!-- breadcrumb -->
<?php if ($this->countModules('ribbon-left')) { ?>
<jdoc:include type="modules" name="ribbon-left" style="none"/>
<?php } ?>
<!-- end breadcrumb -->
<?php if ($this->countModules('ribbon-right')) { ?>
<span class="ribbon-button-alignment pull-right">
<jdoc:include type="modules" name="ribbon-right" style="none"/>
</span>
<?php } ?>
<div class="btn-headactions pull-right">
<i class="fa fa-book"></i> Documentation
<i class="fa fa-phone"></i> Support
<i class="fa fa-star"></i> Rate us on JED
</div>
</div>
<!-- END RIBBON -->
<?php if ($this->countModules('toolbar') || $this->countModules('title')) : ?>
<div class="box-toolbar">
<div class="">
<!-- col -->
<div class="pull-left">
<!-- PAGE HEADER -->
<jdoc:include type="modules" name="title"/>
</div>
<!-- end col -->
<!-- right side of the page with the sparkline graphs -->
<!-- col -->
<div class="pull-right">
<?php if ($this->countModules('toolbar')) : ?>
<span class="pull-right">
<jdoc:include type="modules" name="toolbar" style="none"/>
</span>
<?php endif; ?>
</div>
<!-- end col -->
</div>
</div>
<?php endif; ?>
<?php if ($this->countModules('top')) : ?>
<div class="row">
<div class="col-sm-12">
<jdoc:include type="modules" name="content-top" style="xhtml"/>
</div>
</div>
<?php endif; ?>
<?php if ($this->countModules('submenu')) : ?>
<div class="row">
<div class="col-sm-12">
<jdoc:include type="modules" name="submenu" style="none"/>
</div>
</div>
<?php endif; ?>
<div class="clearfix"></div>
<!-- MAIN CONTENT -->
<div id="content">
<?php if ($this->countModules('content-top')) { ?>
<div class="row">
<jdoc:include type="modules" name="content-top" style="none"/>
</div>
<?php } ?>
<div class="clearfix"></div>
<div class="component content-wrap">
<div id="system-message-container"><jdoc:include type="message" style="xhtml"/></div>
<div class="clearfix"></div>
<jdoc:include type="component" style="xhtml"/>
<div class="clearfix"></div>
</div>
<?php if ($this->countModules('content-bottom')) { ?>
<div class="row">
<jdoc:include type="modules" name="content-bottom" style="none"/>
</div>
<?php } ?>
</div>
<div class="clearfix"></div>
<!-- END MAIN CONTENT -->
</div>
<!-- END MAIN PANEL -->
<?php if ($this->countModules('footer')) { ?>
<jdoc:include type="modules" name="footer" style="none"/>
<?php } ?>
<jdoc:include type="modules" name="dynamic" style="xhtml"/>
<!-- Google Analytics code below -->
<?php if ($ga_code = $this->params->get('ga_code')) { ?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '<?php echo htmlspecialchars($ga_code) ?>']);
_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>
<?php } ?>
</body>
</html>
I understand that I need this link,
<a href="<?php echo JRoute::_('index.php?option=com_sellacious&view=store&id=' . $item->get('seller_uid')); ?>">
<?php echo $item->get('seller_company', $item->get('seller_name')); ?></a>
but don't know how to implement it in the second file.

You need access to the view object from the sellacious product view in your file (i.e. the this in $sellers = **$this**->item->get('sellers')). Your file is a template file, and templates don't have access to the component view object - it's already been marked for garbage collection by the time the template renders. If you are only rendering the sellacious store links on pages that include the sellacious component, you could copy and store the data in JRegistry to use in the template. You could do this in a layout override from your template (layouts have access to their component's view object). If it's for use in your custom component or other components, you'd need to write model logic to pull the information from the database. In that case, I'd look at how the sellacious model is doing it and copy just the parts you need.

Related

How Not To Execute Data If imgProductx Is NULL In The Database

I have to following php code where I want to execute the image function if there is an image to show. Which means If the image field is empty/NULL I dont want to show the image, because it will give an error saying 'no image found'.
How can I do this?
Thanks in advance.
<div>
<?php if (!empty($datas[0]['imgProduct1'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct1']);?>" class="img-fluid" alt="Product1" />
<?php } ?>
</div>
<div>
<?php if (!empty($datas[0]['imgProduct2'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct2']);?>" class="img-fluid" alt="Product2" />
<?php } ?>
</div>
<div>
<?php if (!empty($datas[0]['imgProduct3'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct3']);?>" class="img-fluid" alt="Product3" />
<?php } ?>
</div>
<div>
<?php if (!empty($datas[0]['imgProduct4'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct4']);?>" class="img-fluid" alt="Product4" />
<?php } ?>
</div>
(Goes till imgProduct8)
In the Database image, I have my picture data ready. In the last line you see imgProduct1 filled, imgProduct2 filled, imgProduct3 filled. After that imgProduct4 is NULL, so I dont want to execute the image function for that matter.
Database image:
In Result from the database picture, you see the result I am getting. So again imgProduct1, imgProduct2 and imgProduct3 are filled with a link, imgProduct4, imgProduct5 etc are not. So I dont want to show the image, thats not there.
Result from database:
The result I am getting now is 3 pictures in my slide show and after that just blank pictures. So he is still think there are more pictures to show.
my whole code:
<?php
require('../php/connection.php');
$product = $_GET['product'];
$sql = "SELECT * FROM tblproduct WHERE strProductNaam='$product'";
$result = sqlsrv_query($conn,$sql);
if( $result === false ) {
die( print_r( sqlsrv_errors(), true));
}
while($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) {
$datas[] = $row;
}
echo '<pre>';
print_r($datas);
echo '</pre>';
sqlsrv_free_stmt($result);
sqlsrv_close($conn);
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Home Gym</title>
<?php
include('../structure/effects.php');
?>
</head>
<body>
<!-- Header -->
<?php
include('../structure/header.php');
?>
<!-- /Header -->
<!-- Main -->
<main>
<br>
<!-- Product Section -->
<section class="single-product">
<div class="container">
<div class="row">
<div class="col-md-5">
<div class="container-fluid p-0">
<div class="site-slider">
<div class="slider-one">
<div>
<?php if (!empty($datas[0]['imgProduct1'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct1']);?>" class="img-fluid" alt="Product1" />
<?php } ?>
</div>
<div>
<?php if (!empty($datas[0]['imgProduct2'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct2']);?>" class="img-fluid" alt="Product2" />
<?php } ?>
</div>
<div>
<?php if (!empty($datas[0]['imgProduct3'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct3']);?>" class="img-fluid" alt="Product3" />
<?php } ?>
</div>
<div>
<?php if (($datas[0]['imgProduct4']) !== NULL){ ?>
<img src="<?php echo ($datas[0]['imgProduct4']);?>" class="img-fluid" alt="Product4" />
<?php } ?>
</div>
<div>
<?php if (($datas[0]['imgProduct4']) !== NULL){ ?>
<img src="<?php echo ($datas[0]['imgProduct5']);?>" class="img-fluid" alt="Product5" />
<?php } ?>
</div>
<div>
<?php if (($datas[0]['imgProduct4']) !== NULL){ ?>
<img src="<?php echo ($datas[0]['imgProduct6']);?>" class="img-fluid" alt="Product6" />
<?php } ?>
</div>
<div>
<?php if (($datas[0]['imgProduct4']) !== NULL){ ?>
<img src="<?php echo ($datas[0]['imgProduct7']);?>" class="img-fluid" alt="Product7" />
<?php } ?>
</div>
<div>
<?php if (($datas[0]['imgProduct4']) !== NULL){ ?>
<img src="<?php echo ($datas[0]['imgProduct8']);?>" class="img-fluid" alt="Product8" />
<?php } ?>
</div>
</div>
<div class="slider-button">
<span class="prev position-top"><i class="fas fa-chevron-left"></i></span>
<span class="next position-top right-0"><i class="fas fa-chevron-right"></i></span>
</div>
</div>
</div>
</div>
<div class="col-md-7">
<p class="new-arrival text-center">NEW</p>
<div class="product-bottom">
<p><i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
</p>
<p><h3><?php echo ($datas[0]['strProductNaam']); ?></h3></p>
<p class="price"><h5><s>€<?php echo ($datas[0]['intPrijs']); ?></s> <b><span class="make_red">€<?php echo ($datas[0]['strSalePrijs']); ?></span> </b></h5></p>
<p><b>Availability: </b>In Stock</p>
</div>
<div class="positive">
<p><i class="fa fa-plus" aria-hidden="true"></i> <?php echo ($datas[0]['strPlusPunt1']); ?></p>
<p><i class="fa fa-plus" aria-hidden="true"></i> <?php echo ($datas[0]['strPlusPunt2']); ?></p>
</div>
<div class="negative">
</div>
<label>Quantity: </label>
<input class="text-center" type="text" value="1"></input>
<button type="button" class="btn btn-primary">Add to Cart</button>
<table class="content-table">
<thead>
<tr>
<th>Product Specifications</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Type</td>
<td><?php echo ($datas[0]['strSpecSoort']); ?></td>
</tr>
<tr class="active-row">
<td>Guarantee</td>
<td><?php echo ($datas[0]['strSpecGarantie']); ?></td>
</tr>
<tr>
<td>Material</td>
<td><?php echo ($datas[0]['strSpecMateriaal']); ?></td>
</tr>
<tr class="active-row">
<td>Weight</td>
<td><?php echo ($datas[0]['strGewicht']); ?></td>
</tr>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</section>
<!-- /Product Section -->
<!-- Product Description -->
<section class="product-description">
<div class="container">
<h6>Product Description</h6>
<p><?php echo ($datas[0]['strBeschrijving']); ?></p>
</div>
</section>
<!-- /Product Descriptionn -->
<br>
<hr class="hr">
<!-- On Sale Product -->
<?php
include('../product-sale.php');
?>
<!-- /On Sale Product -->
</main>
<!-- /Main -->
<!-- Footer -->
<?php
include('../structure/footer.php');
?>
<!-- /Footer -->
<!-- Script: Bootstrap CDN, JS -->
<?php
include('../structure/script.php');
?>
</body>
</html>
you can try updating the query:
SELECT * FROM table_name WHERE image_column != NULL
Hope so it might help you. It would be better if you provide the whole code...
SOLVED:
<?php if (!empty($datas[0]['imgProduct1'])){ ?>
<div>
<img src="<?php echo ($datas[0]['imgProduct1']);?>" class="img-fluid" alt="Product1" />
</div>
<?php } ?>
The div had to be inside of the if function. That's why a white screen popped up.

php sessions on different pages

I am new to php.I am developing a website and have some problems with sessions on different pages.When i login to website my header becomes
Main Reklam Logout Anna
And this is what happens when i click to other links in my website
Main Reklam Login Register
But when i click again to main the sessions are again there
Main Reklam Logout Anna
Here is my header.php
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Telefonal</title>
<meta name="description" content="Source code generated using layoutit.com">
<meta name="author" content="LayoutIt!">
<base href="http://domain.com"></base>
<link rel="stylesheet" href="<?php echo $config['template'];? >assets/css/bootstrap.min.css">
<link rel="stylesheet" href="<?php echo $config['template'];?>assets/css/style.css">
<link rel="stylesheet" href="<?php echo $config['template'];?>assets/css/custom.css">
<link rel="stylesheet" href="<?php echo $config['template'];?>assets/css/font-awesome.min.css">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css">
<link href='https://fonts.googleapis.com/css?family=Ubuntu' rel='stylesheet' type='text/css'>
</head>
<body>
<div class="container-fluid" >
<!-- Navigation menu -->
<div class="row" >
<div class="col-md-12">
<nav class="navbar navbar-default top-navigation" role="navigation" >
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse " id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-left">
<li id="left-first-list">
Main
</li>
<li id="left-second-list">
<img src="upload/main/website-design-symbol.png"> Reklam
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<?php if(isset($_SESSION['user']) ){?>
<li id="right-first-list">
<img src="upload/main/login.png"> Logout
</li> <?php
}else{?>
<li id="right-first-list">
<img src="upload/main/login.png"> Login
</li>
<?php
}?>
<?php if(isset($_SESSION['user'])){?>
<li id="right-second-list">
<img src="upload/main/clipboard-with-pencil.png"> <?php echo $_SESSION['user'];?>
</li> <?php
}else{?>
<li id="right-second-list">
<img src="upload/main/clipboard-with-pencil.png"> Qeydiyyat
</li>
<?php }?>
</ul>
</div>
</nav>
</div>
</div>
And here is my login.php i am using facebook login
<?php
session_start();
//require 'functions.php';
// added in v4.0.0
require_once 'dbconfig.php';
require_once 'autoload.php';
use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\Entities\AccessToken;
use Facebook\HttpClients\FacebookCurlHttpClient;
use Facebook\HttpClients\FacebookHttpable;
// init app with app id and secret
FacebookSession::setDefaultApplication( '**********','*************8' );
// login helper with redirect_uri
$helper = new FacebookRedirectLoginHelper('http://www.domain.com/fbconfig.php' );
try {
$session = $helper->getSessionFromRedirect();
} catch( FacebookRequestException $ex ) {
// When Facebook returns an error
} catch( Exception $ex ) {
// When validation fails or other local issues
}
// see if we have a session
if ( isset( $session ) ) {
// graph api request for user data
$request = new FacebookRequest( $session, 'GET', '/me' );
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject();
$fbid = $graphObject->getProperty('id'); // To Get Facebook ID
$fbfullname = $graphObject->getProperty('name'); // To Get Facebook full name
$femail = $graphObject->getProperty('email'); // To Get Facebook email ID
/* ---- Session Variables -----*/
$_SESSION['user_id'] = $fbid;
$_SESSION['user'] = $fbfullname;
$_SESSION['EMAIL'] = $femail;
// checkuser($fuid,$ffname,$femail);
$query="SELECT * from Users where Fuid='$fbid'";
$check = $db->query($query);
$res = $check->num_rows;
if (empty($res) || $res==0) { // if new user . Insert a new record
$query2 = "INSERT INTO Users VALUES ('". $fbid ."','$fbfullname','$femail')";
$db->query($query2);
$query_up="UPDATE Users SET Fuid='$fbid'";
$db->query($query_up);
$path="upload/".$fbid."/";
if (!file_exists($path)) {
mkdir($path);}
} else { // If Returned user . update the user record
$query3 = "UPDATE Users SET Ffname='$fbfullname', Femail='$femail' where Fuid='$fbid'";
$db->query($query3);
}
header("Location: index.php");
} else {
$loginUrl = $helper->getLoginUrl();
header("Location: ".$loginUrl);
}
?>
Detail.php
<?php
if(isset($_GET['pid'])){
$pid=(int)$_GET['pid'];
$_SESSION['pid']=$pid;
$product_query=
"SELECT * from `ad`,`ad_description`
WHERE `ad`.`ad_id`=`ad_description`.`ad_id`
AND `ad`.`ad_id`='$pid'
AND `ad`.`created_date`< NOW()
ORDER BY `ad`.`created_date`
Limit 1";
$get_products_row=$db->query($product_query);
if($get_products_row->num_rows>0){
while($single_product=$get_products_row->fetch_assoc()){
$products[]=array(
'ad_id'=>$single_product['ad_id'],
'ad_name' =>$single_product['ad_name'],
'picture'=>$single_product['picture'],
'price'=>$single_product['price'],
'ad_description'=>$single_product['ad_description'],
'created_date'=>$single_product['created_date'],
'user_id'=>$single_product['user_id'],
'barter'=>$single_product['barter'],
'city'=>$single_product['city'],
'phone'=>$single_product['phone'],
);
}
//}
}else{
echo "lllllll";
//header("Location: index.php?page=404");
}
}else{
echo "aaaaaaa";
//header("Location: index.php?page=404");
}
require_once($config['template']."detail.php");
?>
<?php
include_once($config['template']."header.php");
include_once($config['template']."brand_list.php");
?>
<?php if(isset($products)){ ?>
<?php foreach ($products as $product) {
$image=$product['picture'];
$image_arr=explode("|*|", $image);
if (strlen($image_arr[1])!=0) {
$src1="upload/".$product['user_id']."/".$image_arr[1];
}else{
$src1="upload/main/no_image.gif";
}
if (strlen($image_arr[2])!=0) {
$src2="upload/".$product['user_id']."/".$image_arr[2];
}else{
$src2="upload/main/no_image.gif";
}
if (strlen($image_arr[3])!=0) {
$src3="upload/".$product['user_id']."/".$image_arr[3];
}else{
$src3="upload/main/no_image.gif";
}
if (strlen($image_arr[4])!=0) {
$src4="upload/".$product['user_id']."/".$image_arr[4];
}else{
$src4="upload/main/no_image.gif";
}
if ($product['picture']==1) {
$barter="mümkündür";
}else{
$barter="mümkün deyil";
}
$url=$_SERVER['REQUEST_URI'];
$check_url="SELECT * from counter where page_url='$url'";
$row=$db->query($check_url);
if ($row->num_rows == 0) {
$query="INSERT INTO counter values(NULL,'$url','1')";
$db->query($query);
}else{
$query2="UPDATE counter
SET count=count+1
WHERE page_url='$url'";
$db->query($query2);
}
$query_select_hits="SELECT count from counter where page_url='$url'";
$row_for_hit=$db->query($query_select_hits);
while ($data=$row_for_hit->fetch_assoc()) {
$hits=$data['count'];
}
//$hits=$row_for_hit->num_rows;
?>
<div class="row">
<div class="col-md-12">
<div class="row" >
<div class="col-md-6" >
<div class="row" >
<div class="col-md-12">
<table class="table" >
<thead>
<tr>
<!-- <th>
#
</th> -->
<th>
<?php echo $product['ad_name']; ?>
</th>
<!-- <th>
Payment Taken
</th>
<th>
Status
</th> -->
</tr>
</thead>
<tbody>
<tr>
<td>
Model
</td>
<td>
<?php echo $product['ad_name']; ?>
</td>
</tr>
<tr class="active">
<td>
Barter imkani
</td>
<td>
<?php echo $barter;?>
</td>
</tr>
<tr >
<td>
Şəhər
</td>
<td>
<?php echo $product['city'];?>
</td>
</tr>
<tr class="active">
<td>
Dərc olunma tarixi
</td>
<td>
<?php echo $product['created_date'];?>
</td>
</tr>
<tr >
<td>
Qiymət
</td>
<td>
<?php echo $product['price'];?> AZN
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-md-12 elave-melumat">
<h3>
Baxilib <img style="width:40px;height:40px;border-radius:10px;" src="upload/main/animated.gif" /> <?php echo $hits;?>
</h3>
<div>
<p>
</p>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 elave-melumat">
<h3>
Əlavə məlumat
</h3>
<div>
<p>
<?php echo $product['ad_description'];?>
</p>
</div>
</div>
</div>
<div class="row" >
<div class="col-md-12 elaqe">
<h3>
Əlaqə
</h3>
<div>
<p>
<?php echo $product['phone'];?>
</p>
</div>
</div>
</div>
<div class="row" >
<div class="col-md-12 elaqe">
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.6&appId=234614743547307";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-comments" data-href="https://www.facebook.com/telefonalaz-1013127532086903/" data-width="500" data-numposts="3">
</div>
</div>
</div>
</div>
<div class="col-md-6 allImages" >
<div class="row" >
<div class="col-md-6 detail-picture">
<img id="myImg" alt="Trolltunga, Norway" width="270" height="200" src="<?php echo $src1; ?>"/>
<!-- The Modal -->
<div id="myModal" class="modal">
<span class="close">×</span>
<img class="modal-content" id="img01">
<div id="caption"></div>
</div>
<img id="myImg" alt="Trolltunga, Norway" width="270" height="200" src="<?php echo $src2; ?>"/>
<!-- The Modal -->
<div id="myModal" class="modal">
<span class="close">×</span>
<img class="modal-content" id="img01">
<div id="caption"></div>
</div>
</div>
<div class="col-md-6 detail-picture">
<img id="myImg" alt="Trolltunga, Norway" width="270" height="200" src="<?php echo $src3; ?>"/>
<!-- The Modal -->
<div id="myModal" class="modal">
<span class="close">×</span>
<img class="modal-content" id="img01">
<div id="caption"></div>
</div>
<img id="myImg" alt="Trolltunga, Norway" width="270" height="200" src="<?php echo $src4;?>" />
<!-- The Modal -->
<div id="myModal" class="modal">
<span class="close">×</span>
<img class="modal-content" id="img01">
<div id="caption"></div>
</div>
</div>
</div>
</div>
<script>
// Get the modal
var modal = document.getElementById('myModal');
// Get the image and insert it inside the modal - use its "alt" text as a caption
var img = document.getElementById('myImg');
var modalImg = document.getElementById("img01");
var captionText = document.getElementById("caption");
img.onclick = function(){
modal.style.display = "block";
modalImg.src = this.src;
modalImg.alt = this.alt;
captionText.innerHTML = this.alt;
}
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
</script>
</div>
</div>
</div>
<?php } }?>
<!-- end of detail part -->
<?php
include_once($config['template']."footer.php");
?>
EDIT:
my website is http://telefonal.az/
In other page (as OP has mentioned) please make sure you have session_start(); function before you are using $_SESSION.
for example
<?php
if (session_status() == PHP_SESSION_NONE) {
session_start();
/*session is started if you don't write this line can't use $_Session global variable*/
}
echo $_SESSION['user_id'];

how to add pop banner on page load on wordpress site?

I have the ad code.
<div id='div-gpt-ad-1373299297661-0-oop'>
<script type='text/javascript'>
googletag.display('div-gpt-ad-1373299297661-0-oop');
</script>
</div>
where should I add this to pop up on page load.
I added this code on the header.php file, under the <body> tag.
but it shows on the top of header.it should be pop up in the middle of the page.
header.php
<body <?php body_class();?> itemscope="itemscope" itemtype="http://schema.org/WebPage">
<!-- 450x450 -->
<!-- Overylay Banner -->
<div id='div-gpt-ad-1373299297661-0-oop'>
<script type='text/javascript'>
googletag.display('div-gpt-ad-1373299297661-0-oop');
</script>
</div>
<?php
if(of_get_option('full_or_boxed_layout')!= 'full_image_option'){
if(of_get_option('background_body_option')== 'big_image'){?>
<img alt="full screen background image" src="<?php echo of_get_option('background_large_image');?>" id="full-screen-background-image" />
<?php }}?>
<div id="content_nav">
<div id="nav">
<?php $top_menu = array('theme_location' => 'Top_Menu', 'container' => '', 'menu_class' => 'menu-top-menu-sf', 'menu_id' => '', 'fallback_cb' => false); wp_nav_menu($top_menu);?>
<?php $main_menu = array('theme_location' => 'Main_Menu', 'container' => '', 'menu_class' => '', 'menu_id' => '', 'fallback_cb' => false, 'link_after'=>'<span class="border-menu"></span>'); wp_nav_menu($main_menu);?>
</div>
</div>
<?php if(of_get_option('full_or_boxed_layout') == 'box_image_option'){ if(of_get_option('background_option') == 'background_image'){?>
<div class="full-background"><img src="<?php echo of_get_option('background_large_image');?>" alt="" /></div>
<?php }}?>
<div id="sb-site" class="<?php if(of_get_option('full_or_boxed_layout') == 'full_image_option'){echo "body_wraper_full";}else{echo "body_wraper_box";}?>">
<div>
</div>
<!-- Start header -->
<header class="header-wraper">
<div class="header_top_wrapper">
<?php $main_top = array('theme_location' => 'Top_Menu', 'container' => '', 'menu_class' => 'sf-top-menu', 'menu_id' => 'menu-top', 'fallback_cb' => false);?>
<div class="row <?php if($main_top == "" || !of_get_option('disable_top_menu')==0){echo "no-top";}?>">
<div class="six columns header-top-left-bar">
<a class="open toggle-lef sb-toggle-left navbar-left" href="#nav">
<div class="navicon-line"></div>
<div class="navicon-line"></div>
<div class="navicon-line"></div>
</a>
<?php if(!of_get_option('disable_top_menu')==1){?>
<div class="mainmenu">
<?php wp_nav_menu($main_top);?>
<div class="clearfix"></div>
</div>
<?php }?>
</div>
<div class="six columns header-top-right-bar">
<?php if(!of_get_option('disable_top_search')==1){?>
<div id="search_block_top">
<form id="searchbox" action="<?php echo home_url(); ?>" method="GET" role="search">
<p>
<input type="text" id="search_query_top" name="s" class="search_query ac_input" value="" placeholder="<?php _e('Search here', 'jelly_text_main'); ?>">
<a class="button_search" href="javascript:document.getElementById('searchbox').submit();"></a>
</p>
</form>
<span>Search</span>
<div class="clearfix"></div>
</div>
<?php }?>
<?php if(!of_get_option('disable_top_header_date')==1){?>
<div class="clock">
<i class="fa fa-clock-o"></i>
<div id="Date">
<?php
/*setlocale(LC_TIME, "pt_BR");
$currDate = strftime("%e %B, %Y, %H:%M");
echo $currDate;*/
?>
<?php echo date('l j F Y'); //setlocale(LC_TIME, "de_DE"); echo strftime('%A %d %B %Y');?></div>
<ul>
<li id="hours"></li>
<li class="point">:</li>
<li id="min"></li>
<li class="point">:</li>
<li id="sec"></li>
</ul>
</div>
<?php }?>
<div class="clearfix"></div>
</div>
</div>
</div>
<div class="header_main_wrapper">
<div class="row">
<div class="<?php if (is_active_sidebar('banner-sidebar')) { echo'four columns header-top-left'; } else { echo'twelve columns logo-position';}?>">
<!-- begin logo -->
<a href="<?php echo home_url(); ?>">
<?php $logo = of_get_option('logo_uploader'); ?>
<?php if (!empty($logo)): ?>
<img src="<?php echo $logo; ?>" alt="<?php bloginfo('description'); ?>"/>
<?php else: ?>
<img src="<?php echo get_template_directory_uri(); ?>/img/logo.png" alt="<?php bloginfo('description'); ?>"/>
<?php endif; ?>
</a>
<!-- end logo -->
</div>
<?php if (is_active_sidebar('banner-sidebar')){ ?>
<div class="eight columns header-top-right">
<?php dynamic_sidebar('banner-sidebar');?>
</div>
<?php }?>
</div>
</div>
<!-- end header, logo, top ads -->
<!-- Start Main menu -->
so where is should I place the ad code?
is it possible to add the overlay banner via text widget? without editing the header.php??
to load something on page load, you need to add it to the <body> tag itself like this:
<body onLoad="callJSFunction()">
.
.
.
</body>
take a look at this tutorial :D

PHP - Wordpress post loop not showing

I'm having trouble with the Blog portion of my project I'm working on. I have made a new template and pointed the Blog page to that template but no posts show up on the page. I have also went under Reading > and changed the Posts Page to Blog, the whole page doesn't show up. Below is the code and a link:
http://www.hbaofwashingtoncounty.org/hbawc2014/blog/
<?php
/*
Template Name: Blog
*/
;?>
<?php get_header();?>
<div class="inner">
<!-- Content Section Start -->
<div class="contentsec-new twocol">
<!-- Top Header Start -->
<div class="topheader">
<div class="inner">
<!-- Logo Start -->
<div class="logo">
<a href="<?php echo home_url();?>">
<?php if($logo_img = $_extracoding->set_value('LOGO', get_template_directory_uri().'/images/logo.png', true)): ?>
<img src="<?php echo $logo_img;?>" alt="<?php bloginfo('name');?>" id="logo" />
<?php else:?>
<span class="logo"> </span>
<?php endif;?>
</a>
</div>
<!-- Logo End -->
<!-- Right Header Start -->
<div class="righthead">
<div class="topsec">
<!-- Service Time and Search Start -->
<!-- Service Time and Search End -->
<!-- Top Navigation Start -->
<div class="menuwrapper">
<?php $redirectTo = (is_home() || is_front_page()) ? home_url() : $_SERVER['REQUEST_URI'];?>
<?php if( ! is_user_logged_in()): ?>
<ul class="topnavi" style="float:right;">
<li><?php _e('Member Login', 'heavens_corner');?>
<!-- Login Bubble Start -->
<div id="loginbox"> <span class="logintop"> </span>
<div class="logincenter">
<h3 class="white bold upper"><?php _e('User Login', 'heavens_corner');?></h3>
<form action="<?php bloginfo('url');?>/wp-login.php" method="post" name="loginform" id="loginform">
<ul>
<li><h5 class="white"><?php _e('User Name', 'heavens_corner');?></h5></li>
<li><input name="log" type="text" class="bar" /></li>
<li><h5 class="white"><?php _e('Password', 'heavens_corner');?></h5></li>
<li><input name="pwd" type="password" class="bar" /><input type="hidden" value="<?php echo $redirectTo;?>" name="redirect_to" /></li>
<li><?php _e('Forget Password?', 'heavens_corner');?> </li>
<li class="nopading"><input type="submit" value="<?php _e('Sign in Now', 'heavens_corner');?>" class="button backcolr" /></li>
</ul>
</form>
</div>
<span class="loginbottom"> </span> </div>
<!-- Login Bubble End -->
</li>
</ul>
<?php else:?>
<ul class="topnavi" style="float:right;">
<li><?php _e('Logout', 'heavens_corner');?>
</ul>
<?php endif;?>
<?php wp_nav_menu(array('theme_location'=>'top-menu', 'container'=>false, 'menu_class'=>'topnavi')); //Top menu?>
<br />
<?php wp_nav_menu(array('theme_location'=>'main-menu', 'container'=>false, 'menu_class'=>'subnavi')); //Top menu?>
</div>
<!-- Top Navigation End -->
</div>
<ul class="boxed">
<?php get_template_part('modules/top_links');?>
<!-- Search Start -->
<li class="last">
<?php echo get_search_form(); //Search form ?>
</li>
<!-- Search End -->
</ul>
<div class="clear"></div>
<?php if($header_settings = get_option(THEME_PREFIX.'general_settings')):?>
<!--Header Short Text-->
<div class="watchlive">
<h3><?php echo character_limiter(kvalue($header_settings, 'header_text'), 50);?></h3>
</div>
<?php endif;?>
</div>
<!-- Right Header End -->
</div>
</div>
<!-- Bread Crumb Start -->
<div class="breadcrumb" style="margin-top:24px;">
<?php echo get_the_breadcrumb(); ?>
</div>
<!-- Bread Crumb End -->
<!-- Sub Page Banner Start -->
<div class="subbanner">
<?php fw_top_banner('category'); //Get big header image?>
</div>
<!-- Sub Page Banner End -->
<!-- Column 3 Start -->
<div class="col3 border-right left">
<!-- Blog Start -->
<div class="blog">
<h1 class="heading colr"><?php single_cat_title();?></h1>
<!-- Blog Post Start -->
<div class="post noborder nopading">
<?php while ( have_posts() ) : the_post(); ?>
<div class="post-date backcolr">
<span><?php echo get_the_date('j');?></span>
<span><?php echo get_the_date('M');?></span>
</div>
<div class="post-heading">
<h5><?php the_title(); ?></h5>
</div>
<div class="clear"></div>
<?php if($media = fw_post_video('w=667&h=369&showThumb=1&thumbSize=category-featured')):?>
<div class="post-thumb">
<?php echo $media;?>
</div>
<?php endif;?>
<div class="post-feat">
<ul>
<li class="authore"><?php _e('by,', 'heavens_corner');?> <?php the_author();?></li>
<li class="comments"><?php comments_number();?></li>
<?php if(has_tag()):?><li class="tags"><?php the_tags();?></li><?php endif;?>
</ul>
</div>
<div class="clear"></div>
<div class="post-desc">
<p><?php echo (function_exists('the_exerpt')) ? get_the_exerpt() : character_limiter(get_the_content(),450,'',true);?></p>
<?php _e('Keep Reading', 'heavens_corner');?>
</div>
<?php endwhile; ?>
</div>
<!-- Blog Post End -->
<!-- Pagination Start -->
<?php if($wp_query->max_num_pages > 1):?>
<div class="paginations">
<ul><?php fw_blog_pagination(); ?></ul>
</div>
<?php endif;?>
<!-- Pagination End -->
</div>
<!-- Blog End -->
</div>
<!-- Column 3 End -->
<!-- Column 1 Start -->
<div class="col1 right">
<!-- Widget Start -->
<?php fw_dynamic_sidebars('category', get_query_var('cat'));?>
<!-- Widget End -->
</div>
<!-- Column 1 End -->
</div>
<!-- Content Section End -->
</div>
<div class="clear"></div>
<!-- Footer Start -->
<?php get_footer(); ?>

Php file renders blank after being converted with Haml (Ruby)!

In order to test if the converted index.haml would work on with my wamp and localhost i did the following:
First, I renamed my index.php into index.html
Then, I typed html2haml index.html index.haml in the command line
Then, I typed haml index.haml indexnew.html in the command line
I renamed indexnew.html to indexnew.php
I tested it: localhost/projects/cross-browser/base0.9/indexnew.php
but the indexnew.php was rendered blank even if the code inside is ok:
Original Php (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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<title>Alex Chen - Web Development, Graphic 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($lang_file=='lang.zh-tw.php' || $lang_file=='lang.zh-cn.php') {echo '<link rel="stylesheet" type="text/css" href="styles/chinese.css" />';} ?>
<script type="text/javascript" src="scripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="scripts/jquery.validate.js"></script>
<script type="text/javascript" src="fancybox/jquery.fancybox-1.3.1.pack.js"></script>
<script type="text/javascript" src="scripts/jquery.scrollTo-min.js"></script>
<script type="text/javascript" src="scripts/jquery.localscroll-min.js"></script>
<script type="text/javascript" src="scripts/custom.js"></script>
<?php if($lang_file=='lang.en.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-en.js"></script>';} ?>
<?php if($lang_file=='lang.es.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-es.js"></script>';} ?>
<?php if($lang_file=='lang.zh-tw.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-zh-tw.js"></script>';} ?>
<?php if($lang_file=='lang.zh-cn.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-zh-cn.js"></script>';} ?>
</head>
<body id="home">
<div id="header">
<div class="container">
<div id="banner">
<ul id="lang">
<li <?php if($lang_file=='lang.en.php') {echo 'class="current"';} ?>>ENGLISH</li>
<li <?php if($lang_file=='lang.es.php') {echo 'class="current"';} ?>><?php echo l('nav_a0'); ?></li>
<li <?php if($lang_file=='lang.zh-tw.php') {echo 'class="current"';} ?>><?php echo l('nav_a1'); ?></li>
<li <?php if($lang_file=='lang.zh-cn.php') {echo 'class="current"';} ?>><?php echo l('nav_a2'); ?></li>
</ul>
<div id="logo">
<h1><a>ALEXCHEN</a></h1>
</div>
<div id="logo2">
<ul id="nav">
<li><?php echo l('nav1'); ?></li>
<li><?php echo l('nav2'); ?></li>
</ul>
</div>
<div id="logo3">
</div>
</div><!-- #header-bottom -->
</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>
<div class="pusher">
<h3><?php echo l('showcase1_h3'); ?></h3>
<p><?php echo l('showcase1_p'); ?></p>
<div class="pic">
<a id="showcase1" href="#inline1"><img src="images/showcase1t.png"/></a>
<div id="inline1">
<img src="images/showcase1.png"/>
studyatbest.com
</div>
</div>
</div>
<div class="pusher">
<h3><?php echo l('showcase2_h3'); ?></h3>
<p><?php echo l('showcase2_p'); ?></p>
<div class="pic">
<a id="showcase2" href="#inline2"><img src="images/showcase2t.png"/></a>
<div id="inline2">
<img src="images/showcase2.png"/>
spacestudios.com
</div>
</div>
</div><!-- .pushed -->
<div class="pusher">
<h3><?php echo l('showcase3_h3'); ?></h3>
<p><?php echo l('showcase3_p'); ?></p>
<div class="pic">
<a id="showcase3" href="#inline3"><img src="images/showcase3t.png"/></a>
<div id="inline3">
<img src="images/showcase3.png"/>
alexchen.com
</div>
</div>
</div>
<div class="pusher">
<h3><?php echo l('showcase4_h3'); ?></h3>
<p><?php echo l('showcase4_p'); ?></p>
<div class="pic">
<a id="showcase4" href="#inline4"><img src="images/showcase4t.png"/></a>
<div id="inline4">
<img src="images/showcase4.png"/>
mattsai.com
</div>
</div>
</div>
<div class="pusher">
<h3><?php echo l('showcase5_h3'); ?></h3>
<p><?php echo l('showcase5_p'); ?></p>
<div class="pic">
<a id="showcase5" href="#inline5"><img src="images/showcase5t.png"/></a>
<div id="inline5">
<img src="images/showcase5.png"/>
mattsai.com
</div>
</div>
</div><!-- .pusher -->
<div class="pusher">
<h3><?php echo l('showcase6_h3'); ?></h3>
<p><?php echo l('showcase6_p'); ?></p>
<div class="pic">
<a id="showcase6" href="#inline6"><img src="images/showcase6t.png"/></a>
<div id="inline6">
<img src="images/showcase6.png"/>
mattsai.com
</div>
</div>
</div>
<div class="pusher">
<h3><?php echo l('showcase8_h3'); ?></h3>
<p><?php echo l('showcase8_p'); ?></p>
<div class="pic">
<a id="showcase8" href="#inline8"><img src="images/showcase8t.png"/></a>
<div id="inline8">
<img src="images/showcase8.png"/>
mattsai.com
</div>
</div>
</div><!-- .pusher -->
</div><!-- .showcase -->
</div><!-- .container -->
</div><!-- #work -->
<div id="footer">
<div class="container">
<div id="footer-top">
<div id="about">
<h3><?php echo l('about_h3'); ?></h3>
<p><?php echo l('about_p'); ?></p>
</div>
<div id="info">
<h3><?php echo l('info_h3'); ?></h3>
<ul>
<li id="tel"><?php echo l('_info_li2'); ?><p>Tel:</p> 0918051170</li>
<li id="gmail"><?php echo l('_info_li3'); ?><p></p>alexchen.net#gmail.com</li>
<li id="facebook"><?php echo l('_info_li4'); ?> 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">
<p>Copyright © 2010 Alex Chen. All Rights Reserved. Hosted on Zymic. Contact form hosted on Email Me Form.<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></p>
</div>
</div><!-- .container -->
</div><!-- #footer -->
<script type="text/javascript" src="scripts/google-analytics.js"></script>
<script type="text/javascript" src="scripts/page-tracker.js"></script>
</body>
</html>
Converted Php (indexnew.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 content='text/html; charset=utf-8' http-equiv='Content-Type' />
<meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible' />
<title>Alex Chen - Web Development, Graphic Design, and Translation</title>
<link href='styles/reset.css' rel='stylesheet' type='text/css' />
<link href='styles/global.css' rel='stylesheet' type='text/css' />
<link href='fancybox/jquery.fancybox-1.3.1.css' rel='stylesheet' type='text/css' />
<?php if($lang_file=='lang.zh-tw.php' || $lang_file=='lang.zh-cn.php') {echo '<link rel="stylesheet" type="text/css" href="styles/chinese.css" ?>
';} ?>
<script src='scripts/jquery-1.3.2.min.js' type='text/javascript'></script>
<script src='scripts/jquery.validate.js' type='text/javascript'></script>
<script src='fancybox/jquery.fancybox-1.3.1.pack.js' type='text/javascript'></script>
<script src='scripts/jquery.scrollTo-min.js' type='text/javascript'></script>
<script src='scripts/jquery.localscroll-min.js' type='text/javascript'></script>
<script src='scripts/custom.js' type='text/javascript'></script>
<?php if($lang_file=='lang.en.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-en.js?>
';} ?>
<?php if($lang_file=='lang.es.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-es.js?>
';} ?>
<?php if($lang_file=='lang.zh-tw.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-zh-tw.js?>
';} ?>
<?php if($lang_file=='lang.zh-cn.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-zh-cn.js?>
';} ?>
</head>
<body id='home'>
<div id='header'>
<div class='container'>
<div id='banner'>
<ul id='lang'>
<li
<?php if($lang_file=='lang.en.php') {echo 'class="current"';} ?>
>
</ul>
<a href='index.php?lang=en'>ENGLISH</a>
<li
<?php if($lang_file=='lang.es.php') {echo 'class="current"';} ?>
>
<a href='index.php?lang=es'>
<?php echo l('nav_a0'); ?>
</a>
<li
<?php if($lang_file=='lang.zh-tw.php') {echo 'class="current"';} ?>
>
<a href='index.php?lang=zh-tw'>
<?php echo l('nav_a1'); ?>
</a>
<li
<?php if($lang_file=='lang.zh-cn.php') {echo 'class="current"';} ?>
>
<a href='index.php?lang=zh-cn'>
<?php echo l('nav_a2'); ?>
</a>
<div id='logo'>
<h1>
<a>ALEXCHEN</a>
</h1>
</div>
<div id='logo2'>
<ul id='nav'>
<li>
<a href='#content'>
<?php echo l('nav1'); ?>
</a>
</li>
<li>
<a href='#contact'>
<?php echo l('nav2'); ?>
</a>
</li>
</ul>
</div>
<div id='logo3'></div>
</div>
<!-- #header-bottom -->
</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>
<div class='pusher'>
<h3>
<?php echo l('showcase1_h3'); ?>
</h3>
<p>
<?php echo l('showcase1_p'); ?>
</p>
<div class='pic'>
<a href='#inline1' id='showcase1'>
<img src='images/showcase1t.png' />
</a>
<div id='inline1'>
<img src='images/showcase1.png' />
<a href='http://studyatbest.com'>studyatbest.com</a>
</div>
</div>
</div>
<div class='pusher'>
<h3>
<?php echo l('showcase2_h3'); ?>
</h3>
<p>
<?php echo l('showcase2_p'); ?>
</p>
<div class='pic'>
<a href='#inline2' id='showcase2'>
<img src='images/showcase2t.png' />
</a>
<div id='inline2'>
<img src='images/showcase2.png' />
<a href='http://studyatbes.com'>spacestudios.com</a>
</div>
</div>
</div>
<!-- .pushed -->
<div class='pusher'>
<h3>
<?php echo l('showcase3_h3'); ?>
</h3>
<p>
<?php echo l('showcase3_p'); ?>
</p>
<div class='pic'>
<a href='#inline3' id='showcase3'>
<img src='images/showcase3t.png' />
</a>
<div id='inline3'>
<img src='images/showcase3.png' />
<a href='http://studyatbes.com'>alexchen.com</a>
</div>
</div>
</div>
<div class='pusher'>
<h3>
<?php echo l('showcase4_h3'); ?>
</h3>
<p>
<?php echo l('showcase4_p'); ?>
</p>
<div class='pic'>
<a href='#inline4' id='showcase4'>
<img src='images/showcase4t.png' />
</a>
<div id='inline4'>
<img src='images/showcase4.png' />
<a href='http://studyatbes.com'>mattsai.com</a>
</div>
</div>
</div>
<div class='pusher'>
<h3>
<?php echo l('showcase5_h3'); ?>
</h3>
<p>
<?php echo l('showcase5_p'); ?>
</p>
<div class='pic'>
<a href='#inline5' id='showcase5'>
<img src='images/showcase5t.png' />
</a>
<div id='inline5'>
<img src='images/showcase5.png' />
<a href='http://studyatbes.com'>mattsai.com</a>
</div>
</div>
</div>
<!-- .pusher -->
<div class='pusher'>
<h3>
<?php echo l('showcase6_h3'); ?>
</h3>
<p>
<?php echo l('showcase6_p'); ?>
</p>
<div class='pic'>
<a href='#inline6' id='showcase6'>
<img src='images/showcase6t.png' />
</a>
<div id='inline6'>
<img src='images/showcase6.png' />
<a href='http://studyatbes.com'>mattsai.com</a>
</div>
</div>
</div>
<div class='pusher'>
<h3>
<?php echo l('showcase8_h3'); ?>
</h3>
<p>
<?php echo l('showcase8_p'); ?>
</p>
<div class='pic'>
<a href='#inline8' id='showcase8'>
<img src='images/showcase8t.png' />
</a>
<div id='inline8'>
<img src='images/showcase8.png' />
<a href='http://studyatbes.com'>mattsai.com</a>
</div>
</div>
</div>
<!-- .pusher -->
</div>
<!-- .showcase -->
</div>
<!-- .container -->
</div>
<!-- #work -->
<div id='footer'>
<div class='container'>
<div id='footer-top'>
<div id='about'>
<h3>
<?php echo l('about_h3'); ?>
</h3>
<p>
<?php echo l('about_p'); ?>
</p>
</div>
<div id='info'>
<h3>
<?php echo l('info_h3'); ?>
</h3>
<ul>
<li id='tel'>
<?php echo l('_info_li2'); ?>
<p>Tel:</p>
0918051170
</li>
<li id='gmail'>
<?php echo l('_info_li3'); ?>
<p></p>
<a href='mailto:janoochen#gmail.com'>alexchen.net#gmail.com</a>
</li>
<li id='facebook'>
<?php echo l('_info_li4'); ?>
<a href='http://www.facebook.com/weedd.chen'>facebook</a>
</li>
</ul>
</div>
<div id='contact'>
<h3>
<?php echo l('contact_h3'); ?>
</h3>
<p>
<?php echo l('_contact_p'); ?>
</p>
<form action='http://www.emailmeform.com/fid.php?formid=254816' id='sendmail' method='post'>
<label for='name'>
<?php echo l('form_label1'); ?>
</label>
<input id='name' name='FieldData0' type='text' />
<label for='email'>
<?php echo l('form_label2'); ?>
</label>
<input id='email' name='FieldData1' type='text' />
<label for='message'>
<?php echo l('form_label3'); ?>
</label>
<textarea id='message' name='FieldData2' type='text'></textarea>
<input id='button' type='submit' value="<?php echo l('submit'); ?>" />
</form>
</div>
</div>
<!-- #footer-top -->
<div id='footer-bottom'>
<p>
Copyright © 2010 Alex Chen. All Rights Reserved. Hosted on
<a href='http://www.zymic.com'>Zymic</a>.
Contact form hosted on
<a href='http://www.emailmeform.com'>Email Me Form</a>.
<a href='http://www.freedomain.co.nr/cheap_web_hosting.php' id='nr' target='_blank'>
<img alt='Cheap Web Hosting Providers' border='0' height='31' src='http://ruarmza.4u.com.ru/ch.gif' width='88' />
</a>
</p>
</div>
</div>
<!-- .container -->
</div>
<!-- #footer -->
<script src='scripts/google-analytics.js' type='text/javascript'></script>
<script src='scripts/page-tracker.js' type='text/javascript'></script>
</body>
</html>
Any suggestions?
I'd suggest you try a PHP-specific version of HAML, like PHPHaml or pHAML. The Ruby HAML interpreter is specifically expecting Ruby code, and will likely screw up your PHP syntax.
Having said that, I have used Chaml with some degree of success. HAML for PHP is at a rather experimental stage, and you will come across bugs. If you're writing more HTML than PHP though, it can be a great help.

Categories