Tagged: widgets
-
AuthorPosts
-
August 11, 2015 at 10:01 am #485798
Hello!
I have developed a widget/shortcode which can be used in the avia builder. It all works accept for one thing, can anyone assist?
Widget: modal group with sub elements (input and select). Adding/edit items works fine, closing (saving) the widget and then opening the widget the items are still there. But when i save the whole page and click on the widget the items are not loading. They are stored in the database and show up in front-end. What am i missing?
`
class vdlp_sc_merken_list extends aviaShortcodeTemplate
{/**
* Create the config array for the shortcode button
*/
function shortcode_insert_button()
{
$this->config['name'] = __('Merken (lijst)', 'vdlp');
$this->config['tab'] = __('VDLP', 'vdlp');
$this->config['icon'] = AviaBuilder::$path['imagesURL']."sc-blog.png";
$this->config['order'] = 20;
$this->config['target'] = 'avia-target-insert';
$this->config['shortcode'] = 'vdlp_sc_merken_list';
$this->config['shortcode_nested'] = array('vdlp_sc_merken_list_merk');
$this->config['tooltip'] = __('Lijst van merken', 'vdlp');
}/**
* 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() {global $merken_module;
$posts = $merken_module->queryItems();
if (!empty($posts)) {
foreach ($posts as $post) {
$merken[get_field('merk_naam', $post->ID)] = $post->ID;
}
}$this->elements = array(
array(
"name" => __("Toevoegen/wijzigen lijst met merken", 'vdlp' ),
"desc" => __("Hier kunt u merken toevoegen, wijzigen of verwijderen uit uw lijst", 'vdlp' ),
"type" => "modal_group",
"id" => "content",
"modal_title" => __("Merk", 'vdlp'),
"std" => array(),
'subelements' => array(
array(
"name" => __("Titel", 'vdlp' ),
"desc" => __("Geef titel op", 'vdlp' ),
"id" => "title",
"type" => "input",
),
array(
"name" => __("Kies gekoppelde merk", 'vdlp' ),
"desc" => __("Selecteer een merk uit de lijst", 'vdlp' ),
"id" => "merkid",
"type" => "select",
"subtype" => $merken,
),
)
)
);
}/**
* 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)
{
$params['innerHtml'] = "<img src='".$this->config['icon']."' title='".$this->config['name']."' />";
$params['innerHtml'].= "<div class='avia-element-label'>".$this->config['name']."</div>";
$params['content'] = NULL; //remove to allow content elementsreturn $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'] = "<div class='avia_title_container'>";
$params['innerHtml'] .= "<span {$template}>" .$params['args']['title']. "</span>";
$params['innerHtml'] .= "</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 = "")
{
$output = "";$atts = shortcode_atts(array(
'items' => 0,
), $atts, $this->config['shortcode']);$merken = ShortcodeHelper::avia_remove_autop($content, true);
if (empty($merken)) {
return '';
}$output .= '<div class="vdlp-widget-wrapper">';
$output .= '<h2>Merken</h2>';
$output .= '<ul class="merken">';
$output .= ShortcodeHelper::avia_remove_autop( $content, true );
$output .= '</ul>';
$output .= '<a href="' . get_permalink(CONST_PAGEID_MERKEN) . '" title="Meer merken">Meer merken</a>';
$output .= '</div>';return $output;
}/**
* vdlp_sc_merken_list_merk
*
* @param array $atts
* @param string $content
* @param string $shortcodename
* @return string
*/
function vdlp_sc_merken_list_merk($atts, $content = "", $shortcodename = "")
{
$atts = shortcode_atts(array(
'merkid' => '',
'title' => ''
), $atts, $this->config['shortcode_nested']);$atts['title'] = (empty($atts['title'])) ? get_field('merk_naam', $atts['merkid']) : $atts['title'];
$output = '<li><a title="Ga naar '. $atts['title'] .'" href="' . get_permalink($atts['merkid']) . '"><span>' . $atts['title'] .'</span></a></li>';
return $output;
}
}
`Kind Regards,
Nico
August 11, 2015 at 5:42 pm #486093Hey vdlpwp!
This is bordering on custom work. It would be best to hire a freelancer to help you out with this customization.
Cheers!
ElliottAugust 12, 2015 at 9:12 am #486341Hello Elliott,
Thanks for the reply. This is custom work. :-) Have you also seen the private content that comes with this post?
I believe it’s a small thing i’m missing and for the core developers at kriesi something to fix fast, possible something that is a known issue. Please take a look.
Kind Regards,
Nico
August 13, 2015 at 10:37 am #487056Hi!
If your element content is dynamically filled with a CPT i’d suggest you using another type of element as a base (like the blog posts element or portfolio grid, the icon list is filled with static content put directly inside the shortcode).
In any case if you really want us to take a look, please create us a WordPress administrator account, post it here as a private reply.
Best regards,
JosueAugust 13, 2015 at 1:39 pm #487178Hello Josue,
See my message in private content. Thanks!
Nico
August 24, 2015 at 8:02 pm #492470Hey Nico!
Did you manage to sort it out? seems you are now using an option-less ‘webshop tip’ element.
Best regards,
JosueSeptember 15, 2015 at 12:12 pm #503268Hello Josue,
The option-less ‘Webshop Tip’ has a connection with woo-commerce (other fields or being used) and loads a specifiek product or random product form a category.
The problem was the line “$params[‘content’] = NULL; //remove to allow content elements” in editor_element(). Argh! :-)
Now it works perfect. Thanks for your help!
Kind regards,
Nico
-
AuthorPosts
- The topic ‘custom widget: modal_group items not loading after page is saved’ is closed to new replies.