related products in joomla - joomla

How to display only thumbnails of products in related products area, my current code is showing the link too i.e image tag with href title of product name. I just want to show the thumbnails
<?php
foreach($this->product->customfieldsRelatedProducts as $field) {
echo $field->display;
}
?>

I think code will help you.
<?php
$image_dir = JURI::root()."images/";
foreach($this->product->customfieldsRelatedProducts as $field) {
echo $field->display;
?>
<img src="<?php echo $image_dir.$field->image; ?>" alt="<?php echo $field->title ?>" />
<?php
}
?>

Related

Magento Static block now showing up in CMS Page

Hy ! I'm trying to display the categories on a cms page.I've tried all the solution on the web but none is working for me. The last one i've tried is this.
1.I've added this code in content tab of my cms page :
{{block type="catalog/navigation" template="catalog/category/list.phtml"}}
2.I've created the list.phtml and put the file on app/design/theme-name/template/catalog/category.
Here is the code pf my file
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php $open = $this->isCategoryActive($_category); ?>
<?php
$cur_category=Mage::getModel('catalog/category')->load($_category->getId());
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category);
if ($immagine = $this->getCurrentCategory()->getImageUrl()):
?>
<div class="catalog-image">
<div>
<a href="<?php echo $this->getCategoryUrl($_category)?>">
<img src="<?php echo $immagine ?>" alt="<?php echo $this->htmlEscape($this->getCurrentCategory()->getName()) ?>" width="313" height="151" />
</a>
</div>
<div class="left"><h2><?php echo $_category->getName()?></h2></div>
</div>
<?php endif; ?>
<?php endforeach; ?>
What I'm doing wrong ? Thanks !
Add this code in content tab of your cms page:
{{block type="core/template" template="page/categories-list.phtml"}}
Create a file in the theme such "categories-list.phtml"
path: app/design/theme-name/template/page/categories-list.phtml
In this file, write the following code in order to get a collection of all the categories:
<?php
$categories = Mage::getModel('catalog/category')
->getCollection()
->addAttributeToSelect('*')
->addIsActiveFilter();
?>
If you want only some categories of parent, use the following code:
<?php
$parent_category_id = 5; // this is ID of parent category
$categories = Mage::getModel('catalog/category')->getCategories($parent_category_id);
?>
To display categories on the screen, use loop, look below:
<?php foreach ($categories as $category): ?>
<p><?php echo $category->getImageUrl(); ?></p>
<p><?php echo $category->getName(); ?></p>
<?php endforeach; ?>
If you use the categories of the parent category to display the image, use the following code:
Mage::getModel('catalog/category')->load($category->getId())->getImageUrl();
Create a folder under catalog with name navigation and put your list.phtml file there it will work.
{{block type="core/template" template="catalog/navigation/list.phtml" category_id="507" }}
Category Display Mode shuould be in static block in display setting.

Joomla/Jomsocial PinMe template I want to replace the PinMe Avatar with JomSocial's Profile image

