since i am new in facebook graph API ,but i know the basics .Now i need help from you all that how to read User Wall Post and others who posted on wall of any user, with read_stream. But i dnt know how to call. I tried some way but i was able to read jus name and basic info. I need help in reading objects. Please help me!!!
<?php header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND
CNT"');?>
<?php
define('FACEBOOK_APP_ID', 'xxxxx');
define('FACEBOOK_SECRET', 'xxxxxxxxx');
function get_facebook_cookie($app_id, $application_secret) {
$args = array();
print_r($_COOKIE);
parse_str(trim($_COOKIE['fbs_' . $app_id], '\\"'), $args);
ksort($args);
$payload = '';
foreach ($args as $key => $value) {
if ($key != 'sig') {
$payload .= $key . '=' . $value;
}
}
if (md5($payload . $application_secret) != $args['sig']) {
return null;
}
return $args;
}
$cookie = get_facebook_cookie($app_id, $application_secret);
echo 'The ID of the current user is ' . $cookie['uid'];
?>
<html>
<body>
<?php if ($cookie) { ?>
Your user ID is <?= $cookie['uid'] ?>
<?php } else { ?>
<fb:login-button>Install Example App</fb:login-button>
<?php } ?>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({appId: 'xxxxxx', xfbml: true,cookie:true});
FB.Event.subscribe('auth.login', function(response) {
// Reload the application in the logged-in state
window.top.location = 'http://apps.facebook.com/fbvantivirus';
});
</script>
<div style="display:none">
</body>
</html>
I have mention the entire code.please do help me.am struggling from last week..all try in vain.Thanks in advance. :)
Welcome in the Cookie Hell. You need a P3P compact policy.
In the iframe, first line:
<?php header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');?>
Related
I wish to add a review function in my old e-commerce website. However, the "write a review" button does not seems to be working, it will not bring me to a review page; seems like a broken link. I followed the opencart documentation review but there is just this bug.
I am using opencart Version 2.0.3.1.
I think, there is something wrong with review tab on your product page.
Due to may OpenCart experience. The best code for this "Write a review" button is:
Write a review
It should work better, then a standard one.
If this wouldn't help - please, write a link to your website and i'll correct the answer.
UPDATED
No your product.tpl find <div id="tab-review" class="tab-content">. It should be like
<?php if ($review_status) { ?>
<div id="tab-review" class="tab-content">
<div id="review"></div>
On the bottom of this file you can look for script
<script type="text/javascript"><!--
$('#review .pagination a').live('click', function() {
$('#review').fadeOut('slow');
$('#review').load(this.href);
$('#review').fadeIn('slow');
return false;
});
$('#review').load('index.php?route=product/product/review&product_id=<?php echo $product_id; ?>');
$('#button-review').bind('click', function() {
$.ajax({
url: 'index.php?route=product/product/write&product_id=<?php echo $product_id; ?>',
type: 'post',
dataType: 'json',
data: 'name=' + encodeURIComponent($('input[name=\'name\']').val()) + '&text=' + encodeURIComponent($('textarea[name=\'text\']').val()) + '&rating=' + encodeURIComponent($('input[name=\'rating\']:checked').val() ? $('input[name=\'rating\']:checked').val() : '') + '&captcha=' + encodeURIComponent($('input[name=\'captcha\']').val()),
beforeSend: function() {
$('.success, .warning').remove();
$('#button-review').attr('disabled', true);
$('#review-title').after('<div class="attention"><img src="catalog/view/theme/default/image/loading.gif" alt="" /> <?php echo $text_wait; ?></div>');
},
complete: function() {
$('#button-review').attr('disabled', false);
$('.attention').remove();
},
success: function(data) {
if (data['error']) {
$('#review-title').after('<div class="warning">' + data['error'] + '</div>');
}
if (data['success']) {
$('#review-title').after('<div class="success">' + data['success'] + '</div>');
$('input[name=\'name\']').val('');
$('textarea[name=\'text\']').val('');
$('input[name=\'rating\']:checked').attr('checked', '');
$('input[name=\'captcha\']').val('');
}
}
});
});
//--></script>
If there is no such script - add it.
Then, in the same folder as product.tpl find review.tpl with code
<?php if ($reviews) { ?>
<?php foreach ($reviews as $review) { ?>
<div class="review-list">
<div class="author"><b><?php echo $review['author']; ?></b> <?php echo $text_on; ?> <?php echo $review['date_added']; ?></div>
<div class="rating"><img src="catalog/view/theme/default/image/stars-<?php echo $review['rating'] . '.png'; ?>" alt="<?php echo $review['reviews']; ?>" /></div>
<div class="text"><?php echo $review['text']; ?></div>
</div>
<?php } ?>
<div class="pagination"><?php echo $pagination; ?></div>
<?php } else { ?>
<div class="content"><?php echo $text_no_reviews; ?></div>
<?php } ?>
If there is no such file - add id.
If all the conditions are OK, but it still not working - here a screenshot of your console errors.
UPDATED 2
check your config.php in foot folder ans set both HTTP_SERVER and HTTPS_SERVER to the same protocol you are using, like
// HTTP
define('HTTP_SERVER', 'https://yoursite.com/');
// HTTPS
define('HTTPS_SERVER', 'https://yoursite.com/');
Make sure that you don't have any http->https redirects in your .htaccess.
Thanks for anyone who helps or points me in the right direction.
I want to show Order Status in opencart user (My Account) page. It will show status by status ID. My Pending Status ID:1 and I want to show only Pending Status. Other status will not appear.
<?php echo $order_statuses['order_status_id']; ?>
I put this at account.tpl but result error. Please help me.
Maybe need to modify
*english/account/account.php
controller/account/account.php
template/module/account.tpl*
My Open cart Version 1.5.6.3 with custom Theme.
In account.php you have add this.
$this->load->model('account/order');
$results = $this->model_account_order->getOrders(0, 5);
foreach ($results as $result) {
$product_total = $this->model_account_order->getTotalOrderProductsByOrderId($result['order_id']);
$voucher_total = $this->model_account_order->getTotalOrderVouchersByOrderId($result['order_id']);
$this->data['orders'][] = array(
'order_id' => $result['order_id'],
'name' => $result['firstname'] . ' ' . $result['lastname'],
'status' => $result['status'],
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'products' => ($product_total + $voucher_total),
'total' => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value']),
'href' => $this->url->link('account/order/info', 'order_id=' . $result['order_id'], 'SSL'),
'reorder' => $this->url->link('account/order', 'order_id=' . $result['order_id'], 'SSL')
);
}
In account.tpl add this code
<div id="resent_order" class="recent_order">
<a style="float:right; margin-bottom:15px;" href="<?php echo $manage_order; ?>" class="button">Manage your orders</a><h4>Recent Order</h4>
<ul style="clear:both;">
<?php if( isset($orders) && count($orders > 0 ) ){
foreach ($orders as $order) { ?>
<li>
<div><strong>Order:#</strong><?php echo $order['order_id']; ?></div>
<div><strong>Date:</strong> <?php echo $order['date_added']; ?></div>
<div><strong>Amount:</strong> <?php echo $order['total']; ?></div>
<div><strong>Status:</strong> <?php echo $order['status']; ?></div>
<div class="editPan"><a class="" title="Edit" href="<?php echo $order['href']; ?>">Edit</a></div>
</li>
<?php } ?>
<?php }else{?> <li>You have no recent orders.</li><?php } ?>
</ul>
</div>
Currently my Opencart site only lets me 'Add to Cart' on the categories page, however if a product has options like 'colour' etc I want it to say 'View Product' instead.
Does anyone know how this can be achieved? I have tried editing the category.php controller to check if a product has options but cannot seem to get it working properly.
Thanks.
Update
So far I have added:
$options = $this->model_catalog_product->getProductOptions($result['product_id']);
Above this array $this->data['products'] = array(); in catalog>controller>product>category.php
This was my attempt to check if a product has options or not. Then I added in catalog>view>theme>mytheme>template>product>category.tpl
<?php if ($product['options']) { ?>
<a href="<?php echo $product['href']; ?>" class="button" />View Product</a>
<?php } else { // EO CATALOGUE MODE ?>
<input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" />
<?php } ?>
But it is not quite cutting the mustard.
You need to add the options to the $products array which is what you are checking in category.tpl:
Look for:
$this->data['products'][] = array(
'product_id' => $result['product_id'],
and add the options as an index to each product array
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'options' => $this->model_catalog_product->getProductOptions($result['product_id']),
I just start with Opencart. I need to have list of brands, like llist of catgories. I try so:
<div class="box">
<div class="box-heading"><?php echo "По брендам" ?></div>
<div class="box-content">
<ul class="box-category">
<?php foreach ($manufacturers as $manufacturer) { ?>
<li>
<?php if ($manufacturer['manufacturer_id'] == $manufacturer_id) { ?>
<?php echo $manufacturer['name']; ?>
<?php } else { ?>
<?php echo $manufacturer['name']; ?>
<?php } ?>
<?php if ($manufacturer['children']) { ?>
<ul>
<?php foreach ($manufacturer['children'] as $child) { ?>
<li>
<?php if ($child['manufacturer_id'] == $child_id) { ?>
- <?php echo $child['name']; ?>
<?php } else { ?>
- <?php echo $child['name']; ?>
<?php } ?>
</li>
<?php } ?>
</ul>
<?php } ?>
</li>
<?php } ?>
</ul>
</div>
</div>
I add this code in default/template/module/category.tpl file.
I get this error: Notice: Undefined variable: manufacturers in....
How should I do this???
Thanks.
category.tpl is the template for the category controller. Its purpose is to show categories. Try to direct your browser to the http://your.site/index.php?route=product/manufacturer and you will get list of manufacturers. The template is /catalog/view/theme/default/template/product/manufacturer_list.tpl.
Your error is a result of one simple thing: the $manufacturers variable is not defined in ControllerModuleCategory controller (aka category.php). If you want use a variable in a template, you must define it in a relevant controller.
In order to obtain list of manufacturers exactly in the /catalog/view/theme/default/template/module/category.tpl (even if it isn't the purpose of this module), you need be done with few things:
1) In the /catalog/model/catalog/manufacturer.php file (model ModelCatalogManufacturer) add function (this function will help you to obtain the list of manufacturers from the database):
public function getManufacturerByCategory($category_id) {
$query = $this->db->query("SELECT m.*
FROM " . DB_PREFIX . "product p
RIGHT JOIN " . DB_PREFIX . "product_to_category p2c ON
p.product_id = p2c.product_id
LEFT JOIN " . DB_PREFIX . "manufacturer m ON
p.manufacturer_id = m.manufacturer_id
WHERE
p2c.category_id = " . (int)$category_id . " AND
m.manufacturer_id IS NOT NULL
GROUP BY m.manufacturer_id");
return $query->rows;
}
2) In the /catalog/controller/module/category.php file (aka ControllerModuleCategory controller), prior to if (file_exists(DIR_TEMPLATE . $this->config->get('confi... insert the code:
if (isset($this->request->get['path'])) {
$category_id = array_pop($parts);
$this->load->model('catalog/manufacturer');
$this->data['manufacturers'] = $this->model_catalog_manufacturer->getManufacturerByCategory($category_id);
} else {
$this->data['manufacturers'] = array();
}
(Keep in mind $this->data['manufacturers'] from the controller will be available in the template as $manufacturers. $this->data['categories'] will be $categories, $this->data['another_var'] will be $another_var and so on.)
And since the moment you can use your foreach ($manufacturers as $manufacturer) in the category module template (the place where you did try the foreach, when you've received "Undefined variable" error) in order to output list of manufacturers which are applied to products from current category.
Best way is create another module, "manufacturer" module, instead of illegitimate using of category module. But I'm not sure that right now you are ready for this challenge.
BTW, I'm all for shadyyx's link to the Jay Gilford's guide. It is awesome quick start guide for beginners.
I have light solution:
Just add code in Controller:category.php:
$this->load->model('catalog/manufacturer');
$this->data['mans'] = $this->data['manufacturers'] =
$this->model_catalog_manufacturer->getManufacturers();
And View: category.tpl:
<?php
foreach($mans as $mans_value)
{
var_dump($mans_value);
}
?>
I have a simple component following the hello world tutorial for the most part, and everything works except i've added a publish / unpublish icons to the toolbar and to the list itself (the small green / red circles).
The toolbar icons work and they can change the state no problem, but the small icons do not, here is the code I have:
view.html.php:
protected function addToolBar()
{
JToolBarHelper::title(JText::_('COM_MADS_MANAGER_OBJECTS'));
JToolBarHelper::publishList($task = 'objects.publish', $alt = 'Publish');
JToolBarHelper::unpublishList($task = 'objects.unpublish', $alt = 'Unpublish');
JToolBarHelper::deleteListX('', 'objects.delete');
JToolBarHelper::editListX('object.edit');
JToolBarHelper::addNewX('object.add');
}
tmpl > body:
<?php
// No direct access to this file
defined('_JEXEC') or die;
?>
<?php foreach($this->items as $i => $item): ?>
<tr class="row<?php echo $i % 2; ?>">
<td><?php echo $item->id; ?></td>
<td><?php echo JHtml::_('grid.id', $i, $item->id); ?></td>
<td><?php echo $item->title; ?></td>
<td><?php echo $item->description; ?></td>
<td align="center"><?php $published = JHTML::_('grid.published', $item, $i); echo $published;?></td>
</tr>
<?php endforeach; ?>
I am using the built in publish / unpublish function and did not create one of my own.
Tables:
<?php
// No direct access to this file
defined('_JEXEC') or die;
jimport('joomla.database.table');
class MAdsTableObjects extends JTable
{
var $id = null;
var $title = null;
var $description = null;
var $published = 0;
function __construct(&$db)
{
parent::__construct('#__mads_objects', 'id', $db);
}
}
?>
I figured it out after A LOT OF FREKIN HEADACHE and wasted time, it should be:
<?php echo JHtml::_('jgrid.published', $item->published, $i, 'objects.',true); ?>
where objects. is the name of my view / controller / model for the listing.
I think you should have a state field in the db, to store the status
state tinyint(3)
Than try using:
echo JHtml::_('grid.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder);