wickywills
10/26/2017 - 8:32 AM

Custom fields within Fishpig/Magento

$post = $this->getPost();
$postContent = $post->getPostContent();

if( $post->getMetaValue('fields') ) :
    $_fields        = $post->getMetaValue('fields');
    $postTitle      = $post->getData('post_title');
    $_helper        = $this->helper('catalog/output');
    $_filterHelper  = $this->helper('wordpress/filter');


    // If "hide title" in the admin is selected, then hide it!
    if( !$post->getMetaValue('hide_title') ) :
        echo '<h1 class="landingpage__title">'.$postTitle.'</h1>';
    endif;


    // Get the brand colour
    $brandColour = $post->getMetaValue('primary_brand_colour');
    
    
    // Output the standard page content
    echo $postContent;


    // Loop through each of the repeater fields and output accordingly
    foreach ($_fields as $_field) :
        switch ($_field['type']) : 


            /**
             * VIDEO
             * Just a big 'ol video
             */
            case 'video':
                $videoSrc = $_field['video'];

                echo    '<div class="landingpage__block">'.
                            '<div class=" landingpage__video embed-container">'.
                                $videoSrc.
                            '</div>'.
                        '</div>';
                break;


            /**
             * INTRO
             * Title with yellow line through it, and a brief intro
             */
            case 'intro':
                $title = $_field['intro_title'];
                $intro = $_field['intro'];

                if( $brandColour ) :
                    echo '<style>.landingpage__intro h2:before{ background: '.$brandColour.' }</style>';
                endif;

                echo    '<div class="landingpage__block">'.
                            '<div class="landingpage__intro">'.
                                '<h2><span>'.$title.'</span></h2>'.
                                '<div class="landingpage__intro-content">'.$intro.'</div>'.
                            '</div>'.
                        '</div>';
                break;


        endswitch;
    endforeach;
endif;