Joomla 1.5. How to add Like / Dislike button on videos / images? - image

I'm useing Joomla 1.5 AllVideoShare (Version 1.2.4) extension.
QUESTION PART 1
I want to ask you how to make like button on videos thumbs/images? For example if user likes video clip or image he can click like button and It counts how many users like It. It can be simple like button or facebook button if possible. Also maybe possible to make Like / Dislike buttons (If user don't like this video/image he can dislike It)
Example where I want to place:
http://img689.imageshack.us/img689/268/likecp.png
This is my part of code where videos are publishing:
<?php if ($this->params->get('show_'.$header, 1)) : ?>
<h2> <?php echo $this->escape($this->params->get($header)); ?> </h2>
<?php endif; ?>
<div id="avs_gallery2<?php echo $this->escape($this->params->get('pageclass_sfx')); ?>">
<?php
if(!count($videos)) echo JText::_('ITEM_NOT_FOUND');
for ($i=0, $n=count($videos); $i < $n; $i++) {
$clear = '';
if($column >= $this->cols) {
$clear = '<div style="clear:both;"></div>';
$column = 0;
$row++;
}
$column++;
echo $clear;
?>
<span class="name"><?php echo $categories[$i]->name; ?></span>
<div id="testas" class="avs_thumb" style="width:190px;" onclick='javascript:location.href="<?php echo JRoute::_($link.$videos[$i]->slug.$qs); ?>"'>
<img class="arrow" src="<?php echo JURI::root(); ?>components/com_allvideoshare/assets/play.gif" border="0" style="margin-left:80px; margin-top:47px;" />
<img class="image" src="<?php echo $videos[$i]->thumb; ?>" width="190; " height="120;" title="<?php echo JText::_('CLICK_TO_VIEW') . ' : ' . $videos[$i]->title; ?>" border="0" />
<span class="title"><FONT COLOR="#000000"><?php echo $videos[$i]->title; ?></font></span>
<span class="views"><FONT COLOR="#000000"><?php echo JText::_('Peržiūros'); ?> : <strong><?php echo $videos[$i]->views*2+1; ?></strong></font></span>
<div class="avs_category_label"><?php echo JText::_('Kategorija'); ?> : <strong><?php echo $videos[$i]->category; ?></strong></div>
</div>
<?php } ?>
QUESTION PART 2
After I add Like / Dislike buttons will be possible to sort them by "Most popular" (Which video have most likes) or there are so hard work?
Example: http://www.anekdotai.lt/
QUESTION PART 3
In the same place as Like / Dislike button I want to put Facebook share button. I have script which works, but I can't succesfully add It to this place.
FB Share script:
<?php
defined('_JEXEC') or die('Restricted access');
$linkTxt = $params->get( 'linkTxt', '' );
$linkColor = $params->get( 'linkColor', '' );
$linkHColor = $params->get( 'linkHColor', '' );
$theUrl = $params->get( 'theUrl', '1' );
$wholeUrl = "location.href.substring(0,location.href.lastIndexOf('/'))";
$currentUrl = "location.href";
?>
<script>function fbs_click() {u=<?php if($params->get('theUrl', 1))
{
echo $currentUrl;
}
else{
echo $wholeUrl;
} ?>;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script><style> html .fb_share_button { display: -moz-inline-block; display:inline-block; padding:1px 1px 1px 20px; height:17px; color:#<?php echo $linkColor ?>; background:url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat left; } html .fb_share_button:hover { color:#<?php echo $linkHColor ?>; background:url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat left; text-decoration:none; } </style> <a rel="nofollow" href="http://www.facebook.com/share.php?u=<url>" class="fb_share_button" onclick="return fbs_click()" target="_blank" style="text-decoration:none;"><?php echo $linkTxt; ?></a>
If I put It to Video publishing code I get error:
Fatal error: Call to a member function get() on a non-object in ..../juokoera.lt/public_html/components/com_allvideoshare/views/videos/tmpl/default.php on line 26
Thank you for answers.

Try adding the following code which will define the $params variable:
$params = JComponentHelper::getParams( 'com_yourcomponent' );

Related

Magetno how add checkbox in contact form?

I must add checkbox in Contact form in Magetno (Magento wer. 1.8.1), I searching tutorials on Google but I found solution ... It is easy way to do this ?
Many Thanks
Wojtek
why you don't use the checkout agreements: Just fetch the agreements in file \app\design\frontend\PACKAGE\TEMPLATE\template\contacts\form.phtml by
if (Mage::getStoreConfigFlag('checkout/options/enable_agreements')) {
$agreements = Mage::getModel('checkout/agreement')->getCollection()
->addStoreFilter(Mage::app()->getStore()->getId())
->addFieldToFilter('is_active', 1);
}
and print out some or all of them like
if ($agreements) {
foreach ($agreements as $_a):
// ID 5 = Datenschutz-Agreement deutsch, ID 6 = Alter-18-Agreement englisch, ID 7 = Datenschutz-Agreement deutsch, ID 8 = Alter-18-Agreement englisch
if ($_a->getId() >= 7 && $_a->getId() <= 8) {
?>
<li>
<div class="checkout-agreements">
<div class="agreement-content"<?php echo ($_a->getContentHeight() ? ' style="height:' . $_a->getContentHeight() . '"' : '')?>>
<?php if ($_a->getIsHtml()):?>
<?php echo $_a->getContent() ?>
<?php else:?>
<?php echo nl2br($this->escapeHtml($_a->getContent())) ?>
<?php endif; ?>
</div>
<p class="agree">
<input type="checkbox" id="agreement-<?php echo $_a->getId()?>" name="agreement[<?php echo $_a->getId()?>]" value="1" title="<?php echo $this->escapeHtml($_a->getCheckboxText()) ?>" class="required-entry checkbox" /><label for="agreement-<?php echo $_a->getId()?>"><?php echo $_a->getIsHtml() ? $_a->getCheckboxText() : $this->escapeHtml($_a->getCheckboxText()) ?></label>
</p>
</div>
</li>
<?php
}
endforeach;
}
That's all!
If there is someone German here: There you will get the full explanation in German!
Best regards
Bastian

Display discount percentage in Magento Category View

I've been trying to display the discount % for each product in the category listing without having to install an extension.
Any ideas on how to do this?
After searching through several tutorials, I found a way to do it:
Open app/design/frontend/base/default/template/catalog/product/price.phtml
Locate ""
Above that line, add:
<?php if($_finalPrice < $_price): ?>
<?php $_Percent = 100 - round(($_finalPrice / $_price)*100); ?>
<p class="special-price">
<span class="price" style="width: 50px; height; 50px; height: 50px;border-radius: 50%; background: red; color: white;position: relative;display: block;float: right;margin-top: -100px;text-align: center;/* padding: 5px; */line-height: 50px; font-weight: 800">ca
<?php echo $_Percent; ?>%
</span>
</p>
<?php endif; ?>
That's it. A few suggestions though:
Instead of modifying base/default files, create your own versions in a subtheme.
Use proper CSS in a stylesheet instead of inline.
Open :
app/design/frontend/base/default/template/catalog/product/price.phtml
or
app/design/frontend/yourtheme/default/template/catalog/product/price.phtml
Locate : <?php endif; /* if ($_finalPrice == $_price): */ ?>
Above that line add:
<?php // Display Discount percents start ?>
<?php if($_finalPrice < $_price): ?>
<?php $_savingPercent = 100 - round(($_finalPrice / $_price)*100); ?>
<p class="special-price yoursaving">
<span class="label"><?php echo $this->__('Discount:') ?></span>
<span class="price">
<?php echo $_savingPercent; ?>%
</span>
</p>
<?php endif; ?>
<?php // Display Discount percent end ?>

products url does not work cant click the

I have the following code to display a product on home page of magento. The product get displayed but I cannot click it and go to the products page .
Can some one please suggest what's wrong.
<?php
//Almost Gone Section
asort($catalog);
reset($catalog);
$almostGoneId = key($catalog);
$almostGoneStock = $catalog[$almostGoneId];
$almostGone = Mage::getModel('catalog/product')->load($almostGoneId);
$_categories = $almostGone->getCategoryIds();
$_catarray = array();
foreach ($_categories as $cat)
{
$category = Mage::getModel('catalog/category')->load($cat);
$_catarray[$category['url_path']] = $category['level'];
}
arsort($_catarray);
$_depth = reset($_catarray);
$_uri = key($_catarray);
$url = $this->getUrl($_uri).$almostGone['url_key'].'';
$almost_gone_price = $almostGone['special_price'];
?>
--><div id="almost_gone" class="product-display-block">
<div class="display-block">
<div class="product_display_image">
<img src="<?php echo $this->helper('catalog/image')- >init($almostGone, 'image')
- >constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(718) ?>" alt="<? php echo $almostGone['name'] ?>">
</div>
<div class="transparent_title">
<!-- <span>Almost Gone, Huge Savings</span> --><span class="display_model">Hurry, Almost Gone Only <?php echo str_replace(".00", "",$_coreHelper->currency($almost_gone_price,true,false)); ?></span>
</div>
</div>
<div class="display_info gone-info">
<span>Grab A Bargain Today, Only </span><span class="red"><?php echo *emphasized text*$almostGoneStock ?></span><span> Left</span>
</div>
<div class="gone-na">
<img src="<?php echo $this->getSkinUrl('images/home/gone-na.png') ?>">
</div>`enter code here`
<div class="link-hover"></div>
</div>
Where is your product url ??
$url = $product->getProductUrl() // may be like this
<a href="<?php echo $url;?>"><img src="<?php echo $this->helper('catalog/image')- >init($almostGone, 'image')
- >constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(718) ?>" alt="<? php echo $almostGone['name'] ?>"></a>

Update woocommerce shopping cart icon dynamically with ajax

I Have searched for an answer to this, but not been able to find one.
In my woocommerce shop, i want a basket icon at the top of the site. When a customer puts something in the cart, they want to swap this icon for a different one - this icon ("not empty") will stay as long as the cart is not empty.
What I'm after is a PHP-type if / else call, which says "if the cart is empty, display icon A, else display icon B". If anyone could shine some light on this, I'd be most grateful!
I am able to update the cart text dynamically following this woocommerce tutorial,
http://docs.woothemes.com/document/show-cart-contents-total/
In my Page
<?php global $woocommerce;
if($woocommerce->cart->get_cart_total()=='0') { ?>
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/empty_cart.png" alt="" width="30" height="30">
<?php }else{ ?>
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/full_cart.png" alt="" width="30" height="30">
<?php } ?>
<a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" >Your Cart : <?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> - <?php echo $woocommerce->cart->get_cart_total(); ?></a>
In Functions.php
add_filter('add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment');
function woocommerce_header_add_to_cart_fragment( $fragments ) {
global $woocommerce;
ob_start();
if($woocommerce->cart->get_cart_total()=='0') { ?>
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/empty_cart.png" alt="" width="30" height="30">
<?php
}else{ ?>
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/full_cart.png" alt="" width="30" height="30">
<?php }
?>
<a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" >Your Cart : <?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> - <?php echo $woocommerce->cart->get_cart_total(); ?></a>
<?php
$fragments['a.cart-contents'] = ob_get_clean();
return $fragments;
}
currently it is showing both the images no matter what is in the cart.
You can see the implementation of the above at
http://fungass.com/testing/shop/uncategorized/abc/
Finally solved it like this,
<?php global $woocommerce; ?>
<a href="<?php echo $woocommerce->cart->get_cart_url(); ?>" ><?php if ($woocommerce->cart->cart_contents_count == 0){
printf( '<img src="%s/images/empty.png" alt="empty" height="25" width="25">', get_stylesheet_directory_uri());
}else{
printf( '<img src="%s/images/full.png" alt="full" height="25" width="25">', get_stylesheet_directory_uri());
}
?> </a>
<a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" >
Your Cart : <?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> - <?php echo $woocommerce->cart->get_cart_total(); ?></a>
I would actually recommend that you use cookies & JavaScript to handle this functionality for the added benefit of allowing caching plugins to serve static pages on non-WooCommerce pages but still have some dynamic pieces on the page (like cart totals or just simply a populated cart icon).
On the PHP side of things, on init, check for cart totals and set a cookie value...
// this should only ever fire on non-cached pages (so it SHOULD fire
// whenever we add to cart / update cart / etc
function update_cart_total_cookie()
{
global $woocommerce;
$cart_total = $woocommerce->cart->cart_contents_count;
setcookie('woocommerce_cart_total', $cart_total, 0, '/');
}
add_action('init', 'update_cart_total_cookie');
On the JavaScript side of things, examine the cookie and then change the icon...
// use the custom woocommerce cookie to determine if the empty cart icon should show in the header or the full cart icon should show
// *NOTE: I'm using the jQuery cookie plugin for convenience https://github.com/carhartl/jquery-cookie
var cartCount = $.cookie("woocommerce_cart_total");
if (typeof(cartCount) !== "undefined" && parseInt(cartCount, 10) > 0) {
$(".full-cart-icon").show();
$(".empty-cart-icon").hide();
// optionally you can even use the cart total count if you want to show "(#)" after the icon
// $(".either-cart-icon span").html("(" + cartCount + ")");
}
else {
$(".full-cart-icon").hide();
$(".empty-cart-icon").show();
}
Hope this helps a bit! Have fun!

how to get different id in body tag?

I have placed the following code in joomla 2.5
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu()->getActive();
$pageclass = '';
if (is_object($menu))
$pageclass = $menu->params->get('pageclass_sfx');
?>
<body id="<?php echo $pageclass ? htmlspecialchars($pageclass) : 'default'; ?>">
But it's getting default for all pages.
Ooops! its resulting this
<body default""="" style="font-size: 100%;">
I take alias to make different id for each page
<body id="<?php echo (isset($menu) || !empty($menu))?$menu->alias:'default'; ?>">
And working fine.

Resources