1

I am trying to test the jqScheduler for PHP within a Drupal CMS Module.

When $eventcal->render(); function is called within a Drupal module, the following code is generated before the <html> section, outside the start of the page.

<style type=text/css>/*
    Document   : calendar
.
.
.
<script type='text/javascript'>jQuery(document).ready(function() {jQuery.datepicker...
<html xmlns="http://www.w3.org/1999/xhtml" lang="fa" xml:lang="fa">

<head>

Is there a way to intercept above code so that I can place them where I need them.

Example:

$output = "<script type='text/javascript'>jQuery(document).ready(function() .... </script>";

I add css & ja file added this like code

     function study_jqScheduler() {
          drupal_add_css('sites/all/libraries/jqgrid/themes/redmond/jquery-ui-1.8.16.custom.css');
        drupal_add_css('sites/all/libraries/jqgrid/themes/jquery.ui.tooltip.css');
      drupal_add_css('sites/all/libraries/jqgrid/themes/ui.jqscheduler.css');  
drupal_add_js('sites/all/libraries/jqgrid/js/jquery-ui-custom.min.js');
drupal_add_js('sites/all/libraries/jqgrid/js/jquery.js');
 drupal_add_js('sites/all/libraries/jqgrid/js/jquery.jqScheduler.min.js');
require_once "sites/all/libraries/jqgrid/php/jqUtils.php";
require_once "sites/all/libraries/jqgrid/php/jqScheduler.php";
require_once "sites/all/libraries/jqgrid/php/jqGridPdo.php";
require_once "sites/all/libraries/jqgrid/jq-config.php";
    global $base_path;
    $base_path1=drupal_get_path('module', 'study');
    // Set the url from where we obtain the data
ini_set("display_errors",1);
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
$conn->query("SET NAMES utf8");
$eventcal = new jqScheduler($conn);
$eventcal->setLocale('en_GB');
$eventcal->setUrl($base_path.$base_path1.'/eventcal.php');
$eventcal->setUser(1);
$eventcal->setUserNames(array('1'=>"Calender User 1",'2'=>"Calendar user 2",'3'=>"Calendar user 3") );
$eventcal->multiple_cal = true;
$output.= $eventcal->render();
     return $output;
}

1 Answer 1

1

You need to return $eventcal->render(); from your page callback function, then it will be added to the content region as normal.

function mymodule_page_callback() {
  drupal_add_js('...');
  drupal_add_css('...');

  return $eventcal->render();
}

Hope that helps, make sure you accept the answers to your previous questions if they've helped you (see this post for details of how to do this). People will will be far more inclined to help in the future if you've shown that you appreciate the time they've taken to help you...you can do this by accepting those answers :-)

Sign up to request clarification or add additional context in comments.

1 Comment

OK I get it, render() is outputting directly to the buffer, it doesn't return the rendered calendar. It's quite easy to fix but I'm reluctant to tell you how until you accept the answers to your previous questions...SO is a community and all members need to participate in that community :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.