SlideShare a Scribd company logo
by kiang @ phpconf taiwan 2013
Magento Extension
Who is kiang?
● Google “Finjon Kiang”
→ About 85,100 results (0.27 seconds) @ 00:42 today
● Taiwan PHP User Group
→ http://twpug.net
● Just This Computer Studio
→ http://olc.tw
● Just Play
→ http://travel.olc.tw
Why English?
Because my English is poor.
I need more practices,
Sorry for those who hate English.
Why Magento?
● 169,571 live websites using Magento today
→ http://trends.builtwith.com/shop/Magento
● Magento ran on 11% of the top 10K sites
→ http://trends.builtwith.com/shop
● Some customers said
“Hey, we want to use Magento”
...This is a real life
<?php echo 'hello world';
<?php echo 'hello world';
app/etc/modules/Olctw_Phpconf.xml
<?xml version="1.0"?>
<config>
<modules>
<Olctw_Phpconf>
<active>true</active>
<codePool>community</codePool>
</Olctw_Phpconf>
</modules>
</config>
<?php echo 'hello world';
app/code/
→ core
→ community
→ local
<?php echo 'hello world';
app/code/community/Olctw/Phpconf/
→ etc/config.xml
→ controllers/IndexController.php
<?php echo 'hello world';
etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<frontend>
<routers>
<phpconf>
<use>standard</use>
<args>
<module>Olctw_Phpconf</module>
<frontName>phpconf</frontName>
</args>
</phpconf>
</routers>
</frontend>
</config>
<?php echo 'hello world';
controllers/IndexController.php
<?php
class Olctw_Phpconf_IndexController extends
Mage_Core_Controller_Front_Action {
public function indexAction() {
echo 'hello world';
}
}
<?php echo 'hello world';
<?php echo 'hello world';
controllers/IndexController.php
$this->loadLayout();
$block = $this->getLayout()->createBlock('core/text')-
>setText('hello world');
$this->getLayout()->getBlock('content')->append($block);
$this->renderLayout();
<?php echo 'hello world';
<?php echo 'hello world';
Move 'hello world' from controller to block
<?php echo 'hello world';
etc/config.xml
<global>
<blocks>
<Olctw_Phpconf>
<class>Olctw_Phpconf_Block</class>
</Olctw_Phpconf>
</blocks>
</global>
<?php echo 'hello world';
app/code/community/Olctw/Phpconf/
→ Block/Hello.php
<?php echo 'hello world';
Block/Hello.php
<?php
class Olctw_Phpconf_Block_Hello extends
Mage_Core_Block_Template {
protected function _toHtml() {
return 'hello world';
}
}
<?php echo 'hello world';
controllers/IndexController.php
$block = $this->getLayout()->createBlock('core/text')-
>setText('hello world');
→
$block = $this->getLayout()-
>createBlock('Olctw_Phpconf/hello');
<?php echo 'hello world';
put 'hello world' block into layout
<?php echo 'hello world';
controllers/IndexController.php
public function indexAction() {
$this->loadLayout();
$this->renderLayout();
}
<?php echo 'hello world';
etc/config.xml
<config>
<frontend>
<layout>
<updates>
<Olctw_Phpconf>
<file>olctw_phpconf.xml</file>
</Olctw_Phpconf>
</updates>
</layout>
</frontend>
</config>
<?php echo 'hello world';
app/design/frontend/base/default/layout/
→ olctw_phpconf.xml
<?php echo 'hello world';
olctw_phpconf.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<phpconf_index_index>
<reference name="content">
<block type="Olctw_Phpconf/hello"></block>
</reference>
</phpconf_index_index>
</layout>
<?php echo 'hello world';
move 'hello world' to template
<?php echo 'hello world';
olctw_phpconf.xml
<block type="Olctw_Phpconf/hello"
template="olctw_phpconf/hello.phtml"></block>
<?php echo 'hello world';
app/design/frontend/base/default/template/
→ olctw_phpconf/hello.phtml
<?php echo 'hello world';
olctw_phpconf/hello.phtml
hello world
<?php echo 'hello world';
Block/Hello.php
<?php
class Olctw_Phpconf_Block_Hello extends
Mage_Core_Block_Template {
}
<?php echo 'hello world';
Interaction between block and template
<?php echo 'hello world';
Block/Hello.php
public function getStoreName() {
return Mage::app()->getStore()->getName();
}
<?php echo 'hello world';
olctw_phpconf/hello.phtml
hello world @ <?php echo $this->getStoreName(); ?>
<?php echo 'hello world';

