Reputation: 27105
I am currently dabbling in Magento and I want know how I can create a blank Hello World file whilst still including header, footer etc. I have read How to create a simple 'Hello World' module in Magento? - however I feel that this is too much for a static page.
I want to create www.site.com/magentolocation/helloworld.php
I want a blank PHP file and rather go down the module and MVC approach can I not just do:
<?php
include magconfig;
mag->header;
echo 'hello world' // or other static html
mag->footer;
?>
Simple.
Upvotes: 0
Views: 947
Reputation: 9100
I'm sure there might be a prettier way but here is a quick snippet for you:
<?php
require_once ('app/Mage.php');
umask(0);
Mage::app('default');
Mage::getSingleton('core/session', array('name' => 'frontend'));
$Block = Mage::getSingleton('core/layout');
$head = $Block->createBlock('Page/Html_Head');
$head->addCss('css/styles.css');
$head->addJs('prototype/prototype.js');
$header = $Block->createBlock('Page/Html_Header');
$header->setTemplate('page/html/header.phtml');
$footer = $Block->createBlock('Page/Html_Footer');
$footer->setTemplate('page/html/footer.phtml');
?>
<html>
<head>
<?php echo $head->getCssJsHtml(); ?>
</head>
<body>
<?php
echo $header->toHTML();
echo 'hello world';
echo $footer->toHTML();
?>
</body>
</html>
Upvotes: 1
Reputation: 8836
http://alanstorm.com/magento_controller_hello_world http://alanstorm.com/layouts_blocks_and_templates
You want to use a template file which is a .phtml file which will let you write PHP and html, but to access it you'll have to set up a Controller. Magento is a beast which must be learned properly. There is no correct way to "escape" from the framework - you are supposed to work within the framework.
Upvotes: 4