Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #27740

    Hi,

    I’m creating a child theme of “Enfold”. I almost finished, but I want to add some features to the pricing tables and I need to modify the “table.php” file on the directory “config-templatebuilder/avia-shortcodes/”.

    The problem is that when I add the modified version of the “table.php” file on the child theme folder, it doesn’t work. It ignores completely the child theme file.

    What can I do?

    Thanks

    #135184

    Hi,

    Do you add the file to the child theme folder or do you add it to the /child-theme-folder/config-templatebuilder/avia-shortcodes/ ? create empty folders to mimic how the folder structure is on the parent theme. You do not have to add any other files just leave folders empty except for the 1 file you are moving.

    Thanks,

    Nick

    #135185

    I created the folders “/child-theme-folder/config-templatebuilder/avia-shortcodes/”, and I added the modified “table.php” on it, but it doesn’t work.

    #135186

    hi,

    I hope your replaced ‘child-theme-folder” with the actual name of your child theme and inside whatever you called your child theme you added config-templatebuilder and inside that you added avia-shortcodes/

    i am just checking.

    Thanks,

    Nick

    #135187

    The file “table.php” is in the “jtvdigital/config-templatebuilder/avia-shortcodes/”, but it doesn’t work. What can I do?

    #135188

    Hi,

    Sorry about that. The only files you can override by dropping the file into the folder structure are the templates (archive, page, post, single etc.)

    To override other files, you need to do that from functions.php in the child theme. So you will need to either

    (a) copy the contents of table.php starting from line 9 to line 301, and paste it into functions.php of the child theme.

    or

    (b) you can do everything same as A except create a new file called table.php and put the code inside it surrounded by <?php in front and ?> in back. and then include that file once into the functions.php

    Do not copy the wrapper from functions.php of the parent that looks like on line 7 and 8 along with the very last closing curly brackets on the page.

    if ( !class_exists( 'avia_sc_table' ) )
    {

    Since functions.php of the child theme will run before the parent then the parent class will never run since line 7 and 8 say that if that function already exists not to run it.

    Thanks,

    Nick

    #135189

    I created a file called “table.php” in the child theme folder. This is the content of the “table.php” file:

    <?php

    /**

    * Sidebar

    * Displays one of the registered Widget Areas of the theme

    */

    class avia_sc_table extends aviaShortcodeTemplate

    {

    static $table_count = 0;

    /**

    * Create the config array for the shortcode button

    */

    function shortcode_insert_button()

    {

    $this->config = __('Table', 'avia_framework' );

    $this->config = __('Content Elements', 'avia_framework' );

    $this->config = AviaBuilder::$path."sc-table.png";

    $this->config = 40;

    $this->config = 'avia-target-insert';

    $this->config = 'av_table';

    $this->config = array('modal_class' => 'bigscreen', 'before_save' => 'before_table_save');

    $this->config = array('av_row', 'av_cell','av_button');

    $this->config = __('Creates a data or pricing table', 'avia_framework' );

    }

    function extra_assets()

    {

    if(is_admin())

    {

    $ver = AviaBuilder::VERSION;

    wp_enqueue_script('avia_table_js' , AviaBuilder::$path.'js/avia-table.js' , array('avia_modal_js'), $ver, TRUE );

    //wp_enqueue_style( 'avia-table-style' , $this->$builder->assetsURL.'css/avia-table.css');

    }

    }

    /**

    * 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(

    "name" => __("Table Builder", 'avia_framework' ),

    "desc" => __("Start by adding columns and rows, then add content and styling to each.", 'avia_framework' ),

    "id" => "table",

    'container_class' =>"avia-element-fullwidth",

    "type" => "table",

    "row_style" => array( __('Default Row', 'avia_framework' ) => '',

    __('Heading Row', 'avia_framework' ) => 'avia-heading-row',

    __('Pricing Row', 'avia_framework' ) => 'avia-pricing-row',

    __('Button Row', 'avia_framework' ) => 'avia-button-row'

    ),

    "column_style" => array(__('Default Column', 'avia_framework' ) => '',

    __('Highlight Column', 'avia_framework' ) => 'avia-highlight-col',

    __('Description Column', 'avia_framework' ) => 'avia-desc-col',

    __('Center Text Column', 'avia_framework' ) => 'avia-center-col'

    )

    ),

    array(

    "name" => __("Table Purpose", 'avia_framework' ),

    "desc" => __("Choose if the table should be used to display tabular data or to display pricing options. (Difference: Pricing tables are flashier and try to stand out)", 'avia_framework' ),

    "id" => "purpose",

    "type" => "select",

    "std" => "pricing",

    "subtype" => array(

    __('Use the table as a Pricing Table', 'avia_framework' ) =>'pricing',

    __('Use the table to display tabular data', 'avia_framework' ) =>'tabular')),

    array(

    "name" => __("Table Caption", 'avia_framework' ),

    "desc" => __("Add a short caption to the table so visitors know what the data is about", 'avia_framework' ),

    "id" => "caption",

    "type" => "input",

    "std" => "",

    "required" => array("purpose","equals","tabular")

    )

    );

    }

    /**

    * 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 which is then inserted into the drag and drop container

    * Less often used: $params to add data attributes, $params 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)

    {

    $params = "config."' title='".$this->config."' />";

    $params.= "<div class='avia-element-label'>".$this->config."</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("label", __("Element", 'avia_framework' ). ": {{label}}");

    $params = NULL;

    $params = "";

    $params .= "<div class='avia_image_container' {$template}>".__("Element", 'avia_framework' ).": ".$params."</div>";

    $params = array('modal_class'=>'mediumscreen');

    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('purpose' => 'pricing', 'caption' => ''), $atts);

    $depth = 2;

    $table_rows = ShortcodeHelper::shortcode2array($content, $depth);

    $output = "";

    if(empty($table_rows)) return;

    self::$table_count ++;

    switch($atts)

    {

    case "pricing": $output .= $this->pricing_table($table_rows, $atts, $meta); break;

    default: $output .= $this->data_table($table_rows, $atts, $meta); break;

    }

    return $output;

    }

    //resort the array so that its easier to do a liststlye output when using pricing tables

    function list_sort_array($table_rows)

    {

    $new = array();

    foreach($table_rows as $rk => $row)

    {

    foreach($row as $ck => $cell)

    {

    $new[$ck] = $cell;

    $new[$ck][] = $row;

    $new[$ck][] = $cell;

    }

    }

    return $new;

    }

    /*

    pricing table uses unordered lists to display the table structure

    */

    function pricing_table($table_rows, $atts, $meta)

    {

    $sorted_rows = $this->list_sort_array($table_rows);

    $output = "";

    $output .= "<div class='avia-table main_color avia-pricing-table-container avia-table-".self::$table_count." ".$meta."'>";

    $fallback_values = array();

    $empty_cells = false;

    foreach($sorted_rows as $ul_k => $ul)

    {

    $output .= "<div class='pricing-table-wrap'>";

    $output .= "<ul class='pricing-table ".$ul."'>";

    foreach($ul as $key => $li)

    {

    $content = trim(do_shortcode($li));

    if(empty($content))

    {

    $ul[$key] .= " empty-table-cell";

    $content = "{{content-{$key}}}";

    $empty_cells = true;

    }

    else if(empty($fallback_values[$key]))

    {

    $fallback_values[$key] = $content;

    }

    if(strpos($ul[$key],'avia-pricing-row') !== false)

    {

    $content = preg_replace('!($|€|¥|£|¢|¤|%|‰|¢|¤|£|¥|€)!','<span class="currency-symbol">$1</span>', $content);

    }

    if(strpos($ul[$key],'avia-pricing-row') !== false)

    {

    $content = preg_replace('!(one-time fee)!','<div class="onetimefee">$1</div>', $content);

    }

    $output .= "<li class='".$ul[$key]."'>";

    $output .= $key == 0 ? "<div class='first-table-item'>{$content}</div>" : $content;

    $output .= $key == 0 ? "<span class='pricing-extra'></span>" :"";

    $output .= "";

    }

    $output .= "";

    $output .= "</div>";

    }

    if($empty_cells)

    {

    foreach($fallback_values as $key => $value)

    {

    $output = str_replace("{{content-{$key}}}", "<span class='fallback-table-val'>".$value."</span>", $output);

    }

    }

    $output .= "</div>";

    return $output;

    }

    /*

    data table uses the real table html tag to display its structure

    */

    function data_table($table_rows, $atts, $meta)

    {

    $responsive_style = "";

    $output = "<table class='avia-table avia-data-table avia-table-".self::$table_count." ".$meta."'>";

    $output .= $atts ? "<caption>".$atts."</caption>" : "";

    $output .= "<tbody>";

    $counter = 0;

    foreach($table_rows as $rk => $row)

    {

    if(empty($row)) $row = array();

    $row_attributes = array_merge(array('row_style' => ""), $row);

    $output .= "<tr class='".$row_attributes."'>";

    foreach($row as $key => $cell)

    {

    if(empty($cell)) $cell = array();

    $cell_attributes = array_merge(array('col_style' => ""), $cell);

    $tag = $row_attributes == 'avia-heading-row' ? "th" : "td";

    $tag = $cell_attributes == 'avia-desc-col' ? "th" : $tag;

    if($rk == 0 && $tag == "th")

    {

    $responsive_style .= ".avia-table-".self::$table_count." td:nth-of-type({$counter}):before { content: '".$row[$counter]."'; } ";

    $counter ++;

    }

    $output .= "<{$tag} class='".$cell_attributes."'>";

    $output .= do_shortcode($cell);

    $output .= "</{$tag}>";

    }

    $output .= "</tr>";

    }

    $output .= "</tbody>";

    $output .= "</table>";

    $output .= "<style type='text/css'>{$responsive_style}</style>";

    return $output;

    }

    }

    And then, in the “functions.php” of my child theme I included the file “table.php”. This is the content of the “functions.php” file:

    <?php

    include("table.php");

    ?>

    But it still doesn’t work. Now when I go to the website it gives me an error…

    #135190

    Please, help me!

    #135191

    The functions.php file shouldn’t need an opening and closing php tag as the whole file should start with a single opening <?php .

    #135192

    Sorry Devin, but I don’t understand you. Can you tell me the code that I should insert in the functions.php and table.php?

    The functions.php is located here: child-theme/functions.php

    The table.php is located here: child-theme/table.php

    #135193

    It depends on exactly how your functions.php file looks. Basically, you don’t open and close php if its already open.

    So you could either need to use:

    require_once( 'table.php' );

    or

    <?php require_once( 'table.php' ); ?>

    If this is still not clear, I would suggest just having a freelance developer make the changes to your child theme for you or directly editing the parent theme and then making a change log and back up so that you can freely update and then re-add your changes later.

    Also note that by including this file instead of the themes, any bug fixes to the parent will not get carried down to the child so you’ll need to check for changes to it on each update.

    #135194

    Thanks for everything!

    #135195

    Hi,

    To make it simpler. Just paste the entire file into functions.php for now of the child theme just take out the <?php from the start along with the lines I asked you to take out. You should not be getting any errors (the function.php file already starts with <?php . If you do , paste it here. but if you are having a problem its a technical problem (you are pasting it wrong somehow) and not the problem with the methods we are providing for you.

    Thanks,

    Nick

Viewing 13 posts - 1 through 13 (of 13 total)
  • The topic ‘Modify "table.php" on a child theme’ is closed to new replies.