Last active
August 29, 2015 13:56
-
-
Save syphoxy/ca50983aa32daaaf7e1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Your mixed HTML+PHP page script (pseudo-code) --> | |
<?php mysql_connect(/* database details */) ?> | |
<?php $result = mysql_query(/* get current page from db */) ?> | |
<?php $page = mysql_fetch_assoc($result) ?> | |
<html> | |
<head> | |
<title><?php echo htmlentities($page['title']) ?></title> | |
</head> | |
<body> | |
<h1><?php echo htmlentities($page['title']) ?></h1> | |
<ul> | |
<?php $result = mysql_query(/* SQL Query */) ?> | |
<?php while($row = mysql_fetch_assoc($result)): ?> | |
<li><?php echo htmlentities($row['title']) ?></li> | |
<?php end ?> | |
</ul> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Your Post Model Class (pseudo-code) | |
class PostModel extends ModelAbstract | |
{ | |
// model specific code here | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Your Index Controller Class (pseudo-code) | |
class IndexController extends ControllerAbstract | |
{ | |
public function showAction($request) | |
{ | |
// call on Post model to get by ID | |
$post = new PostModel($request->id); | |
// expost post to view script | |
$this->view->post = $post; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Your controller action template (pseudo-code) --> | |
<html> | |
<head> | |
<title><?php echo htmlentities($this->post->title) ?></title> | |
</head> | |
<body> | |
<h1><?php echo htmlentities($this->post->title) ?></h1> | |
<p><?php echo $this->post->content ?></p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<config> | |
<modules> | |
<NAMESPACE_Twitter> | |
<active>true</active> | |
<codePool>local</codePool> | |
</NAMESPACE_Twitter> | |
</modules> | |
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<config> | |
<modules> | |
<NAMESPACE_Twitter> | |
<version>0.0.1</version> | |
</NAMESPACE_Twitter> | |
</modules> | |
<global> | |
<blocks> | |
<twitter> | |
<class>NAMESPACE_Twitter_Block</class> | |
</twitter> | |
</blocks> | |
</global> | |
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class NAMESPACE_Twitter_Block_Timeline extends Mage_Core_Block_Template | |
{ | |
public function getTimeline($username, $limit) | |
{ | |
$tweets = array(); | |
// code to get tweets here | |
return $tweets; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- let's add a block to our layout that defines | |
where to inject our twitter widget --> | |
<catalog_product_view> | |
<reference name='product.info'> | |
<block type='twitter/timeline' name='product.info.twitter.timeline' as='product.view.twitter.timeline' template='catalog/product/view/twitter/timeline.phtml' /> | |
</reference> | |
</catalog_product_view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id='twitter-timeline'> | |
<?php foreach ($this->getTimeline('demacmedia', 2) as $tweet): ?> | |
<div class='tweet'><?php echo $tweet['text'] ?></div> | |
<?php end ?> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php echo $this->getChildHtml('product.info.twitter.timeline') ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment