Determine category in CMS block - magento

I've got some categories in Magento which have got "Static block and products" as display mode. All these categories point to the same CMS block, which in turn points to a template file. The template file should generate different content according to the category.
So my question is: Can I, in the CMS block (or template file), somehow find out the category?
Thank you in advance!

Mage::registry('current_category');

Related

How can i edit the product template of Magento Website

Sorry for asking for very basic question. Actually i am very new to magento hence couldn't find the solution..Here is the question:
I have a magento ecommerce website and i want to edit the product template of the website.
I have both magento and FTP credentials. But not able to figure out where is the actual product template.
in which folder i have to look for the product template file?
I want to append some HTML to each product page hence i am looking for it.
Please Advise.
Hope to get some help.
Regards,
Rich
The best way to debug this type of issue when new to magento is to "Turn on Template Path Hints"
Log into the admin
Goto -> System ->Configuration, and on the bottom of the list select “Developer”
click on Debug – you will only see “Profiler”. Here is the trick – you have to switch the “Current Configuration Scope:” [in the upper left] to a website instead of default. Select “Main Website”.
Now you will see the selection for Template Path Hints – check yes. This will display the path of the template for each block of the page so you can find stuff! You can also choose to “Add Block Names to Hints” to see the corresponding model class for the block.
Which going to point you to app/design/frontend/[theme]/default/template/catalog/product/*
Read more # http://www.redlightblinking.com/blog/magento-debugging-how-to-debug-template-paths-logging-and-display-errors
In addition to the previous answer make sure to disable the cache otherwise you might not see the results right away.
The Product page has many files attached but mainly the most importants, in my opinion, areI
the media.phtml that controls the size of your mage, more views, etc then you have the
the upsell.phtml that call the upsell products and
the view.phtml that combine all these files.
You can find them at
app/design/frontend/base/default/template/catalog/product
app/design/frontend/base/default/template/catalog/product/view
Copy these files and paste them in your theme directory. DO NOT OVERRIDE THEM! and also keep in mind you have: single product, configurable product, etc so you'll have to edit those files as well if you need!
Hope this helps and any feedback from other users is always appreciated.
I have a Magento e-commerce website and I want to edit the product template of the website. I have both Magento and FTP credentials. But not able to figure out where is the actual product template. in which folder do I have to look for the product template file, I would like to edit my product by adding some code. I found this folder in FTP /public_html/app/design/frontend/ET/base/Magento_Catalog/templates/product/view/productlabels.phtml
I edit some code
unit price :
<script type="text/javascript">
$(document).ready(function() {
var Quantity = document.getElementById("qty").value;
var UnitPrice = document.getElementById("options[4]").value;
var vUnitPrice = vUnitPrice / vQuantity;
vUnitPrice = $("#vUnitPrice ").val(total2.toFixed(2));
document.write(vUnitPrice);
}
</script>
but nothing changes, help me please

Display 4 items per row from any category on magento1.7 home page

I am fresher with magento. I am using magento 1.7.
I want to display 4 items per row on magento home from a category. I am using wayaat.com free theme. How can I display. Please guide.
My dummy magento instance where I am doing R&D with magento: http://questoons.com/magento/
You can use different list file for displaying your product, just copy original list.phtml file and give name something like listhome.phtml and put in catalog/product folder and in this file change $_columnCount variable to $_columnCount =4 and you are done and in your cms page change your listing file named {{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/listhome.phtml"}}
Sorry to post an answer here, but i dont have enough reputation to comment.
Increase your ul.products-grid width from current 980px to at least 1001 px. It will bring the forth product in row. As Mufaddal stated before, yours is a matter of css now.

How to remove pager and sorter on home page Magento

I'm trying to modify mi CMS/home_page of Magento. I want to see some products that are on a specific category, like this:
{{block type="catalog/product_list" category_id="35" column_count="4" template="catalog/product/list.phtml" }}
It shows the category products, but now, I want to go a step further, and I want to remove some elements as it is the home page. I attach an image to clarify:
1 and 2 are located at the pager element. When we have more than one page of products, we can also see the pages (element 4), also located here. In this case, we only have 4 products, so we don't see the pages.
Element 3 is at sorter element.
I want to remove element 1, 2 and 3 if it's the home page, but keep element 4 (the pages).
Any idea on how can I do that on Magento?
You will have to duplicate the category product list display module, which means creating your own module, XML, PHTML and such ... Personally I would use the z-blocks module from Aheadworks. This will give you the ability do display things like "featured products" etc. on your homepage without editing Magento block code. .. It's not that expensive considering the amount of time you will spend developing what you want to do.
As you may already be knowing that these elements are being rendered through pager.phtml. The elements that you want to remove can made to disappear by checking for a condition i.e
if(!(Mage::getSingleton('cms/page')->getIdentifier()=='home'))
{pass the variables that you do not want to appear in home page}
I could solve it. For anyone who could need it, without a payed extension, here I write what I did:
First:
I duplicated this phtml on my theme folder:
catalog/product/list/toolbar.phtml
catalog/product/list.phtml
And I paste them on my template folder. I changed the name in order to not override the elements for the other pages that are not the home page.
catalog/product/list/toolbar_home.phtml
catalog/product/list_home.phtml
With this, I have 2 phtml that work only for my homepage. How do I call them?
Second:
I add the specific block on my home page:
{{block type="catalog/product_list" category_id="35" column_count="4" template="catalog/product/list_home.phtml" }}
Beware: I changed the template to point to my template.
Third:
On my list_home.phtml, where you can find this code:
<?php echo $this->getToolbarHtml() ?>
I changed it by this:
<?php echo $this->getToolbarHtmlHome() ?>
This function doesn't exist, so we need to create it. This function will call our toolbar_home.phtml.
Fourth:
Go to code/core/Mage/Catalog/Block/Product/List.php, and find the function getToolbarHtml. Copy and paste it under it. And change it to look like this:
public function getToolbarHtmlHome()
{
return $this->getChildHtml('toolbar_home');
}
Now that we have created all the code, you can go to template/catalog/product/list/toolbar_home.phtml and modify whatever you want. It will work only on your home page! :)

Add search module in category page

I would add the search form in the category pages. The module will make researches in the same category. It's possible?
Add category to Advanced Search. Some pointers here:
http://www.magentocommerce.com/wiki/5_-_modules_and_development/search_and_advanced_search/how_to_add_search_by_category_to_advanced_search
You will probably want to do it in a module rather than in a core hack...
Now put some simple form together inside a phtml file, put the layout xml together to load it on category pages. Set the search to add the current category to the search string that gets sent off to your modified 'Advanced Search'.
As for getting that category, try $this->getCurrentCategory();

how to create a right sidebar in magento which will be visible only on product view page

I am new to magento .
I want to create a right sidebar on product view page such that this is visible only on product view page not on other pages.
How can I do this.Please Help.
Thanks.
To have a right sidebar only on the product page you need to to a few things:
in the admin panel set the product pages to have 2 columns with right sidebar
create a block and template file (or just edit one that is available)
in catalog.xml (this is in your themes's layout folder) find the handle called and within that section find in there you can add your block / template file.
For more info on how you can create blocks and templates see here.
In magento almost every postion is handled by catalog.xml, (if you go the proper way) You can place any static block , in catalog.xml you will find the postioning of blocks for every page (be it category, product or home page) just you need to place the block in the right reference.

Resources