In magento, by default 11 tabs are displayed in the customer edit page in the back end. How can I remove tabs from the default list of tabs. What I have done so far:
Created a class to override Mage_Adminhtml_Block_Customer_Edit_Tabs class and then overrode the _beforeToHtml() method.
tried to remove the tabs using
$this->removeTab('addresses');
Removing Customer tabs
a) You have to override Mage_Adminhtml_Block_Customer_Edit_Tabs because the Magento guys did a small typo there: they are adding tabs in _beforeToHtml() method instead of _prepareLayout(). So first you have to modify your config.xml and add:
<global>
<blocks>
<adminhtml>
<rewrite>
<customer_edit_tabs>Yourmodule_Customer_Block_Edit_Tabs</customer_edit_tabs>
</rewrite>
</adminhtml>
</blocks>
</global>
In Yourmodule_Customer_Block_Edit_Tabs just copy and paste the Mage_Adminhtml_Block_Customer_Edit_Tabs contents (don’t forget to change the class name!), and rename _beforeToHtml() method to _prepareLayout()
b) Add the removeTab action into your layout xml (default: customer.xml):
<adminhtml_customer_edit>
<reference name="left">
<block type="adminhtml/customer_edit_tabs" name="customer_edit_tabs">
<action method="removeTab">
<name>NAME_OF_TAB</name>
</action>
</block>
</reference>
</adminhtml_customer_edit>
You can find out the NAME_OF_TAB, by inspecting the tab’s anchor () and looking for the “name” attribute.
Related
I am trying to create a custom collection page with pagination. I have created the code for the pagination in the block and can output it in the template.
However the module that I am creating has pages that have other templates with no pagination.
How it works: User goes to index.php/styles/choose/items and selects the attributes/categories of the products he wants to display. He clicks on submit and is redirected to index.php/styles/choose/products where he can see the products and pagination.
In my styles.xml I have
<styles_choose_items>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
<reference name="content">
<block type="styles/styles" name="styles" template="styles/styles.phtml"/>
</reference>
</styles_choose_items>
<styles_choose_products>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
<reference name="content">
<block type="styles/products" name="products" template="styles/products.phtml"/>
</reference>
</styles_choose_products>
In config.xml I have :
<blocks>
<styles>
<rewrite>
<styles>Nuvo_Styles_Block_Styles</styles>
</rewrite>
<rewrite>
<products>Nuvo_Styles_Block_Products</products>
</rewrite>
</styles>
</blocks>
In the controller :
public function itemsAction()
{
$this->loadLayout();
$this->renderLayout();
}
public function productsAction()
{
$this->loadLayout();
$this->renderLayout();
}
I would really like to know what I am doing wrong. The index.php/styles/choose/items page displays correctly, however the index.php/styles/choose/products show only the template and if I try to add anything to the Products.php block it goes blank with no error.
Any help is appreciated.
Thank you!
Thank you for your feedback. I've enabled line 77 in index.php ini_set('display_errors', 1); to see the errors.
I was actually very close. There was just an error in the Products.php block file. It now works correctly.
the declaration of blocks in your config is wrong, you are not rewriting blocks, as far as I can tell. Try this:
<blocks>
<styles>
<class>Nuvo_Styles_Block</class>
</styles>
</blocks>
Also it would be useful to see Nuvo_Styles_Block_Products
I created my custom block which should replace an existing Magento block.
Wanna to replace the existing Magento block with my block on the whole site, independetly upon the page and the place where the existing Magento block exists. What should be the reference ?
Actually I have something like this:
<default>
<reference name="left">
<remove name="left.newsletter" />
<block type="newsletter/subscribe" name="newsletter" after="-" template="mynewsletter/subscribe.phtml"/>
</reference>
</default>
I remove there the default newsletter on the left and then create my newsletter block. It works but replaces only the newsletter block on the left. Wanna to use my block on the whole site in place of left.newsletter even if the block is in other references like content or right etc. What should I do ?
If you want to replace every occurance of Mage_Newsletter_Block_Subscribe with your own block My_Module_Block_Subscribe, use a class rewrite. In your modules config.xml:
<global>
<blocks>
<newsletter>
<rewrite>
<subscribe>My_Module_Block_Subscribe</subscribe>
</rewrite>
</newsletter>
</block>
</global>
But judging by your code, you actually do not have a custom block, just a custom template. You could change the template with an observer for the core_block_tohtml_before event, that calls setTemplate('mynewsletter/subscribe.phtml') on the block if its class is Mage_Newsletter_Block_Subscribe.
I'd like to add a static box under the price on each product page, but I dont want to overwrite an existing template file (e.g. catalog/product/view.phtml) to render it's child block.
I tried to add a block element via frontend/base/default/layout/local.xml
<layout version="0.1.0">
<default>
<reference name="product.info">
<block type="telllowerpricelink/linkbox" name="telllowerpricelink.linkbox" template="telllowerpricelink/link.phtml" before="product.description" output="toHtml" />
</reference>
</default>
</layout>
Then i built a rudimental module:
app/code/local/MyPackage/TellLowerPriceLink/Block/LinkBox.php
<?php
class MyPackage_TellLowerPriceLink_Block_Link extends Mage_Core_Block_Template
{
}
?>
app/code/local/MyPackage/TellLowerPriceLink/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<MyPackage_TellLowerPriceLink>
<version>0.1.0</version>
</MyPackage_TellLowerPriceLink>
</modules>
<global>
<blocks>
<mypackage_telllowerpricelink>
<class>MyPackage_TellLowerPriceLink_Block</class>
</mypackage_telllowerpricelink>
</blocks>
</global>
</config>
And my templatefile:
design/frontend/base/default/template/telllowerpricelink/link.phtml
<?php
echo 'Hello world!';
?>
So my questions are:
1. The main question: Is it possible to add the html-output (btw: I dont see it) at the end of the parent block element without editing its template (a la renderChildHtml)?
2. Is it possible to store my template file in this folder or have I to copy the hole default theme folder into a own theme?
Thanks a lot, I have googled and read a lot but didnt find a satisfying answer.
That's only possible with blocks derived from Mage_Core_Block_Text_List block so in your case it isn't possible but you could add your block to reference content (a container that renders all the children from layout files) and wrap your block into a div with style="display: none;" set and then move it with a javascript to the expected location.
It's possible but instead you could change the default theme in admin under system->configuration->general->design->package
The name that you will use here will be the name of your theme folder (note that this changes the theme for your entire store) so you can create your folder in desing/your_theme_name_from_admin/{layout, template} and put only files that you require to override in there. With this you could copy only the phtml file that you would like to override and change it on the new location while keeping the default copy in tact.
I'm trying to hide the price for all products in Magento for both the Product and Grid page. I created a custom module to update the layout, the config.xml is as follows:
<config>
<modules>
<ABC_XYZ>
<version>1.0</version>
</ABC_XYZ>
</modules>
<frontend>
<layout>
<updates>
<killprice>
<file>killprice.xml</file>
</killprice>
</updates>
</layout>
</frontend>
</config>
I added the killprice.xml as follows:
<layout>
<default>
<block type="catalog/product_price_template" name="catalog_product_price_template" template="killprice/price.phtml" />
</default>
<killprice_index_index>
<block type="catalog/product_price_template" name="catalog_product_price_template" template="killprice/price.phtml" />
</killprice_index_index>
</layout>
But the killprice/price.phtml is not being rendered and I get the normal price template. I am a bit suspicious about the tags in killprice.xml layout file, am I overriding the price template the right way?
This should be what you are looking for…
<layout>
<default>
<reference name="catalog_product_price_template">
<action method="addPriceBlockType"><type>simple</type><block>catalog/product_price</block><template>killerprice/price.phtml</template></action>
<!-- duplicate for each product type you need to handle i.e. change the value of the <type> node" -->
</reference>
</default>
</layout>
Have a look in Mage_Catalog_Block_Product_Abstract to see why this works
I have a custom module I wrote that is pretty basic...it just adds a small block to the footer for tracking using Media Forge. The tag it adds is different depending on whether you're on a product view page or not. This worked GREAT....until I turned on caching. Now, if you flush the cache and load a product view page, you get the correct block for the product view page. If you then go to another page (home, for instance), it still uses the product view page's block. If I flush the cache and reload the home page, it's now using the right one, but if I go to a product page now, it's using the wrong one there. So it's definitely a cache issue, I just don't understand how I'm supposed to correct this problem.
I'll paste the contents of my files below. I look forward to any responses!
Layout XML file:
<layout version="0.1.0">
<!-- DEFAULT TAG -->
<default>
<reference name="footer">
<block type="core/template" name="mediaforge_footer" as="mediaforge_footer" template="tracking/mediaforge_default.phtml"/>
</reference>
</default>
<!-- PRODUCT VIEW PAGES -->
<catalog_product_view>
<reference name="mediaforge_footer">
<action method="setTemplate"><template>tracking/mediaforge_product.phtml</template></action>
</reference>
</catalog_product_view>
</layout>
config.xml for my custom module:
<config>
<modules>
<VPS_Tracking>
<version>0.1.0</version>
</VPS_Tracking>
</modules>
<frontend>
<layout>
<updates>
<vps_tracking>
<file>vps_tracking.xml</file>
</vps_tracking>
</updates>
</layout>
</frontend>
</config>
Added this to the end of footer.phtml:
<?php echo $this->getChildHtml('mediaforge_footer'); ?>
The module definition is pretty basic and the two template files mediaforge_default.phtml and mediaforge_product.phtml are pretty simple so I won't bother including them.
Any ideas?
In a nutshell, you need to define a cache key for your block, which means you'll need to use something other than Mage_Core_Block_Template. When you create your own block, add this to the constructor:
protected function _construct() {
$this->addData(array(
'cache_lifetime' => 3600,
'cache_key' => $this->someMethodToDifferentiatePages(),
));
}
That last method needs to return a different string to every use case of the block (e.g. one for catalog pages, one for "other" if that's all you need). This will tell Magento which cached version to use
Hope that helps!
Thanks,
Joe