Hi I am using TemPlaza's PinMe template with the Jomsocial community component in Joomla! 3.0.3 Stable [ Ember ]
What I am looking for a very simple solution to having the Jomsocial avatar (Profile Image) replace the PinMe image on the Pins which
uses joomla core for image and profile
Jomsocial offers this:
Use JomSocial Avatars
To acquire a path to a JomSocial Avatar, you can simply request a cUser object and call a simple getThumbAvatar function to retrieve the avatar url.
include_once JPATH_ROOT.'/components/com_community/libraries/core.php';
// Get CUser object
$user = CFactory::getUser($userid);
$avatarUrl = $user->getThumbAvatar();
echo '<img src="'.$avatarUrl.'">';
The PinMe template is coded as such:
<?php if(isset($this->s_user) && $this->s_user==1){ ?>
<div class="TzAuthor">
<?php if(isset($Pins->user_img) && !empty($Pins->user_img)){ ?>
<img class="tz_pin_img_user" src="<?php echo JUri::root().'/'.$Pins->user_img; ?>">
<?php }else{ ?>
<img class="tz_pin_img_user" src="<?php echo JUri::root().'/components /com_tz_pinboard/images/avata.jpg'?>">
<?php }?>
<div class="TzAuthorInfo">
<a class="tz_pin_name_user"
href="<?php echo Route::_(TZ_PinboardHelperRoute::getPinboardManageruserRoute($Pins->id_user)); ?>" rel="nofollow">
<?php echo $Pins->user_name; ?>
<?php if(isset($Pins->name_user_repin) && !empty($Pins->name_user_repin)){
?>
<strong class="tz_by">
<?php echo JText::_('COM_TZ_PINBOARD_MANAGERUSER_REPIN_BY'); ?>
</strong>
<?php
echo $Pins->name_user_repin;
}
?>
</a>
spoke with the PinMe people and the cost for custom code isnt worth it and the sites on my local not live
to reiterate
all I am looking for a very simple solution to having the Jomsocial avatar (Profile Image) replace the PinMe profile image on the Pins
how do i make this happen

Displaying posts from specific categories with the AheadWorks blog extension for Magento

I'm using the AheadWorks blog extension for Magento, and my blog pages are working fine. But I want excerpts of my latest posts from certain categories to appear on my home page. I've successfully setup everything thus far by adding:
<block type="blog/blog" name="blog.latest" template="aw_blog/blog-home.phtml" />
to "layout.xml", by adding:
<?php echo $this->getChildHtml('blog.latest') ?>
to my home page's phtml file, and by creating "template/aw_blog/blog-home.phtml".
The problem is that I can't figure out how to limit what categories are shown. For example, you'll see in my "blog-home.phtml" file below that I'm trying to limit the posts to the "news" category. I've tried lots of solutions from other forums, but no matter what I do, I see posts from every category. Does anyone know what I need to add/take away from my code to limit the categories?
<?php $posts = $this->getPosts("news"); ?>
<div id="messages_product_view">
<?php Mage::app()->getLayout()->getMessagesBlock()->setMessages(Mage::getSingleton('customer/session')->getMessages(true)); ?>
<?php echo Mage::app()->getLayout()->getMessagesBlock()->getGroupedHtml(); ?>
</div>
<?php $numberOfPosts = 1 ?>
<?php $renderedPosts = 0 ?>
<?php foreach ($posts as $post): ?>
<div class="postWrapper">
<div class="postTitle">
<h2><a href="<?php echo $post->getAddress(); ?>" ><?php echo $post->getTitle(); ?></a></h2>
</div>
<div class="postContent"><?php echo $post->getPostContent(); ?></div>
<?php echo $this->getBookmarkHtml($post) ?>
<div class="tags"><?php echo $this->getTagsHtml($post) ?></div>
<div class="postDetails">
<?php if ($this->getCommentsEnabled()): ?>
<?php echo $post->getCommentCount(); ?> <a href="<?php echo $post->getAddress(); ?>#commentBox" >Comments</a> |
<?php endif; ?>
<?php $postCats = $post->getCats(); ?>
<?php echo "<h1>" . $postCats[2] . "</h1>"; ?>
<?php if (!empty($postCats)): ?>
<?php echo Mage::helper('blog')->__('Posted in'); ?>
<?php foreach ($postCats as $data): ?>
<?php echo $data['title']; ?>
<?php endforeach; ?>
<?php else: ?>
<?php endif; ?></div>
<?php $renderedPosts ++ ?>
<?php if ($renderedPosts = $numberOfPosts) {
break;
}
?>
</div>
<?php endforeach; ?>
<?php //$this->getPages(); ?>
Following is the quick solution:
Go to aw_blog frontend template, default might be this app/design/frontend/base/default/template/aw_blog/menu.phtml
check and replace:
if ($posts = $this->getRecent():
with
$currentBlogCat = Mage::getSingleton('blog/cat');
if ($posts = $this->getRecent($currentBlogCat['cat_id'])):
Now open up /app/code/community/AW/Blog/Block/Menu/Sidebar.php
check for the below function:
public function getRecent()
add a parameters to it:
public function getRecent($currentCat=false)
Also, replace the following code block
$collection = clone self::$_collection;
if (array_key_exists('categories',$data = $this->getData();) && count(explode(',', $data['categories'])) == 1) {
with
$collection = clone self::$_collection;
$data = $this->getData();
if($currentCat>0)$data['categories']=$currentCat;
# Category fix #
if (array_key_exists('categories',$data ) && count(explode(',', $data['categories'])) == 1) {
Thanks!

In Joomla 2.5, How can I add category images and Title in the "list all categories" layout

In Joomla 2.5.8, I've created a menu item that uses the "List All Categories" type. I'm wanting to display the image AND Title for the parent category and the images for each subcategory as follows:
-- Parent Category Image --
Parent Category Title
Parent Category Description
SubCategory1 Title
Subcategory1 Image -- SubCategory1 Description
SubCategory2 Title
Subcategory2 Image -- SubCategory2 Description
SubCategory3 Title
Subcategory3 Image -- SubCategory3 Description
SubCategory4 Title
Subcategory4 Image -- SubCategory4 Description
I'm working in the file template/html/com_content/categories/default.php and I've tried copying the code from the blog.php file:
<?php if ($this->params->get('show_description_image') && $this->category->getParams()->get('image')) : ?>
<img src="<?php echo $this->category->getParams()->get('image'); ?>"/>
<?php endif; ?>
But it breaks the page and loads a blank page. The titles of the subcategories and their descriptions show, I'm just missing the parent title and the images.
In the options for the menu item I have the category title, description and image all set to show.
Any help on this would be greatly appreciated.
here's the deafault.php code:
<?php
/**
* #package Joomla.Site
* #subpackage com_content
* #copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* #license GNU General Public License version 2 or later; see LICENSE.txt
*/
// no direct access
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers');
?>
<?php if ($this->params->get('show_page_heading')) : ?>
<h1>
<?php echo $this->escape($this->params->get('page_heading')); ?>
</h1>
<?php endif; ?>
<?php if ($this->params->get('show_base_description')) : ?>
<?php //If there is a description in the menu parameters use that; ?>
<?php if($this->params->get('categories_description')) : ?>
<?php echo JHtml::_('content.prepare', $this->params->get('categories_description'), '', 'com_content.categories'); ?>
<?php else: ?>
<?php //Otherwise get one from the database if it exists. ?>
<?php if ($this->parent->description) : ?>
<div class="category-desc">
<?php echo JHtml::_('content.prepare', $this->parent->description, '', 'com_content.categories'); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
<?php
echo $this->loadTemplate('items');
?>
The answer is here: http://forum.joomla.org/viewtopic.php?p=2613555
The codes to display the images, if the category has an image and if
"Show category image" is selected (Joomla 2.5, it should work for 1.7
too).
For the parent category, in
templates/mytemplate/html/com_content/categories/default.php
<?php if ($this->params->get('show_description_image') && $this->parent->getParams()->get('image')) : ?>
<img src="<?php echo $this->parent->getParams()->get('image'); ?>" alt=" "/>
<?php endif; ?>
For the subcategories, in
templates/mytemplate/html/com_content/categories/default_items.php
<?php if ($this->params->get ('show_description_image') && $item->getParams()->get('image')) :?>
<img src="<?php echo $item->getParams()->get('image');?>" alt=" "/>
<?php endif; ?>
This is a solution for Joomla 3.x version. It works for both categories and sub-categories.
templates/mytemplate/html/com_content/categories/default_items.php
<?php if ($item->getParams()->get('image')) : ?>
<img src="<?php echo $item->getParams()->get('image');?>" alt="">
<?php end if; ?>

Display pricing and add to cart button in related products Virtuemart 2.0

I would like to display the related product pricing and have add to cart button along with each of the related products.
Below is the code snippet from the related products page. The $field does not have any pricing available. How can I show the pricing and "add to cart" button? Thanks in advance
<?php
foreach ($this->product->customfieldsRelatedProducts as $field) {
?><div class="product-field product-field-type-<?php echo $field->field_type ?>">
<span class="product-field-display"><?php echo $field->display ?></span>
<span class="product-field-desc"><?php echo jText::_($field->custom_field_desc) ?></span>
</div>
<?php } ?>
I have found solution here and it works for me:
no need to edit core files
It requires copying the "default_relatedproducts.php", "default_showprices.php" and "default_addtocart.php" to your "template/html/com_virtuemart/productdetails" folder. Then replace all of the code in the "default_relatedproducts.php" with the following code:
<?php
// Check to ensure this file is included in Joomla!
defined ( '_JEXEC' ) or die ( 'Restricted access' );
$model = new VirtueMartModelProduct();
$calculator = calculationHelper::getInstance();
$currency = CurrencyDisplay::getInstance();
?>
<div class="product-related-products">
<h4><?php echo JText::_('COM_VIRTUEMART_RELATED_PRODUCTS'); ?></h4>
<div>
<?php
foreach ($this->product->customfieldsRelatedProducts as $field) {
?>
<div class="product-field">
<?php
$product = $model->getProductSingle($field->custom_value,true);
?>
<h2><?php echo JHTML::link ($product->link, $product->product_name); ?></h2>
<a title="<?php echo $product->product_name ?>" rel="vm-additional-images" href="<?php echo $product->link; ?>">
<?php
echo $this->product->images[0]->displayMediaThumb('class="browseProductImage"', false);
?>
</a>
<div class="short_desc"><?php echo $product->product_s_desc; ?></div>
<?php include 'default_showprices.php'; ?>
<?php include 'default_addtocart.php'; ?>
</div>
<?php } ?>
</div>
</div>
Had a same problem. But I had to show only the price.
So the fastest way is to change sql select statement in customfields.php
Path in Joomla 2.5 for Virtuemart 2.0 administrator/components/com_virtuemart/models/customfields.php
line 548 of
public function getProductCustomsFieldRelatedProducts($product)
change only
$query=
with
'SELECT C.`virtuemart_custom_id` , `custom_parent_id` , `admin_only` , `custom_title` , `custom_tip` , C.`custom_value`
AS value, `custom_field_desc` , `field_type` , `is_list` , `is_hidden` , C.`published` , field.`virtuemart_customfield_id` ,
field.`custom_value`, field.`custom_param`, price.`product_price`, field.`ordering`
FROM `#__virtuemart_customs` AS C
LEFT JOIN `#__virtuemart_product_customfields` AS field ON C.`virtuemart_custom_id` = field.`virtuemart_custom_id`
LEFT JOIN `#__virtuemart_product_prices` AS price ON
field.`custom_value` = price.`virtuemart_product_id`
Where field.`virtuemart_product_id` ='.(int)$product->virtuemart_product_id.' and `field_type` = "R"';
After all on line 559 change
$field->custom_price
to
$field->product_price
And finally...
In template view of product description insert the code below to show the prices of related products
<?php echo $field->product_price ?>
The only problem with the below solution is that it doesn't display the correct images for the related products. It's using the main products image and just repeating it.

Resources