Please try this...
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getBaseUrl().'marketplace/vendor/selectcategory');
exit()
better way to use JavaScript:
<script type="text/javascript">location.href = '<?php echo Mage::getBaseUrl().'marketplace/vendor/selectcategory'; ?>';</script>
I think it is possible, but in some cases the question is wrong. You do not want to do this. If I'm looking at what you are trying to achieve, then this is not the right solution.
Templates should be really dumb and should not care about which class they are being applied to. Templates should contain all HTML you want to render and you should try to have the least amount of coded logic in there.
There are multiple ways to change the behaviour of template from a controller.
Solution 1: Passing variables
You can pass variables to a block that represent the result of your logic.
Controller method:
$converationId = (int) $this->getRequest()->getParam('id');
$this->loadLayout();
$block = $this->getLayout()->getBlock('.....');
if ($block) {
$block->setHasConversation( $converationId > 0 );
}
Template:
<?php if ($this->getHasConversation()): ?>
<!-- Do conversation stuff -->
<?php else: ?>
<!-- Do other stuff -->
<?php endif; ?>
Solution 2: Unset one of the blocks
Based on a condition you can unset the block you DON'T want to be show/rendered.
Your page template contains the shared HTML and the child blocks will
Layout XML:
<reference name="content">
<block type="core/template" name="mymodule_page" template="'customer/page.phtml'">
<block type="MyModule/Conversation" name="mymodule_conversation" template="'customer/conversation.phtml'"/>
<block type="MyModule/Other" name="mymodule_other" template="'customer/other.phtml'"/>
</block>
</reference>
Controller method:
$converationId = (int) $this->getRequest()->getParam('id');
$this->loadLayout();
$pageBlock = $this->getLayout()->getBlock('mymodule_page');
if ($pageBlock) {
$pageBlock->unsetChild(
($converationId > 0 ? 'mymodule_other' : 'mymodule_page')
);
}
Template customer/page.phtml
:
/** Call getChildHtml() with no param to render all children */
$this->getChildHtml();
Best Answer
Here I have a solution might work for you. We mostly use
setData()
method for pass variables from the controller to block.above
setData()
method will create a variable, and you can access this variable in the block fileblock.phtml
you created. Use below code for getting the value of the variable.