More Related Content

Similar to Magento phpconf 2013

Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014
Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014
Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014
David Yell
 
Frappe Open Day - September 2018
Frappe Open Day - September 2018Frappe Open Day - September 2018
Frappe Open Day - September 2018
Frappe Technologies Pvt. Ltd.
 
Going Global - WordPress Multilingual
Going Global - WordPress MultilingualGoing Global - WordPress Multilingual
Going Global - WordPress Multilingual
Amit Kvint
 
Make web as webapp
Make web as webappMake web as webapp
Make web as webapp
Fred Lin
 
Google App Engine Overview - BarCamp Phnom Penh 2011
Google App Engine Overview - BarCamp Phnom Penh 2011Google App Engine Overview - BarCamp Phnom Penh 2011
Google App Engine Overview - BarCamp Phnom Penh 2011
traactivity
 
Vietnam qa meetup
Vietnam qa meetupVietnam qa meetup
Vietnam qa meetup
Syam Sasi
 
Enterprise PHP Development - ZendCon 2008
Enterprise PHP Development - ZendCon 2008Enterprise PHP Development - ZendCon 2008
Enterprise PHP Development - ZendCon 2008
Ivo Jansch
 
Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...
IT Event
 
I18n of java script
I18n of java scriptI18n of java script
I18n of java script
Junichi Shinohara
 
Magento 2 Seminar - Welkom
Magento 2 Seminar - WelkomMagento 2 Seminar - Welkom
Magento 2 Seminar - Welkom
Yireo
 
Why Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your ClientsWhy Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your Clients
Pantheon
 
Meet Magento - the open source that is changing the world of commerce
Meet Magento - the open source that is changing the world of commerceMeet Magento - the open source that is changing the world of commerce
Meet Magento - the open source that is changing the world of commerce
Kuba Zwolinski
 
Alexandr Vronskiy "Evolution of Ecommerce Application"
Alexandr Vronskiy "Evolution of Ecommerce Application"Alexandr Vronskiy "Evolution of Ecommerce Application"
Alexandr Vronskiy "Evolution of Ecommerce Application"
Fwdays
 
PHP Berkshire October 2015
PHP Berkshire October 2015PHP Berkshire October 2015
PHP Berkshire October 2015
David Yell
 
Understanding Technologies - Presentation for College Students
Understanding Technologies - Presentation for College StudentsUnderstanding Technologies - Presentation for College Students
Understanding Technologies - Presentation for College Students
Ketan Raval
 
Minimizing Magento Upgrade Downtime - Oleksandr Zarichnyi - Imagine Commerce ...
Minimizing Magento Upgrade Downtime - Oleksandr Zarichnyi - Imagine Commerce ...Minimizing Magento Upgrade Downtime - Oleksandr Zarichnyi - Imagine Commerce ...
Minimizing Magento Upgrade Downtime - Oleksandr Zarichnyi - Imagine Commerce ...
Oleksandr Zarichnyi
 
Magento on HHVM. Daniel Sloof
Magento on HHVM. Daniel SloofMagento on HHVM. Daniel Sloof
Magento on HHVM. Daniel Sloof
MeetMagentoNY2014
 
Headless E-commerce That People Love
Headless E-commerce That People LoveHeadless E-commerce That People Love
Headless E-commerce That People Love
DigitalOcean
 
Mobile html5 today
Mobile html5 todayMobile html5 today
Mobile html5 today
Ido Green
 
Ashfaq Ahmed PHP-Java Developer-updated
Ashfaq Ahmed PHP-Java Developer-updatedAshfaq Ahmed PHP-Java Developer-updated
Ashfaq Ahmed PHP-Java Developer-updated
Ashfaq Ahmed
 

