Skip to content

Instantly share code, notes, and snippets.

@mshmsh5000
Last active December 16, 2015 05:19
Show Gist options
  • Save mshmsh5000/5383773 to your computer and use it in GitHub Desktop.
Save mshmsh5000/5383773 to your computer and use it in GitHub Desktop.
world.phtml
<?php
/**
* World / Sub-channel template. A world is defined in Magento as a category
* (only World categories should have their "Include in Navigation Menu"
* attributes set to "Yes"). In WordPress, the World must have a correspon-
* ding category that shares the same URL slug as its Magento counterpart.
* There is also a World content type in WordPress, which gets associated
* with its World category. The world has attributes and content associations
* as part of its CTD.
*
* A Sub-channel has a WordPress category and a content type, but no Magento
* representation. A Sub-channel is related to a World by (a) making its
* category a child of the World category, and (b) associating the Sub-
* channel content item with its dedicated category.
*
* Example:
*
* WORDPRESS MAGENTO
* Category: For Fun -> "for-fun" Category: For Fun -> "for-fun"
* World post -> For Fun category
*
* Category: Pop In Anytime -> "pop-in-anytime"
* (Child of "for-fun")
* Sub-channel -> Pop In Anytime category
*
* In Magento, the world page is a category page without products. This
* template, world.phtml, starts by loading the World in an omnibus
* fashion -- the world, its sub-channels, and all related content.
*
* @see Topps_Content_Helper_Data::getWorld()
*/
?>
<?php
$world = $this->helper( 'topps_content' )->getWorld();
// See sub-channel loop: This int determines position of generator in loop.
$idea_generator_position = ( isset( $world->idea_generator_section ) ) ? $world->idea_generator_section : 0;
// Social data helper.
/** @var $_social_helper Topps_Content_Helper_Social */
$_social_helper = Mage::helper( 'topps_content/social' );
?>
<?php echo $this->getChildHtml( 'worldnav' ) ?>
<div id="world">
<?php if ( !empty( $world->css_file ) && !empty( $world->css_file[ 0 ] ) && !empty( $world->css_file[ 0 ]->url ) ): ?>
<link rel="stylesheet" type="text/css" href="<?php print $world->css_file[ 0 ]->url; ?>" />
<?php endif; ?>
<!-- WORLD: TOP -->
<div id="<?php print $world->slug ?>" class="channel">
<div class="bg_wrap">
<div class="wrapper">
<?php if ( !empty( $world->hero[ 0 ] ) ): ?>
<?php $world_image = $world->hero[ 0 ]->full; ?>
<div id="hero">
<img src="<?php print $world_image->url ?>" alt="<?php print $world_image->title_plain ?>"
width="<?php print $world_image->width ?>"
height="<?php print $world_image->height ?>" />
</div>
<?php endif; ?>
</div>
<div class="main_content">
<div class="wrapper">
<div class="blocks top clear">
<!-- CONTEST ARTICLE -->
<?php if ( !empty( $world->contest_article ) ): ?>
<?php $world_contest = $world->contest_article[ 0 ]; ?>
<?php if (! empty( $world_contest->custom_css ) ): ?>
<style>
<?php print $world_contest->custom_css; ?>
</style>
<?php endif; ?>
<div class="block article contest text top<?php
if ( !empty( $world_contest->css_unique_class ) ): print ' ' . $world_contest->css_unique_class; endif; ?>">
<h3><?php print $world_contest->title; ?></h3>
<p><?php print $world_contest->excerpt; ?>
<span class="tooltip">
<span class="tip">
By submitting a photo with #myringpop, you are representing that you are the owner of the photo and granting certain rights to Topps to use this photo. For complete information, see the Photo Submission link below.
</span>
<span class="help_tip">*</span>
</span>
</p>
<?php if ( !empty( $world->contest_article[ 0 ]->external_link ) && !empty( $world->contest_article[ 0 ]->cta_text ) ): ?>
<p><a data-slug="<?php echo $world->contest_article[ 0 ]->slug ?>" href="/content/index/contests/?c=<?php echo $world->contest_article[ 0 ]->slug ?>"><?php print $world->contest_article[ 0 ]->cta_text; ?></a></p>
<?php endif; ?>
</div>
<?php endif; ?>
<!-- /CONTEST ARTICLE -->
<!-- PHOTO -->
<?php if ( !empty( $world->image_2[ 0 ] ) && !empty( $world->image_2[ 0 ]->full ) ): ?>
<?php $world_image_2 = $world->image_2[ 0 ]->full; ?>
<div class="block photo top">
<?php if ( !empty( $world->image_2_url) ): ?><a href="<?php print $world->image_2_url ?>"><?php endif; ?>
<img src="<?php print $world_image_2->url ?>" alt="<?php print $world_image_2->title_plain ?>"
width="<?php print $world_image_2->width ?>"
height="<?php print $world_image_2->height ?>" />
<?php if ( !empty( $world->image_2_url) ): ?></a><?php endif; ?>
</div>
<?php endif; ?>
<!-- /PHOTO -->
<!-- PROMO IMAGE -->
<?php if ( !empty( $world->image_3[ 0 ] ) && !empty( $world->image_3[ 0 ]->full ) ): ?>
<?php $world_image_3 = $world->image_3[ 0 ]->full; ?>
<div class="block promo top">
<?php if ( !empty( $world->image_3_url) ): ?><a href="<?php print $world->image_3_url ?>"><?php endif; ?>
<img src="<?php print $world_image_3->url ?>" alt="<?php print $world_image_3->title_plain ?>"
width="<?php print $world_image_3->width ?>"
height="<?php print $world_image_3->height ?>" />
<?php if ( !empty( $world->image_3_url) ): ?></a><?php endif; ?>
</div>
<?php endif; ?>
<!-- /PROMO IMAGE -->
<!-- ARTICLE -->
<?php if ( !empty( $world->article ) ): ?>
<?php $world_article = $world->article[ 0 ]; ?>
<?php if (! empty( $world_article->custom_css ) ): ?>
<style>
<?php print $world_article->custom_css; ?>
</style>
<?php endif; ?>
<div class="block top end article text<?php if ( !empty( $world_article->css_wrapper_class ) ): print ' ' . $world_article->css_wrapper_class; endif; ?> end">
<?php if ( isset( $world_article->display_title ) && true === $world_article->display_title ): ?>
<h3><?php print $world_article->title; ?></h3>
<?php endif; ?>
<p><?php print $world_article->excerpt; ?></p>
<?php if ( isset( $world_article->display_read_more ) && true === $world_article->display_read_more ): ?>
<p>
<a data-slug="<?php echo $world_article->slug ?>" class="cta" href="<?php print ( !empty( $world_article->custom_url ) ) ? $world_article->custom_url : $world_article->url ?>">
<?php print ( !empty( $world_article->read_more_text ) ) ? $world_article->read_more_text : 'Read more' ?></a>
</p>
<?php endif; ?>
</div>
<?php endif; ?>
<!-- /ARTICLE -->
<div class="social clear">
<ul class="clear">
<li class="facebook"><a href="<?php print $_social_helper->getFacebookShareUrl() ?>" data-service="facebook" data-width="400" data-height="285">Facebook</a></li>
<li class="twitter"><a href="<?php print $_social_helper->getTwitterShareUrl() ?>" data-service="twitter" data-width="400" data-height="350">Twitter</a></li>
<li class="pinterest"><a href="<?php print $_social_helper->getPinterestShareUrl() ?>" data-service="pinterest" data-width="700" data-height="600">Pinterest</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /WORLD: TOP -->
<?php
/* WP instructions are to set idea gen position to 1 for it to show after the world,
* >1 for each sub-channel.
*/
$subchannel_count = 1;
$idea_f_shown = false;
?>
<?php foreach ( $world->children as $slug => $subchannel ): ?>
<?php if ( $subchannel_count == $idea_generator_position ): ?>
<?php $idea_generator_shown = true; ?>
<!-- IDEA GENERATOR -->
<div id="generator" data-json-url="<?php print $world->ideas_json_url ?>" class="thin">
<div class="wrapper clear">
<div class="title">
<h3><?php print $world->idea_generator_header ?></h3>
<?php if ( !empty( $world->idea_generator_subhed ) ): ?><h4><?php print $world->idea_generator_subhed ?></h4><?php endif; ?>
</div>
<div class="idea">
<div class="msg"></div>
<a href="/customizer" class="start">Check out the customizer for a bunch of exciting options!</a>
</div>
<div class="options">
<strong class="active"><span></span></strong>
<ul></ul>
</div>
<button class="press"><strong>Press</strong></button>
</div>
</div>
<!-- /IDEA GENERATOR -->
<?php endif; ?>
<!-- Sub-channel: <?php print $subchannel->slug ?> -->
<div id="<?php print $subchannel->css_wrapper_id ?>" class="channel">
<!-- bg_wrap -->
<div class="bg_wrap">
<div class="wrapper">
<?php if ( !empty( $subchannel->content ) ): ?>
<!-- HEADER -->
<div class="header">
<h2><span><?php print $subchannel->content ?></span></h2>
</div>
<!-- /HEADER -->
<?php endif; ?>
<?php if ( !empty( $subchannel->hero ) && !empty( $subchannel->hero[ 0 ]->url ) ): ?>
<!-- HERO -->
<div class="hero">
<img src="<?php print $subchannel->hero[ 0 ]->url ?>" alt="<?php print $subchannel->hero[ 0 ]->title_plain ?>"
width="<?php print $subchannel->hero[ 0 ]->width ?>"
height="<?php print $subchannel->hero[ 0 ]->height ?>" />
</div>
<!-- /HERO -->
<?php endif; ?>
<!-- main_content -->
<div class="main_content">
<!-- blocks -->
<div class="blocks clear">
<?php if ( !empty( $subchannel->image_2 ) && !empty( $subchannel->image_2[ 0 ]->url ) ): ?>
<!-- EDITORIAL FIRST IMAGE -->
<div class="block photo">
<img src="<?php print $subchannel->image_2[ 0 ]->url ?>" alt="<?php print $subchannel->image_2[ 0 ]->title_plain ?>"
width="<?php print $subchannel->image_2[ 0 ]->width ?>"
height="<?php print $subchannel->image_2[ 0 ]->height ?>" />
</div>
<!-- /EDITORIAL FIRST IMAGE -->
<?php endif; ?>
<!-- ARTICLE -->
<?php if ( !empty( $subchannel->article ) ): ?>
<?php $sub_article = $subchannel->article[ 0 ]; ?>
<?php if (! empty( $sub_article->custom_css ) ): ?>
<style>
<?php print $sub_article->custom_css; ?>
</style>
<?php endif; ?>
<div class="block article text<?php if ( !empty( $sub_article->css_wrapper_class ) ): print ' ' . $sub_article->css_wrapper_class; endif; ?>">
<?php if ( isset( $sub_article->display_title ) && true === $sub_article->display_title ): ?>
<h3><?php print $sub_article->title; ?></h3>
<?php endif; ?>
<p><?php print $sub_article->excerpt; ?></p>
<?php if ( isset( $sub_article->display_read_more ) && true === $sub_article->display_read_more ): ?>
<p>
<a class="cta <?php if ( !empty( $sub_article->custom_url ) ): ?>ignore<?php endif; ?>"
href="<?php print ( !empty( $sub_article->custom_url ) ) ? $sub_article->custom_url : $sub_article->url ?>">
<?php print ( !empty( $sub_article->read_more_text ) ) ? $sub_article->read_more_text : 'Read more' ?></a>
</p>
<?php endif; ?>
</div>
<?php endif; ?>
<!-- /ARTICLE -->
<?php if ( !empty( $subchannel->gallery_promo ) ): ?>
<!-- GALLERY PROMO -->
<div class="block gallery">
<?php print $subchannel->gallery_promo ?>
</div>
<!-- /GALLERY PROMO -->
<?php endif; ?>
<!-- DESIGN ELEMENTS -->
<div class="design-elements">
<?php if ( !empty( $subchannel->design_elements ) ): ?>
<?php foreach ( $subchannel->design_elements as $image ): ?>
<?php if ( !empty( $image->image_file[ 0 ] ) && !empty( $image->image_file[ 0 ]->full ) ): ?>
<?php $design_element = $image->image_file[ 0 ]->full; ?>
<!-- ELEMENT -->
<div class="block element">
<?php if ( !empty( $image->click_url ) ): ?><a href="<?php print $image->click_url ?>"><?php endif; ?>
<img src="<?php print $design_element->url ?>"
width="<?php print $design_element->width ?>"
height="<?php print $design_element->height ?>"
alt="<?php print $design_element->title_plain ?>" />
<?php if ( !empty( $image->click_url ) ): ?></a><?php endif; ?>
</div>
<!-- /ELEMENT -->
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
</div>
<!-- /DESIGN ELEMENTS -->
<!-- WRAPPER IMAGE -->
<?php if ( !empty( $subchannel->wrapper_image[ 0 ] ) && !empty( $subchannel->wrapper_image[ 0 ]->image_file ) ): ?>
<?php $wrapper_image = $subchannel->wrapper_image[ 0 ]->image_file[ 0 ]->full ?>
<div class="block productwrapper">
<?php if ( !empty( $subchannel->wrapper_image[ 0 ]->click_url ) ): ?><a href="<?php print $subchannel->wrapper_image[ 0 ]->click_url ?>"><?php endif; ?>
<img src="<?php print $wrapper_image->url ?>"
width="<?php print $wrapper_image->width ?>"
height="<?php print $wrapper_image->height ?>"
alt="<?php print $wrapper_image->title_plain ?>" />
<?php if ( !empty( $subchannel->wrapper_image[ 0 ]->click_url ) ): ?></a><?php endif; ?>
</div>
<?php endif; ?>
<!-- /WRAPPER IMAGE -->
<!-- IMAGE GALLERY -->
<div class="image_gallery">
<?php if ( !empty( $subchannel->images ) ): ?>
<?php foreach ( $subchannel->images as $image ): ?>
<?php if ( !empty( $image->display_image[ 0 ] ) && !empty( $image->display_image[ 0 ]->full ) ): ?>
<?php $display_image = $image->display_image[ 0 ]->full; ?>
<!-- PHOTO -->
<div class="block photo" data-slug="<?php print $image->slug ?>">
<div class="overlay"></div>
<?php if ( !empty( $image->click_url ) ): ?><a href="<?php print $image->click_url ?>"><?php endif; ?>
<img src="<?php print $display_image->url ?>"
width="<?php print $display_image->width ?>"
height="<?php print $display_image->height ?>"
alt="<?php print $image->title_plain ?>" />
<?php if ( !empty( $image->click_url ) ): ?></a><?php endif; ?>
</div>
<!-- /PHOTO -->
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
<?php if ( !empty( $subchannel->images_json ) ): ?>
<script>
var <?php print $subchannel->css_wrapper_id_safe ?>_images_json = <?php echo $subchannel->images_json ?>;
</script>
<?php endif; ?>
<div class="images_json" data-json-url="<?php print $subchannel->images_json_url ?>"></div>
<div class="image-gallery-title" style="display: none;">
<?php if (!empty( $subchannel->gallery_title ) ): ?>
<?php print $subchannel->gallery_title ?>
<?php else: ?>
<?php print $subchannel->title ?> Images
<?php endif; ?>
</div>
</div>
<!-- /IMAGE GALLERY -->
<!-- VIDEO GALLERY -->
<div class="video_gallery">
<?php if ( !empty( $subchannel->videos_json ) ): ?>
<script>
var <?php print $subchannel->css_wrapper_id_safe ?>_videos_json = <?php echo $subchannel->videos_json ?>;
</script>
<?php endif; ?>
<div class="videos_json" data-json-url="<?php print $subchannel->video_json_url ?>"></div>
<?php if ( !empty( $subchannel->videos ) ): ?>
<?php foreach ( $subchannel->videos as $video ): ?>
<?php if ( !empty( $video->video ) && is_object( $video->thumbnail[ 0 ] ) ): ?>
<?php $video_thumb = $video->thumbnail[ 0 ]->full; ?>
<!-- VIDEO -->
<div class="block video" data-slug="<?php print $video->slug ?>">
<!-- This is the embeddable URL. -->
<a class="ignore_ajax" href="<?php print $video->embed ?>"><img src="<?php print $video_thumb->url ?>"
width="<?php print $video_thumb->width ?>"
height="<?php print $video_thumb->height ?>"
alt="<?php print $video_thumb->title_plain ?>" /></a>
</div>
<!-- /VIDEO -->
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
</div>
<!-- /VIDEO GALLERY -->
</div>
<!-- /blocks -->
</div>
<!-- /main_content -->
</div>
<!-- /wrapper -->
</div>
<!-- /bg_wrap -->
</div>
<!-- /Sub-channel: <?php print $subchannel->slug ?> -->
<?php $subchannel_count++ ?>
<?php endforeach; ?>
<?php /* Catch-all: If the idea generator's position setting has value that's kept it
* from displaying yet, show it now.
*/
?>
<?php if ( !$idea_generator_shown ): ?>
<!-- IDEA GENERATOR -->
<div id="generator" data-json-url="<?php print $world->ideas_json_url ?>" class="thin">
<div class="wrapper clear">
<div class="title">
<h3><?php print $world->idea_generator_header ?></h3>
<?php if ( !empty( $world->idea_generator_subhed ) ): ?><h4><?php print $world->idea_generator_subhed ?></h4><?php endif; ?>
</div>
<div class="idea">
<div class="msg"></div>
<a href="/customizer" class="start">Check out the customizer for a bunch of exciting options!</a>
</div>
<div class="options">
<strong class="active"><span></span></strong>
<ul></ul>
</div>
<button class="press"><strong>Press</strong></button>
</div>
</div>
<!-- /IDEA GENERATOR -->
<?php endif; ?>
</div> <!-- /world -->
<?php /* Additional content that we haven't incorporated into sub-channels */ ?>
<!--
<!-- FACEBOOK - - >
<?php echo $this->getChildHtml( 'facebook' ) ?>
<!-- PINTEREST - - >
<?php echo $this->getChildHtml( 'pinterest' ) ?>
-->
<!-- IDEA GENERATOR -->
<?php //echo $this->getChildHtml( 'ideagenerator' ) ?>
<div class="modal" id="lightbox_media">
<div class="top clear"><span class="close">Press ESC or</span></div>
<div class="inner">
<div class="contents clear"></div>
<div class="social">
<ul class="clear">
<li class="facebook"><a href="#" data-service="facebook" data-width="400" data-height="285">Facebook</a></li>
<li class="twitter"><a href="#" data-service="twitter" data-width="400" data-height="350">Twitter</a></li>
<li class="pinterest"><a href="#" data-service="pinterest" data-width="700" data-height="600">Pinterest</a></li>
</ul>
</div>
<div class="loader">Loading...</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment