Created
March 13, 2011 16:57
-
-
Save raybrownco/868254 to your computer and use it in GitHub Desktop.
This file is a comparison between WordPress/Pods and ExpressionEngine. It shows the syntax required to display a list of three featured books on a site's homepage.
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
<!-- Featuring three books on a site's homepage --> | |
<!-- The Pods/WordPress way --> | |
<ul id="featured-books"> | |
<?php | |
$book = new Pod('book'); | |
$params = array( | |
'where'=>'t.show_on_homepage = 1', | |
'limit'=>3, | |
'orderby'=>'t.release_date DESC' | |
); | |
$book->findRecords($params); | |
if($book->getTotalRows() > 0) | |
{ | |
while($book->fetchRecord()) : | |
$title = $book->get_field('title'); | |
$subtitle = $book->get_field('sub_title'); | |
$cover = $book->get_field('cover'); | |
$description = $book->get_field('description'); | |
$buyingOptions = $book->get_field('buying_options'); | |
$buyingOptionLinks = array(); | |
if($buyingOptions) | |
{ | |
$buyingOptionsArray = explode("\n", $buyingOptions); | |
foreach($buyingOptionsArray as $buyingOption) | |
{ | |
$linkArray = explode('|', $buyingOption); | |
$link = '<li class="'. trim('_'.$linkArray[0]) .' icon replace"><a href="'. trim($linkArray[1]) .'" target="_blank"><span>'. trim($linkArray[0]) .'</span></a></li>'; | |
array_push($buyingOptionLinks, $link); | |
} | |
} | |
?> | |
<li class="book"> | |
<?php if($cover) { ?> | |
<h1><?=$title;?></h1> | |
<h2><?=$subtitle;?></h2> | |
<div class="cover"> | |
<?php | |
if($buyingOptionsArray) { | |
$linkArray = explode('|', $buyingOptionsArray[0]); | |
?> | |
<a href="<?php echo $linkArray[1]; ?>" target="_blank"> | |
<img src="<?php echo $cover[0]['guid']; ?>" alt="<?=$title;?>" /><br/> | |
<span class="purchase-text">Purchase Book</span> | |
</a> | |
<?php } else { ?> | |
<img src="<?php echo $cover[0]['guid']; ?>" alt="<?=$title;?>" /> | |
<?php } ?> | |
</div> | |
<?php } ?> | |
<div class="description"><?=$description;?></div> | |
</li> | |
<?php | |
endwhile; | |
} | |
?> | |
</ul> | |
<!-- The ExpressionEngine way --> | |
<ul id="featured-books"> | |
{exp:channel:entries channel="books" search:show_on_homepage="=yes" limit="3" orderby="release_date" sort="desc"} | |
<li class="book"> | |
<h1>{title}</h1> | |
<h2>{subtitle}</h2> | |
<div class="cover"> | |
{if buying_options} | |
{buying_options limit="1"} | |
<a href="{link}" target="_blank"> | |
<img src="{cover_thumbnail}" alt="{title}" /><br/> | |
<span class="purchase-text">Purchase Book</span> | |
</a> | |
{/buying-options} | |
{if:else} | |
<img src="{cover_thumbnail}" alt="{title}" /> | |
{/if} | |
</div> | |
<div class="description">{description}</div> | |
</li> | |
{/exp:channel:entries} | |
</ul> |
Also, to revisit this, Pods 2.x syntax is cleaner, more efficient, and less coding work than Pods 1.x as shown above.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just now saw this, I think if you put into account the Pods templating engine (using {@field_name} tags instead of PHP) and WordPress shortcodes, the end result is a lot less PHP and actual coding and it looks a heck of a lot like EE.