Similar to Magento phpconf 2013 (20)

Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014
Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014
Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014
 
Frappe Open Day - September 2018
Frappe Open Day - September 2018Frappe Open Day - September 2018
Frappe Open Day - September 2018
 
Going Global - WordPress Multilingual
Going Global - WordPress MultilingualGoing Global - WordPress Multilingual
Going Global - WordPress Multilingual
 
Make web as webapp
Make web as webappMake web as webapp
Make web as webapp
 
Google App Engine Overview - BarCamp Phnom Penh 2011
Google App Engine Overview - BarCamp Phnom Penh 2011Google App Engine Overview - BarCamp Phnom Penh 2011
Google App Engine Overview - BarCamp Phnom Penh 2011
 
Vietnam qa meetup
Vietnam qa meetupVietnam qa meetup
Vietnam qa meetup
 
Enterprise PHP Development - ZendCon 2008
Enterprise PHP Development - ZendCon 2008Enterprise PHP Development - ZendCon 2008
Enterprise PHP Development - ZendCon 2008
 
Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...
 
I18n of java script
I18n of java scriptI18n of java script
I18n of java script
 
Magento 2 Seminar - Welkom
Magento 2 Seminar - WelkomMagento 2 Seminar - Welkom
Magento 2 Seminar - Welkom
 
Why Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your ClientsWhy Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your Clients
 
Meet Magento - the open source that is changing the world of commerce
Meet Magento - the open source that is changing the world of commerceMeet Magento - the open source that is changing the world of commerce
Meet Magento - the open source that is changing the world of commerce
 
Alexandr Vronskiy "Evolution of Ecommerce Application"
Alexandr Vronskiy "Evolution of Ecommerce Application"Alexandr Vronskiy "Evolution of Ecommerce Application"
Alexandr Vronskiy "Evolution of Ecommerce Application"
 
PHP Berkshire October 2015
PHP Berkshire October 2015PHP Berkshire October 2015
PHP Berkshire October 2015
 
Understanding Technologies - Presentation for College Students
Understanding Technologies - Presentation for College StudentsUnderstanding Technologies - Presentation for College Students
Understanding Technologies - Presentation for College Students
 
Minimizing Magento Upgrade Downtime - Oleksandr Zarichnyi - Imagine Commerce ...
Minimizing Magento Upgrade Downtime - Oleksandr Zarichnyi - Imagine Commerce ...Minimizing Magento Upgrade Downtime - Oleksandr Zarichnyi - Imagine Commerce ...
Minimizing Magento Upgrade Downtime - Oleksandr Zarichnyi - Imagine Commerce ...
 
Magento on HHVM. Daniel Sloof
Magento on HHVM. Daniel SloofMagento on HHVM. Daniel Sloof
Magento on HHVM. Daniel Sloof
 
Headless E-commerce That People Love
Headless E-commerce That People LoveHeadless E-commerce That People Love
Headless E-commerce That People Love
 
Mobile html5 today
Mobile html5 todayMobile html5 today
Mobile html5 today
 
Ashfaq Ahmed PHP-Java Developer-updated
Ashfaq Ahmed PHP-Java Developer-updatedAshfaq Ahmed PHP-Java Developer-updated
Ashfaq Ahmed PHP-Java Developer-updated
 

Recently uploaded

GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 

Recently uploaded (20)

GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 

