I am using the joomla newsflash in order to display the 5 most recent items in my home page. the newsflash is attached to my news & events category. now I need that one of the news & events items will not be displayed in my home newsFlash. is it possible?, thanks
For Joomla 1.5.26, a template override might be your best bet. See here for how that's done: http://forum.joomla.org/viewtopic.php?t=145996
In your case, you'd create a new file at
/templates/your_template/html/mod_newsflash/_item.php
You'd put the following code in that file. Be sure to replace "99" with the id of your article. You can get that from the Article Manager table.
<?php // no direct access
defined('_JEXEC') or die('Restricted access'); ?>
<?php
$my_article_id = $item->id;
if ($my_article_id !== '99') :
if ($params->get('item_title')) : ?>
<table class="contentpaneopen<?php echo $params->get( 'moduleclass_sfx' ); ?>">
<tr>
<td class="contentheading<?php echo $params->get( 'moduleclass_sfx' ); ?>" width="100%">
<?php if ($params->get('link_titles') && $item->linkOn != '') : ?>
<a href="<?php echo $item->linkOn;?>" class="contentpagetitle<?php echo $params->get( 'moduleclass_sfx' ); ?>">
<?php echo $item->title;?></a>
<?php else : ?>
<?php echo $item->title; ?>
<?php endif; ?>
</td>
</tr>
</table>
<?php endif; ?>
<?php if (!$params->get('intro_only')) :
echo $item->afterDisplayTitle;
endif; ?>
<?php echo $item->beforeDisplayContent; ?>
<table class="contentpaneopen<?php echo $params->get( 'moduleclass_sfx' ); ?>">
<tr>
<td valign="top" ><?php echo $item->text; ?></td>
</tr>
<tr>
<td valign="top" >
<?php if (isset($item->linkOn) && $item->readmore && $params->get('readmore')) :
echo '<a class="readmore" href="'.$item->linkOn.'">'.$item->linkText.'</a>';
endif; ?>
</td>
</tr>
</table>
<?php endif; ?>
The relevant code is in the second and final PHP tags, where I've inserted an IF check which looks for your article ID and skips it if it matches.
Related
getName() returns null after upgrade to magento 1.9.38
in product page
the code i'm talking about is located in
design/frontend/rwd/default/template/cataloginventory/stockqty/compsite.phtml
<?php foreach ($this->getChildProducts() as $childProduct) : ?>
<?php $childProductStockQty = $this->getProductStockQty($childProduct); ?>
<?php if ($childProductStockQty > 0) : ?>
<tr>
<td><?php echo $childProduct->getName() ?></td>
<td class="a-center"><?php echo $childProductStockQty ?></td>
</tr>
<?php endif ?>
<?php endforeach ?>
it's only showing the qty but not the product name. All this products are associated products to one configurable...
the image where should appear the product name, on the product page
I'm attempting to place the product attribute table within a div on my product page, seperately from the content of the usual collateral tabs.
I've located the code from my attributes.phtml and i've tried to just copy and paste this code into the appropriate part of my view.phtml, resulting in the following:
<div class="spec-table">
<?php if($_additional = $this->getAdditionalData()): ?>
<table class="data-table" id="product-attribute-specs-table">
<col width="25%" />
<col />
<tbody>
<?php foreach ($_additional as $_data): ?>
<?php $_attribute = $_product->getResource()->getAttribute($_data['code']);
if (!is_null($_product->getData($_attribute->getAttributeCode())) && ((string)$_attribute->getFrontend()->getValue($_product) != '')) { ?>
<tr>
<th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
<td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
</tr>
<?php } ?>
<?php endforeach; ?>
</tbody>
</table>
<script type="text/javascript">decorateTable('product-attribute-specs-table')</script>
<?php endif;?>
</div>
When this didn't work, I tried invoking the attributes.phtml from within my view.phtml using:
<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('catalog/product/view/attributes.phtml')->toHtml();?>
but sadly neither of these approaches seems to work, and I just end up with a blank div.
What's the best way to inject my attributes.phtml (or for that matter, the contents of any given .phtml file) into my product page at some arbitrary point?
Managed to get this to work using the following
<?php echo $this->getLayout()->createBlock('catalog/product_view_attributes')->setTemplate('catalog/product/view/attributes.phtml')->toHtml();?>
Is it possible to output the available list of custom options onto the view.phtml page within Magento? Obviously the drop down lists allow you to filter down but I need to list them in a html table and allow the customer to add to cart on each item.
I will show you how to convert dropdown and multi-select options into table format. This is the code that do the trick.
<?php
$product = Mage::Registry('current_product');
$options = $product->getOptions();
//check for option exists
if($options):
foreach ($options as $option) :
//table format allows only for select options
if($option->getType()== Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN ||
$option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_MULTIPLE):
$require = ($option->getIsRequire()) ? ' required-entry' : '';
if($option->getType()== Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN):
$value_name = 'options['.$option->getid().']';
else:
$value_name = 'options['.$option->getid().'][]';
endif;
?>
<table border="1" style="width:500px;margin-bottom:30px">
<thead>
<tr<?php if ($option->getIsRequire()) echo ' class="required"' ?>>
<th><?php echo $option->getTitle() ?></th>
<th><?php if ($option->getIsRequire()) echo '<em>*</em>' ?></th>
</tr>
</thead>
<tbody id="<?php echo 'select_'.$option->getId() ?>" class="<?php echo $require.' product-custom-option' ?>">
<?php
foreach ($option->getValues() as $values) :
$value = $values->getOptionTypeId();
$value_title = $values->getTitle();
?>
<tr>
<td>
<?php
if($option->getType()== Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN):
?>
<input type="radio" name="<?php echo $value_name; ?>" class="radio_option" id="<?php echo 'radio_option_'.$value ?>" value="<?php echo $value; ?>" />
<?php
else:
?>
<input type="checkbox" name="<?php echo $value_name; ?>" class="checkbox_option" id="<?php echo 'checkbox_option_'.$value ?>" value="<?php echo $value; ?>" />
<?php
endif;
?>
</td>
<td><?php echo $value_title; ?></td>
</tr>
<?php
endforeach;
?>
</tbody>
</table>
<?php
endif;
endforeach;
endif;
?>
Here for dropdown options, we are using radio button to show their values. For multiselect options, checkbox inputs are used. So if checkbox appears in the table, that means it a multi select option and hence more than one checkboxes can have tick at a time. Since radio buttons are used for dropdown options, it is important to make sure that, only one radio button is checked at a time. (We need to use javascript for ensure this).
So if we are set some custom options for a product through admin like this..
The output correspond to our code will be look like this
Note: Please note that, the code is in very basic format. You may require additional css and javascripts make it more user frontly. This is for giving you a basic idea and additional css, js are hence out of box topic.
For more information about code, check out my blog
Hope it helps
my problem is, that i can get correct product url, but it doesn't get product name, image, price and description.
i have 6 item random product block like this:
http://www.upload.ee/image/3374325/magento.png
all the six items are clickable and they have correctly random products url's behind. Just can't figure out why image, price and name won't apper.
current code:
<?php $_productCollection = Mage::getModel('catalog/product')->getCollection(); ?>
<?php if(!$_productCollection->count()): ?>
<div class="padder">
<div class="note-msg">
<?php echo $this->__('There are no products matching the selection.') ?>
</div>
</div>
<?php else: ?>
<div class="listing-type-cell catalog-listing padder" style="margin-bottom:-20px;margin-top:10px;border-top: 1px solid rgba(221,221,221,0.53);"> <!-- the class name will change to .listing-type-grid if viewing in grid mode -->
<?php $_collectionSize = $_productCollection->count() ?>
<?php $_items = $_productCollection->getItems();
shuffle($_items); ?>
<h2 style="margin:20px 0;">Seda toodet vaadanud inimesed vaatasid ka neid tooteid</h2>
<table cellspacing="0" class="products-grid" id="product-grid-table">
<?php $i=0; foreach ($_items as $_product): ?>
<?php if ($i++%6==0): ?>
<tr height="290">
<?php endif ?>
<td class="random_item" style="width:150px;padding-right:10px;">
<a class="product-image" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_product->getName() ?>">
<img src="<?php echo $_product->getImageUrl(); ?>" width="144" height="216" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" /></a>
<h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></h3>
<?php echo $this->getPriceHtml($_product, true) ?>
</a>
</td>
<?php if ($i%12==0 && $i!=$_collectionSize): ?>
</tr>
<?php endif ?>
<?php if ($i==6) break; // show 6 products max ?>
<?php endforeach ?>
<?php for($i;$i%12!=0;$i++): ?>
<td class="empty-product"> </td>
<?php endfor ?>
<?php if ($i%12==0): ?>
</tr>
<?php endif ?>
</table>
<script type="text/javascript">decorateTable('product-grid-table')</script>
</div>
<?php endif; ?>
See this question for adding name and price: retrieve product attributes in collection and this thread for images: load the media_gallery in a product collection
This file (frontend/base/default/template/catalog/product/list.phtml) was edited, now is not showing the proper prices,
http://www.personalproducts4u.co.uk/hotel-toiletries/au-lait
I changed the third table tag (ONLY THE THIRD TABLE TAG)on the file above AND THE PRICES ARE SHOWING ALL THE SAME (ON DISCOUNTED PRICES)
any ideas?
this is the code I changed:(pasted it on the third table tag of the lists file)
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<th class="buy_heading">Buy</th>
<td class="buy_pay_content">1</td>
<?php
/*foreach($tierPrices as $key=>$value)
{
echo "<td class='buy_pay_content'>".number_format($tierPrices[$key]['price_qty'],0)."</td>";
} */
?>
<?php
if(count($tierPrices)):
foreach($tierPrices as $key=>$value)
{
echo "<td class='buy_pay_content'>";
echo number_format($tierPrices[$key]['price_qty'],0);
if($key == $count-1)
{
echo "+";
}
echo "</td>";
}
else:
echo '<td class="buy_pay_content">5</td>
<td class="buy_pay_content">10+</td>';
endif;
?>
<td class="buy_pay_content">Quantity</td>
</tr>
<tr>
<th class="pay_heading">Pay</th>
<td class="buy_pay_content"><?php echo $this->getPriceHtml($_product) ?><?php //echo Mage::helper('core')->currency($_product->getPrice()) ; ?>
<?php //echo Mage::helper('core')->currency($_product->getPrice()) ; ?> <?php //echo $this->getPriceHtml($_product, true)
?>
</td>
<?php
$specialprices = Mage::getModel('catalog/product')->load($_product->getId())->getSpecialPrice();
if($specialprices)
{
$specialprice =$specialprices;
}
else
{
$specialprice = 0;
}
if(count($tierPrices)):
foreach($tierPrices as $key=>$value)
{
if($specialprice < $tierPrices[$key]['price'] && $specialprice != '0'):
//echo 'special less'.$specialprice;
?>
<td class='buy_pay_content'><div class="price-box">
<p class="old-price"><span id="old-price-182" class="price"> <?php echo Mage::helper('core')->currency($tierPrices[$key]['price']) ?> </span> </p>
<p class="special-price"> <span id="product-price-182" class="price"><?php echo Mage::helper('core')->currency($specialprice) ?></span></p>
</div></td>
<?php
else:
?>
<td class='buy_pay_content'><?php echo Mage::helper('core')->currency($tierPrices[$key]['price']) ?></td>
<?php
endif;
?>
<?php }
else:
echo "<td class='buy_pay_content'>".$this->getPriceHtml($_product, true)."</td>";
echo "<td class='buy_pay_content'>".$this->getPriceHtml($_product, true)."</td>";
endif;
?>
<td class="buy_pay_content"><input type="text" class="input-text qty" title="Qty" value="" maxlength="12" id="qty" name="qty"></td>
</tr>
</table>
Well the issue seems to be the fact that getSpecialPrice() returns what ever is in the Special Price field. I could be mistaken but I don't believe you can supply special tiered prices in Magento. You can still add a static special price but as you have already experienced it will display the same price for each iteration.
You will probably need some sort of custom extension or template logic to display such sales properly.
I am not sure how you currently manage your tiered pricing, but if it is a fixed percentage for each tier you could set your tiered prices to the calculated sale prices and calculate and display the original tier prices by dividing each tiered discount percentage and display that number.