brrocks28
6/30/2015 - 10:27 AM

Ctools Popup

Ctools Popup

<?php
function  ctools_popup_menu(){
    $items['popup']=array(
    'title'=>'Ctools popup page',
     'page callback'=>'popup_page_callback',
     'access callback'=>TRUE,
    );
    
    $items['ajax/%ctools_js/show/modal']=array(
     'title'=>'Model Content',
      'page callback'=>'modal_page_callback',
      'page arguments'=>array(1),
      'access callback'=>TRUE      
    );
    return $items;
}


function popup_page_callback(){
    
    ctools_include('ajax');
    ctools_include('modal');
    ctools_modal_add_js();
    $build['paragraph']=array(
    '#prefix'=>'<p>',
     '#suffix'=>'</p>',
      '#markup'=>t("click here"),
    );
    
    $text=t("show popup text");
    $alt=t("show popup text on click");
    $dest="ajax/nojs/show/modal";
    $link= ctools_modal_text_button($text, $dest, $alt);
   
    $build['popup_link']=array(
     '#markup'=>$link, 
      
    );
    return render($build);
}

function modal_page_callback($js=NULL){
    
    if($js){
    ctools_include('ajax');
    ctools_include('modal');           
        $title= t('POPUP popopopup');
        
        $build=array(
        '#prefix'=>'<p>',
        '#suffix'=>'</p>',
         '#markup'=> t('hello this is popup  '),
        );
        $output=render($build);
        ctools_modal_render($title, $output);
    }

}
name = ctools_popup 
description = This is  Ctools Popup.
package = Bhavesh_Modules 
core = 7.x