Jump to content


Photo
- - - - -

Output linebreaks

sections

  • Please log in to reply
2 replies to this topic

#1 bluecloud

bluecloud

    Advanced Member

  • Members
  • 44 posts
  • LocationHillegom
  • Framework Version:latest (always)
  • Country: Country Flag

Posted 13 December 2013 - 01:58 PM

In a custom section I have a textarea option. When I enter some text in the textarea and do some linebreaks, I see them in the DMS editor, but they are gone on the output.

 

How do I keep these linebreaks on the output? I have now:

 
function section_template() {
    printf( '
            <div class="row">
                <div class="span4">%1$s</div>
                <div class="span6"><p>%2$s</p></div>
            </div>',
            $this->build_menu(),
            $this->opt( 'my_text' ), // This my textarea 
           
   );
}


#2 Danny

Danny

    Is Awesome!

  • Moderators
  • 17533 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 13 December 2013 - 02:07 PM

Hi,

 

Can you add your whole custom sections code (full section.php file) to your reply, so I can try myself please.

 

Also, try viewing our developer docs which has information on how to add text areas etc. - http://docs.pageline...s-option-engine

 

Like so:

 

 $opts[] = array(
            'key'           => 'some_key',
            'type'          => 'textarea', 
        );


#3 bluecloud

bluecloud

    Advanced Member

  • Members
  • 44 posts
  • LocationHillegom
  • Framework Version:latest (always)
  • Country: Country Flag

Posted 13 December 2013 - 02:10 PM

Here it is:

 
<?php
/**
Section: Sub Header
Author: Blue Cloud
Author URI: http://www.bluecloudcompany.com
Description: Een subheader met daarin een menu en een tekstblok
Version: 1.0.0
Class Name: EGS_SubHeader
Filter: Component
*/


class EGS_SubHeader extends PageLinesSection {


    function section_persistent() {

        // Put code that should always be loaded here.
        $url = $this->base_url; // the base url of the section
        $dir = $this->base_dir; // the base directory of the section

    }




    function section_opts() {

        $opts = array(
            array (
                'key'           => 'subheader_menu',
                'type'          => 'select_menu',
                'title'         => __('Sub Menu', 'erfgoedspoor'),
                'label'			=> __( 'Selecteer menu', 'erfgoedspoor' )
            ),
            array(
				'key'			=> 'subheader_title',
				'type'			=> 'text',
                'title'         => __( 'Titel', 'erfgoedspoor'),
				'label'			=> __( 'Titel in de Sub Header', 'erfgoedspoor' ),
            ),
            array(
				'key'			=> 'subheader_text',
				'type'			=> 'textarea',
                'title'         => __( 'Tekstblok', 'erfgoedspoor'),
				'label'			=> __( 'Tekst in de Sub Header', 'erfgoedspoor' ),
            ),
        );
        return $opts;

    }



    function section_styles() {

    }



    function section_head(){

        // This will out put in between your sites <head> tags.
        // For example, adding javascript:
        ?>
        <script>
            jQuery(window).ready(function() {
                // Javascript could go here.
            });
        </script>
        <?php

    }




    function section_template() {

        printf( '
            <div class="row">
                <div class="span4">%3$s</div>
                <div class="span6 subheader-text"><h5>%2$s</h5><p>%1$s</p></div>
            </div>',
            $this->opt( 'subheader_text' ),
            $this->opt( 'subheader_title' ),
            $this->build_menu()
        );

    }


    /**
     * Build the menu
     * @return string
     */
    private function build_menu( ) {

        $menu = $this->opt( 'subheader_menu');
        $menu_list = '';
        $menu_items = wp_get_nav_menu_items( $menu );

        $menu_list .= '<ul class="subheader-menu unstyled">';

        foreach( (array)$menu_items as $menu_item ) {

            $title = $menu_item->title;
            $url = $menu_item->url;
            $menu_list .= '<li><a class="" href="'.$url.'">' . $title . '</a></li>';

        }

        $menu_list .= '</ul>';

        return $menu_list;
    }





}






Also tagged with one or more of these keywords: sections