Joomla modül geliştirme, neden ben ... tanımsız yöntemi JDocumentRendererModule Çağrı alabilirim?

1 Cevap php

I've been trying to get my first module to work, but keep getting Fatal error: Call to undefined method JDocumentRendererModule::isTuesday() and can't for the life of me figure out what is wrong. I think I followed all tutorials to the letter, however as I am not really comfortable with PHP, I suspect the problem really lies between the chair and the keyboard in this case! :-)

Joomla Sürüm 1.5.15

Testleri için PHP 5.2.11 / 5.3.1

Herhangi bir Yardım gerçekten takdir edilmektedir.

İşte benim kod ...

mod_jjoz_tourdates.php

<?php
 defined('_JEXEC') or die('Direct Access to this location is not allowed.');
// Include the syndicate functions only once
require_once( dirname(__FILE__).DS.'helper.php' );
$mdates = modJJOZtourdatesHelper::getDatesByMonth();
require( JModuleHelper::getLayoutPath( 'mod_jjoz_tourdates' ) );

helper.php

// no direct access
defined('_JEXEC') or die('Restricted access');

define('INTERNAL_FORMAT', 'Y-m-d');
define('DISPLAY_MONTH_FORMAT', 'M Y');
define('DISPLAY_DAY_FORMAT', 'D d M Y');

class modJJOZtourdatesHelper {


var $excluded_dates = array('2010-03-09','2010-04-13');

// operating days as per parameters
var $op_mon,$op_tue,$op_wed,$op_thu,$op_fri,$op_sat,$op_sun;


function getBlockeddatelist($params){
    $excluded_dates = array($params ->get('blockeddatelist'));
    return $exluded_dates;
}

  /*  date('w') returns a string numeral as follows:
   '0' Sunday
   '1' Monday
   '2' Tuesday
   '3' Wednesday
   '4' Thursday
   '5' Friday
   '6' Saturday
 */
function isSunday($date) {
    return date('w', strtotime($date)) === '0';
}

function isMonday($date) {
    return date('w', strtotime($date)) === '1';
}

  // why are you "undefined" ???
function isTuesday($date) {
    return date('w', strtotime($date)) === '2';
}

function isWednesday($date) {
    return date('w', strtotime($date)) === '3';
}

function isThursday($date) {
    return date('w', strtotime($date)) === '4';
}

function isFriday($date) {
    return date('w', strtotime($date)) === '5';
}

function isSaturday($date) {
    return date('w', strtotime($date)) === '6';
}

// handle the excluded dates
function isExcludedDate($internal_date) {
    return in_array($internal_date, $this->excluded_dates);
}


function getDatesByMonth()  {

    $start_date = date(INTERNAL_FORMAT);
    $months_and_dates = array();

    // loop over 365 days and look for tuesdays or wednesdays not in the excluded list
    foreach(range(0,365) as $day) {
        $internal_date = date(INTERNAL_FORMAT, strtotime("{$start_date} + {$day} days"));
        $this_day = date(DISPLAY_DAY_FORMAT, strtotime($internal_date));
        $this_month = date(DISPLAY_MONTH_FORMAT, strtotime($internal_date));

        if ($this->isTuesday($internal_date) || $this->isWednesday($internal_date) && !$this->isExcludedDate($internal_date)) {
            $months_and_dates[$this_month][] = $this_day;
        }
    }
    return $months_and_dates;
}
}

tmpl/default.php

<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
?>

<div>
 <?php
   // just loop and print the dates...
   foreach($mdates as $month => $days) {
       print $month . "<br>"."\n";
       print implode('<br>', $days);
       print "<br>"."\n";} 
 ?>
</div>

1 Cevap

Sadece kayıt ve bu konuya takılmaları herkes için.

Bir e-posta listesinde Dostça bir ruh bana yardımcı oldu.

Çözüm:

don't use $this->isTuesday(); use MyModuleHelper::isTuesday();

therefore...

if ($this->isTuesday($internal_date) || 
      $this->isWednesday($internal_date) && 
          !$this->isExcludedDate($internal_date)) {
             $months_and_dates[$this_month][] = $this_day;}

turns into

if (modJJOZtourdatesHelper::isTuesday($internal_date) ||
      modJJOZtourdatesHelper::isWednesday($internal_date) && 
       !modJJOZtourdatesHelper::isExcludedDate($internal_date)) {
            $months_and_dates[$this_month][] = $this_day;}