Magento phpconf 2013

  • 1. by kiang @ phpconf taiwan 2013 Magento Extension
  • 2. Who is kiang? ● Google “Finjon Kiang” → About 85,100 results (0.27 seconds) @ 00:42 today ● Taiwan PHP User Group → http://twpug.net ● Just This Computer Studio → http://olc.tw ● Just Play → http://travel.olc.tw
  • 3. Why English? Because my English is poor. I need more practices, Sorry for those who hate English.
  • 4. Why Magento? ● 169,571 live websites using Magento today → http://trends.builtwith.com/shop/Magento ● Magento ran on 11% of the top 10K sites → http://trends.builtwith.com/shop ● Some customers said “Hey, we want to use Magento” ...This is a real life
  • 6. <?php echo 'hello world'; app/etc/modules/Olctw_Phpconf.xml <?xml version="1.0"?> <config> <modules> <Olctw_Phpconf> <active>true</active> <codePool>community</codePool> </Olctw_Phpconf> </modules> </config>
  • 7. <?php echo 'hello world'; app/code/ → core → community → local
  • 8. <?php echo 'hello world'; app/code/community/Olctw/Phpconf/ → etc/config.xml → controllers/IndexController.php
  • 9. <?php echo 'hello world'; etc/config.xml <?xml version="1.0" encoding="UTF-8"?> <config> <frontend> <routers> <phpconf> <use>standard</use> <args> <module>Olctw_Phpconf</module> <frontName>phpconf</frontName> </args> </phpconf> </routers> </frontend> </config>
  • 10. <?php echo 'hello world'; controllers/IndexController.php <?php class Olctw_Phpconf_IndexController extends Mage_Core_Controller_Front_Action { public function indexAction() { echo 'hello world'; } }
  • 11. <?php echo 'hello world';
  • 12. <?php echo 'hello world'; controllers/IndexController.php $this->loadLayout(); $block = $this->getLayout()->createBlock('core/text')- >setText('hello world'); $this->getLayout()->getBlock('content')->append($block); $this->renderLayout();
  • 13. <?php echo 'hello world';
  • 14. <?php echo 'hello world'; Move 'hello world' from controller to block
  • 15. <?php echo 'hello world'; etc/config.xml <global> <blocks> <Olctw_Phpconf> <class>Olctw_Phpconf_Block</class> </Olctw_Phpconf> </blocks> </global>
  • 16. <?php echo 'hello world'; app/code/community/Olctw/Phpconf/ → Block/Hello.php
  • 17. <?php echo 'hello world'; Block/Hello.php <?php class Olctw_Phpconf_Block_Hello extends Mage_Core_Block_Template { protected function _toHtml() { return 'hello world'; } }
  • 18. <?php echo 'hello world'; controllers/IndexController.php $block = $this->getLayout()->createBlock('core/text')- >setText('hello world'); → $block = $this->getLayout()- >createBlock('Olctw_Phpconf/hello');
  • 19. <?php echo 'hello world'; put 'hello world' block into layout
  • 20. <?php echo 'hello world'; controllers/IndexController.php public function indexAction() { $this->loadLayout(); $this->renderLayout(); }
  • 21. <?php echo 'hello world'; etc/config.xml <config> <frontend> <layout> <updates> <Olctw_Phpconf> <file>olctw_phpconf.xml</file> </Olctw_Phpconf> </updates> </layout> </frontend> </config>
  • 22. <?php echo 'hello world'; app/design/frontend/base/default/layout/ → olctw_phpconf.xml
  • 23. <?php echo 'hello world'; olctw_phpconf.xml <?xml version="1.0"?> <layout version="0.1.0"> <phpconf_index_index> <reference name="content"> <block type="Olctw_Phpconf/hello"></block> </reference> </phpconf_index_index> </layout>
  • 24. <?php echo 'hello world'; move 'hello world' to template
  • 25. <?php echo 'hello world'; olctw_phpconf.xml <block type="Olctw_Phpconf/hello" template="olctw_phpconf/hello.phtml"></block>
  • 26. <?php echo 'hello world'; app/design/frontend/base/default/template/ → olctw_phpconf/hello.phtml
  • 27. <?php echo 'hello world'; olctw_phpconf/hello.phtml hello world
  • 28. <?php echo 'hello world'; Block/Hello.php <?php class Olctw_Phpconf_Block_Hello extends Mage_Core_Block_Template { }
  • 29. <?php echo 'hello world'; Interaction between block and template
  • 30. <?php echo 'hello world'; Block/Hello.php public function getStoreName() { return Mage::app()->getStore()->getName(); }
  • 31. <?php echo 'hello world'; olctw_phpconf/hello.phtml hello world @ <?php echo $this->getStoreName(); ?>
  • 32. <?php echo 'hello world';