Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #840004

    I’ve got a custom element in the Avia Layout Builder that I’m needing to add link text to.
    Meaning that every time a link is added, I’d like “Know More” text to display under the description.
    Can anyone give me a hand?
    Thanks!!
    The current code for the custom block is:

    <?php
    
    /**
     * Slider
     * Shortcode that allows to slide some content
     */
    if (!class_exists('avia_sc_offerings_blocks')) {
    
        class avia_sc_offerings_blocks extends aviaShortcodeTemplate {
    
            /**
             * Create the config array for the shortcode button
             */
            function shortcode_insert_button() {
                $this->config['name'] = __('Offerings Block', 'avia_framework');
                $this->config['tab'] = __('Custom Blocks', 'avia_framework');
                $this->config['icon'] = AviaBuilder::$path['imagesURL'] . "sc-contentslider.png";
                $this->config['order'] = 83;
                $this->config['target'] = 'avia-target-insert';
                $this->config['shortcode'] = 'av_offerings_block';
                $this->config['shortcode_nested'] = array('avia_offerings_block');
                $this->config['tooltip'] = __('Display a content slider element', 'avia_framework');
            }
    
            /**
             * Popup Elements
             *
             * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
             * opens a modal window that allows to edit the element properties
             *
             * @return void
             */
            function popup_elements() {
                $this->elements = array(
                    array(
                        "type" => "tab_container", 'nodescription' => true
                    ),
                    array(
                        "type" => "tab",
                        "name" => __("Content", 'avia_framework'),
                        'nodescription' => true
                    ),
                    array(
                        "name" => __("Add/Edit Blocks", 'avia_framework'),
                        "desc" => __("Here you can add, remove and edit the blocks you want to display.", 'avia_framework'),
                        "type" => "modal_group",
                        "id" => "content",
                        "modal_title" => __("Edit Form Element", 'avia_framework'),
                        "std" => array(
                            array('title' => __('Block 1', 'avia_framework'), 'tags' => '')
                        ),
                        'subelements' => array(
                            array(
                                "name" => __("Block Title", 'avia_framework'),
                                "desc" => __("Enter the block title here (Better keep it short)", 'avia_framework'),
                                "id" => "title",
                                "std" => "Block Title",
                                "type" => "input"),
                            array(
                                "name" => __("Title Link?", 'avia_framework'),
                                "desc" => __("Where should your title link to?", 'avia_framework'),
                                "id" => "link",
                                "type" => "linkpicker",
                                "fetchTMPL" => true,
                                "std" => "",
                                "subtype" => array(
                                    __('No Link', 'avia_framework') => '',
                                    __('Set Manually', 'avia_framework') => 'manually',
                                    __('Single Entry', 'avia_framework') => 'single',
                                    __('Taxonomy Overview Page', 'avia_framework') => 'taxonomy',
                                ),
                                "std" => ""),
                            array(
                                "name" => __("Open in new window", 'avia_framework'),
                                "desc" => __("Do you want to open the link in a new window", 'avia_framework'),
                                "id" => "linktarget",
                                "required" => array('link', 'not', ''),
                                "type" => "select",
                                "std" => "",
                                "subtype" => AviaHtmlHelper::linking_options()),
                            array(
                                "name" 	=> __("Description",'avia_framework' ),
                                "desc" 	=> __("Enter description",'avia_framework' ),
                                "id" 	=> "content",
                                "type" 	=> "textarea",
                                "std" 	=> ""
                                ),
                            array(
                                "name" => __("Choose Image", 'avia_framework'),
                                "desc" => __("Either upload a new, or choose an existing image from your media library", 'avia_framework'),
                                "id" => "src",
                                "type" => "image",
                                "title" => __("Insert Image", 'avia_framework'),
                                "button" => __("Insert", 'avia_framework'),
                                "std" => AviaBuilder::$path['imagesURL'] . "placeholder.jpg"),
                        )
                    ),
                    array(
                        "name" => __("Heading", 'avia_framework'),
                        "desc" => __("Do you want to display a heading above the images?", 'avia_framework'),
                        "id" => "heading",
                        "type" => "input",
                        "std" => "",
                    ),
                    array(
                        "name" => __("CSS ID", 'avia_framework'),
                        "desc" => __("Custom ID for the block container", 'avia_framework'),
                        "id" => "css_id",
                        "type" => "input",
                        "std" => "",
                    ),
                    array(
                        "name" => __("CSS Class", 'avia_framework'),
                        "desc" => __("Custom Class for the block container", 'avia_framework'),
                        "id" => "css_class",
                        "type" => "input",
                        "std" => "",
                    ),
                    array(
                        "type" => "close_div",
                        'nodescription' => true
                    ),
                    array(
                        "type" => "tab",
                        "name" => __("Colors", 'avia_framework'),
                        'nodescription' => true
                    ),
                    array(
                        "name" => __("Font Colors", 'avia_framework'),
                        "desc" => __("Either use the themes default colors or apply some custom ones", 'avia_framework'),
                        "id" => "font_color",
                        "type" => "select",
                        "std" => "",
                        "subtype" => array(__('Default', 'avia_framework') => '',
                            __('Define Custom Colors', 'avia_framework') => 'custom'),
                    ),
                    array(
                        "name" => __("Custom Font Color", 'avia_framework'),
                        "desc" => __("Select a custom font color. Leave empty to use the default", 'avia_framework'),
                        "id" => "color",
                        "type" => "colorpicker",
                        "std" => "",
                        "container_class" => 'av_half av_half_first',
                        "required" => array('font_color', 'equals', 'custom')
                    ),
                    array(
                        "type" => "close_div",
                        'nodescription' => true
                    ),
                    array(
                        "type" => "close_div",
                        'nodescription' => true
                    ),
                );
            }
    
            /**
             * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
             * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
             * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
             *
             *
             * @param array $params this array holds the default values for $content and $args.
             * @return $params the return array usually holds an innerHtml key that holds item specific markup.
             */
            function editor_element($params) {
                $heading = "";
                $template = $this->update_template("heading", " - <strong>{{heading}}</strong>");
                if (!empty($params['args']['heading']))
                    $heading = "- <strong>" . $params['args']['heading'] . "</strong>";
    
                $params['innerHtml'] = "<img src='" . $this->config['icon'] . "' title='" . $this->config['name'] . "' />";
                $params['innerHtml'].= "<div class='avia-element-label'>" . $this->config['name'] . "</div>";
                $params['innerHtml'].= "<div class='avia-element-label' {$template}>" . $heading . "</div>";
                return $params;
            }
    
            /**
             * Editor Sub Element - this function defines the visual appearance of an element that is displayed within a modal window and on click opens its own modal window
             * Works in the same way as Editor Element
             * @param array $params this array holds the default values for $content and $args.
             * @return $params the return array usually holds an innerHtml key that holds item specific markup.
             */
            function editor_sub_element($params) {
                $template = $this->update_template("title", "{{title}}");
    
                $params['innerHtml'] = "";
                $params['innerHtml'] .= "<div class='avia_title_container' {$template}>" . $params['args']['title'] . "</div>";
    
                return $params;
            }
    
            /**
             * Frontend Shortcode Handler
             *
             * @param array $atts array of attributes
             * @param string $content text within enclosing form of shortcode element
             * @param string $shortcodename the shortcode found, when == callback name
             * @return string $output returns the modified html string
             */
            function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "") {
    
                $atts = shortcode_atts(array(
                    'type' => 'slider',
                    'autoplay' => 'false',
                    'animation' => 'fade',
                    'interval' => 5,
                    'navigation' => 'arrows',
                    'heading' => '',
                    'columns' => 3,
                    "css_id" => "",
                    "css_class" => "",
                    'handle' => $shortcodename,
                    'content' => ShortcodeHelper::shortcode2array($content, 1),
                    'class' => $meta['el_class'],
                    'custom_markup' => $meta['custom_markup'],
                    'font_color' => '',
                    'color' => '',
                    'styling' => ''
                        ), $atts, $this->config['shortcode']);
    
                if ($atts['font_color'] == "custom") {
                    $atts['class'] .= " av_inherit_color";
                    $atts['styling'] .=!empty($atts['color']) ? " color:" . $atts['color'] . "; " : "";
                    if ($atts['styling'])
                        $atts['styling'] = " style='" . $atts['styling'] . "'";
                }
    
                $slider = new avia_offerings_block($atts);
                return $slider->html();
            }
    
        }
    
    }
    
    if (!class_exists('avia_offerings_block')) {
    
        class avia_offerings_block {
    
            static $slider = 0;     //slider count for the current page
            protected $config;      //base config set on initialization
    
            function __construct($config) {
                global $avia_config;
                $output = "";
    
                $this->config = array_merge(array(
                    'type' => 'grid',
                    'autoplay' => 'false',
                    'animation' => 'fade',
                    'handle' => '',
                    'heading' => '',
                    'navigation' => 'arrows',
                    'columns' => 3,
                    'interval' => 5,
                    'class' => "",
                    'custom_markup' => "",
                    'css_id' => "",
                    'css_class' => "",
                    'content' => array(),
                    'styling' => ""
                        ), $config);
            }
    
            public function html() {
                $output = "";
                $counter = 0;
                avia_offerings_block::$slider++;
                if (empty($this->config['content']))
                    return $output;
    
                //$html .= empty($this->subslides) ? $this->default_slide() : $this->advanced_slide();
    
                extract($this->config);
    
                $columns = 3;
                $extraClass = 'first';
                $slide_loop_count = 1;
                $loop_counter = 1;
                $total = $columns % 2 ? "odd" : "even";
                $heading = !empty($this->config['heading']) ? '<h2>' . $this->config['heading'] . '</h2>' : "&nbsp;";
                $slide_count = count($content);
                $grid = 'av_one_fifth';
    
                $data = AviaHelper::create_data_string(array('autoplay' => $autoplay, 'interval' => $interval, 'animation' => $animation, 'show_slide_delay' => 30));
    
                $id = 'id="'.$css_id.'"';
                $thumb_fallback = "";
                $output .= "<div  {$id} class='{$css_class} col-centered offerings custom-block' {$styling}>";
    
                $heading_class = '';
                if ($navigation == 'no')
                    $heading_class .= ' no-content-slider-navigation ';
                if ($heading == '&nbsp;')
                    $heading_class .= ' no-content-slider-heading ';
    
                $output .= "<div class='avia-smallarrow-slider-heading $heading_class'>";
                $output .= "<div class='new-special-heading'>" . $heading . "</div>";
                $output .= "</div>";
    
                $output .= "<div class='avia-content-slider-inner'>";
    
                foreach ($content as $key => $value) {
                    $link = $linktarget = "";
    
                    extract($value['attr']);
    
                    $link = aviaHelper::get_url($link);
                    $blank = (strpos($linktarget, '_blank') !== false || $linktarget == 'yes') ? ' target="_blank" ' : "";
                    $blank .= strpos($linktarget, 'nofollow') !== false ? ' rel="nofollow" ' : "";
    
                    $parity = $loop_counter % 2 ? 'odd' : 'even';
                    $last = $slide_count == $slide_loop_count ? " post-entry-last " : "";
                    $post_class = "post-entry slide-entry-overview slide-loop-{$slide_loop_count} slide-parity-{$parity} {$last}";
    
                    if ($loop_counter == 1)
                        $output .= "<div class='block-entry-wrap col-centered'>";
    
                    $markup = avia_markup_helper(array('context' => 'entry', 'echo' => false, 'custom_markup' => $custom_markup));
                    $output .= "<section class='flex_column av_one_third col-centered {$post_class} {$grid} {$extraClass}' $markup>";
    
                    $markup = avia_markup_helper(array('context' => 'entry_title', 'echo' => false, 'custom_markup' => $custom_markup));
                    if(!empty($src)){
                        $img = "<img src='".$src."' alt='" . esc_attr($title) . "'  />";
                    } else {
                        $img = "<img src='".AviaBuilder::$path['imagesURL'] . "placeholder.jpg"."' alt='" . esc_attr($title) . "'  />";
                    }
                    if(!empty($link)){
                        $output .= "<a href='{$link}' $blank title='" . esc_attr($title) . "'>"."<div class='avia_image_container'>{$img}</div>"."</a>";
                    } else {
                        $output .= "<div class='avia_image_container'>{$img}</div>";
                    }
                    $output .=!empty($title) ? "<h3 class='slide-entry-title entry-title' $markup>" : '';
                    $output .= (!empty($link) && !empty($title)) ? "<a href='{$link}' $blank title='" . esc_attr($title) . "'>" . $title . "</a>" : $title;
                    $output .=!empty($title) ? '</h3>' : '';
    
                    $markup = avia_markup_helper(array('context' => 'entry_content', 'echo' => false, 'custom_markup' => $custom_markup));
                    $output .=!empty($value['content']) ? "<div class='slide-entry-excerpt entry-content' $markup>" . ShortcodeHelper::avia_apply_autop(ShortcodeHelper::avia_remove_autop($value['content'])) . "</div>" : "";
    
                    $output .= '</section>';
    
                    $loop_counter ++;
                    $slide_loop_count ++;
                    $extraClass = "";
    
                    if ($loop_counter > $columns) {
                        $loop_counter = 1;
                        $extraClass = 'first';
                    }
    
                    if ($loop_counter == 1 || !empty($last)) {
                        $output .="</div>";
                    }
                }
    
                $output .= "</div>";
    
                $output .= "</div>";
    
                return $output;
            }
        }
    
    }

    Thanks!

    #841065

    Hey JenToronto,

    Unfortunately it would require quite some time and customization of the theme to achieve this, so I am sorry to tell you that this is not covered by our support. However if its really important for you to get this done, you can always hire a freelancer to do the job for you :)

    Best regards,
    Basilis

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.