I'm trying to set up a blog page on an old Joomla 1.5 site. I need a different header graphic to show based on which of 3 categories is the current category.
This is what I have thus far, which doesn't really work. For the sake of this example, we'll just use an echo statement in place of the graphic.
if ($this->catid = "960") {
echo "this is category number 960";
}
else {
echo "This is another category";
}
?>
Does anyone remember how to do this in Joomla 1.5?
Figured it out...
<?php $catNum = JRequest::getVar('id');
if ($catNum == "962"){
echo "Category Number 962";
}
else{
echo "nope";
}
?>
Related
I am using Mijoshop which is a Opencart integration for Joomla. What I am currently looking to achieve is to display a specific div class in the header if a certain product or category is matched.
I've found this code which I've added to my category.tpl but without any luck or any of these being displayed:
<? php if($category_id==20){
echo "text1";}
else
{echo "text2"}
?>
Any ideas on how to get this to work? Some expert help would be greatly appreciated.
Try this:
<?php if($category['category_id'] == 20) { ?>
echo "text1";
} else {
echo "text2";
}
?>
The value should be called by $category['category_id'] and you had some syntax errors:
Space after ?
No semi-colon after "text2"
I would like to put a a message to say "available in other colors" on the category page if there is more than one color you can select on the product. Right now I have some code in content.product.php that detects if it's a variable product, but not if there are more than one option for an attribute. Color is a custom attribute.
Right now I have:
<?php if($product->product_type == "variable") { ?>
<h4>Available in other colors.</h4>
<?php } else { ?>
<?php } ?>
It's showing all variable product type with this message. I want to show it only if there are 2 or more colors attached to the product. The products has two attributes on it - size and color. Size always has three or four wheras color sometimes only has one
I guess you are looking for something like this?
<?php
if ($product->product_type == "variable") {
print '<h4>Variable products message.</h4>';
}
else if (count($product->color) > 2) {
print '<h4>This product is avilable in other colors!</h4>';
}
else {
#Optional print here..
}
?>
I might be wrong all you need to do is test by writing
<?php print_r($product); exit;?>
see where the colors are beign stored and just replace the ->color with the proper name. Good luck!
This is what ended up working
<?php
$fabric_values = get_the_terms( $product->id, 'pa_color-swatch');
if (count($fabric_values) >= 2) {
print '<h4>Available in other fabrics.</h4>';
}
else {
#Optional print here..
}
?>
I've encountered a strange thing in one magento installation, I haven't touched it in awhile so they must've added stuff to it.
The issue is: They set the cms page to 'disabled' so that page now yields a 404 error each time it's visited(which is good), but for some reason the links.phtml is still releasing all links, not checking if the page is disabled or not.
So I put this here to test:
<?php $_links = $this->getLinks(); ?>
<?php if(count($_links)>0): ?>
<ul class="links"<?php if($this->getName()): ?> id="<?php echo $this->getName() ?>"<?php endif;?>>
<?php foreach($_links as $_link): ?>
<?php
$cmsCollections = Mage::getModel('cms/block')->getCollection();
$attribute = "title";
$value = $_link['title'];
$cmsCollections->addFieldToFilter($attribute, $value);
$item = $cmsCollections->getFirstItem();
$id = $item->getData('is_active');
if($id == 1){
echo "CMS PAGE ". $value." ACTIVE";
}else{
echo "CMS PAGE ". $value." is INACTIVE";
}
?>
The odd part here is that I keep getting the wrong results ...
I'm no magento expert here so maybe anyone knows how to do this properly in getLinks ? I found no options to filter stuff there unfortunately
Elijah, CMS BLOCk collection should be ...
$cmsCollections=
Mage::getModel('cms/block')->getCollection()->addFieldToFilter('is_active',1);
CMS Page Collection
$CMSpageColl
=Mage::getModel('cms/page')->getCollection()->addFieldToFilter('is_active',1);
If you want a particular CMS block then you can get it using idendifier
$cmsCollections = Mage::getModel('cms/block')->getCollection()->addFieldToFilter('identifier',indefiername);
If you want a particular CMS block then you can get it usign idendifier
$cmspageCollections =
Mage::getModel('cms/page')->getCollection()->addFieldToFilter('identifier',indefiername);
Firstly I would like to apologise if this question has been answered somewhere else but I am unable to find what I am looking for as I am new to PHP and assume I need this to solve my problem.
I have built a website and am using Mals-e shopping cart. I have everything up and running but I would like to show how many products are still in stock under the product description and if there are no items in stock. For example:
Available stock: 2
or
Sold Out
I have read that I need a text file with product name, price and quantity, a PHP file to read and rewrite the quantity available and out put the results on the product page and a mypage.php page but I really don't know where to start. I've spent days trying to sort this out.
I have Mysql database with some items in table called (items) with available quantity but don't know how to go about sorting it out. Any help would be most appreciated.
Thank you.
Without seeing the actual code you're using to display the product, it's hard to say buy all you should need is something like:
<?php
// get the product and stock level
if($product->numberInStock > 0) {
echo 'Available: ' . $product->numberInStock;
} else {
echo 'Out of stock';
}
If you're editing a phtml type template (HTML with embedded PHP), you might display it like:
<? if($product->numberInStock > 0): ?>
<p>Available: <?= $product->numberInStock; ?></p>
<? else ?>
<p>Out of stock</p>
<? endif; ?>
Had same issue, found out following.
Inside your catalog/product type template you can use this:
<?php
$_product = $this->getProduct();
$_qty = $_product->getStockItem()->getQty();
?>
<p>
<?php if($_qty > 0): ?>
Available: <?php echo $_qty; ?>
<?php else: ?>
Out of stock
<?php endif; ?>
</p>
session_start($_POST['quantity']);
if(isset($_POST['quantity']))
{
$postedquantity=$_POST['quantity'];
$productQuantity="20";
if($postedquantity<$productQuantity){
echo "In stock";
echo "<br/>";
}
$productQuantity=$productQuantity-$postedquantity;
echo $productQuantity."Remaining";
}
You can even do like this,storing quantity value in session and everytime it's posted it will check whether it is in stock or not and it will show how much quantity is remaining.
This is my problem: I have an ecommerce website, and I would like my search results to come up with products that have their links avaiable either within the image of the product on the search page, or next to the image. My current code looks like this:
if($_GET['searchBox'] !='')
{
if(mysql_num_rows($searchresult)==0) {
echo 'Your search returned no results';
}
else
{
while ($row = mysql_fetch_assoc($searchresult))]
{
echo "<img src='".$row['image']."'/>".' '.$row['name'].' £'.$row['price'].' '.$row['ProductUrl'];
}
}
}
?>
I have spent ages trying to get an URL into the image area, but I can't make it work.
Please help!!
What the problem put image in to the anchor tag.
Have you tried like this
echo "<a href='".$row['ProductUrl']."'><img src='".$row['image']."'/></a>";
EDIT
echo "<img src='".$row['image']."'/>".' '.$row['name'].' £'.$row['price'].'
<a href="'.$row['ProductUrl']."'>".$row['ProductUrl']."</a>";