I think the main problem is that you should start to understand Magento's layout structure before you begin such a task.
I will try to give a brief tutorial; It may contain some errors and is mainly for structure.
First things first:
- You should turn on Magento Developer Mode.
- You should turn on Magento logging.
After that:
You are trying to create a new block. A block in Magento is not created simply by creating a template .php-file for it; instead, you will have to write a tiny module for it. There are some good tutorials out there how to create a Magento module, so I won't go deeper into detail about the config files and stuff.
How you create a block with a module:
Your module must contain a "Block"-folder and a file like this: app/code/local/[Companymame]/[Modulename]/Block/Catalog/Product/Featured.php
This Featured.php holds your business logic - another thing you are mixing up here: The featured.php in the /template/-folder should contain Template-Stuff, mainly to position the products in some fancy html, display some information (name, price, whatever), but should not contain the way to get the product; instead, there should be some line like $collection = $this->getProductCollection();
Featured.php should contain the class declaration for this block and the methods;
<?php
class [Companyname]_[Modulename]_Block_Catalog_Product_Featured {
function getProductCollection() {
// get the products and return them
$cat_id = 35
$category = Mage::getModel('catalog/category')->load($cat_id);
$collection = $category->getProductCollection()->addAttributeToSort('position');
Mage::getModel('catalog/layer')->prepareProductCollection($collection);
return $collection;
}
}
You have now your block class.
In your module's config.xml, add a paragraph and tell Magento that this module comes with a new block and a layout update:
<global>
<blocks>
<featured>
<class>[Companyname]_[Modulename]_Block_Catalog_Product_Featured</class>
</featured>
</blocks>
</global>
<frontend>
<layout>
<updates>
<featured>
<file>featured.xml</file>
</featured>
</updates>
</layout>
</frontend>
Magento's autoloader function checks the classname and automatically gets your block-file - no manual include of Featured.php is necessary.
The mentioned file featured.xml goes into the app/design/frontend/[package]/[theme]/layout/
folder and should contain the layout update. I don't know the correct path to the header-block atm and will leave it commented for this reason, but I hope you get the point:
<?xml version="1.0">
<!-- navigate to page/header block -->
<block type="[companyname]/[modulename]_catalog_product_featured" name="product.featured" as="topSlider" translate="label">
<label>Page Slider</label>
<action method="setTemplate"><template>catalog/product/featured.phtml</template></action>
</block>
<!-- close open nodes -->
Notice the differences to your xml-statement: The blockname fits the classname; I also added the template via the addTemplate-action and changed you featured.php to featured.phtml - do it the Magento way ;) (not sure if .php would work, though).
As I said above: The code I provided won't be free of errors, just typing this on a lazy Saturday evening ;) I hope you get the point, ask me questions if you need further help.
If you update your config.xml as follows, you should be able to add multiple unique handles:
<config>
<modules>
<Ziva_CustomCatalog>
<version>1.0.0</version>
</Ziva_CustomCatalog>
</modules>
<global>
<blocks>
<ziva_customcatalog>
<class>Ziva_CustomCatalog_Block</class> <!--this is a new block page for that custom module-->
</ziva_customcatalog>
<catalog>
<rewrite>
<product_list>Ziva_Customcatalog_Block_Product_List</product_list>
</rewrite>
</catalog>
</blocks>
</global>
</config>
You can then call 'ziva_customcatalog/layer_view'
for your new block.
Best Answer
There is no need to rewrite this block.
You can just hook into
catalog_block_product_list_collection
and add your filters.