Created
August 26, 2020 19:02
-
-
Save taotiwordpress/6ce1f9239068b480056b37b2d9cf60b2 to your computer and use it in GitHub Desktop.
[text-block] Page builder text block module #pagebuilder
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 | |
namespace Modules; | |
use Timber; | |
### Example usage | |
// $args = [ | |
// 'text_block' => get_sub_field('text_block'), | |
// ]; | |
// $new_module = new TextBlock($args); | |
// $new_module->render(); | |
class TextBlock { | |
protected $defaults; | |
protected $context; | |
public function __construct( $args=[] ){ | |
$this->defaults = [ | |
'text_block' => false, | |
'classes' => [ | |
'l-module', | |
'l-container', | |
'textBlock', | |
] | |
]; | |
extract(array_merge($this->defaults, $args)); | |
$processed_content = do_shortcode( $text_block ); | |
$this->context = Timber::get_context(); | |
$this->context['content'] = $processed_content; | |
$this->context['classes'] = implode(' ', $classes); | |
} | |
public function render(){ | |
Timber::render('textBlock.twig', $this->context); | |
} | |
} |
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
.textBlock-content { | |
@include containerSmall(); | |
.wp-caption { | |
font-size: .88em; | |
p { | |
margin-top: .66rem; | |
font-size: 1rem; | |
color: $color-gray; | |
} | |
} | |
} |
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
{% block textBlock %} | |
<div class="{{ classes }}"> | |
<div class="l-inner textBlock-inner"> | |
{% if content %} | |
<div class="textBlock-content entry-content">{{ content }}</div> | |
{% endif %} | |
</div> | |
</div> | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment