We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin Manager will not load

Development and Programming

DarkScythe's avatar
DarkScythe
36 posts
17 years ago
DarkScythe's avatar DarkScythe

Hello,

Perhaps I posted in the wrong forum before.. everyone appears to avoid my threads like the plague for some reason. I’m having some serious issues trying to get what I think is a simple plugin to work. I wrote up a small plugin following the guide in the EE docs, and doublechecked that all the required parts are there. However, when I upload it into my plugins folder (and I’ve given it 777 permissions, although 755 seems to work for the other plugins) and try to load the plugin manager, it won’t load.. it will just sit at a blank screen with no error messages or anything. If I delete the plugin, it will load normally. I don’t know why it’s failing when I upload my plugin.

I’m using EE 1.6.4, thanks in advance.

       
DarkScythe's avatar
DarkScythe
36 posts
17 years ago
DarkScythe's avatar DarkScythe

Perhaps it would help if I posted what I have so far in the plugin..

<?php

$plugin_info = array(
    'pi_name' => 'EE Age Calculator',
    'pi_version' =>'1.0',
    'pi_author' =>'Teny Ng',
    'pi_author_url' => 'http://www.darkscythe.com/',
    'pi_description' => 'Calculates Registered Member Age',
    'pi_usage' => Age::usage()
);

class Age
{

var $return_data = '';
    
    function Age()
    {
    global $TMPL;
    $rawdob = $TMPL->fetch_param('dob');
        if ($rawdob = '';)
        {
        $rawdob = date("m d, Y", time());
        }
    $rmob = explode(' ', $rawdob);
    $mob = date("m", strtotime($rmob['0']));
    $dob = intval($rmob['1']);
    $yob = $rmob['2'];
    $curtime = explode(' ', date("m d Y", time()));
    $dobday = "$mob"."$dob";
    $today = "$curtime[0]"."$curtime[1]";
    $dobyear = "$yob";
    $thisyear = "$curtime[2]";
        if ($today >= $dobday)
        {
        $age = $thisyear - $dobyear;
        }
        else
        {
        $age = ($thisyear - $dobyear) -1;
        }
    $this->return_data = $age;
    }

    // ---------------------- //
    // How to Use This Plugin //
    // ---------------------- //

    function usage()
    {
    ob_start();
    ?>

    This plugin is used in conjunction with EE's native {Birthday} tag
    to calculate a member's age. The member must have entered their
    birthday into EE for the tag to pull anything up. Members who do
    not have a birthday set, or are unregistered guests will have an
    age of 0 (zero.) Input format for manually hard-coding a birthday is
    mm dd, YYYY mirroring the format EE uses to display the {Birthday}
    tag. The month can be 2-digit numeric or standard text. The day must
    be numerical and the year must be 4-digit numeric for clarity.

    Usage should be {exp:Age dob="{Birthday}"}

    This function can be altered to take any standard date format, at
    the expense of some accuracy by utilizing the strtotime() function
    on the entire entry string, followed by the date() function to return
    a mm dd, YYYY formatted date. Some additional checks will need to be
    made for birthdays before 1970.
    
    <?php
    $buffer = ob_get_contents();
    
    ob_end_clean();
    
    return $buffer;
    }
    // END

}

?>

I can’t figure out if it’s something within my plugin that’s causing the problem or not. Since it only happens when I try to load the manager with this plugin loaded, it must be in there somewhere, but where?

       
Pascal Kriete's avatar
Pascal Kriete
2,589 posts
17 years ago
Pascal Kriete's avatar Pascal Kriete

A blank page usually means you have a syntax error in your code. In this case it’s in your first if statement:

if ($rawdob = '';)    // That semicolon shouldn't be there
       
DarkScythe's avatar
DarkScythe
36 posts
17 years ago
DarkScythe's avatar DarkScythe

Oh… that was really stupid.. lol. I guess I got a little bit too used to adding semi-colons after every line.

Good to know a blank page means syntax error though.. That tip wasn’t present anywhere in the EE docs, as far as I could tell - would’ve been immensely helpful. I’ll remove that and see if it works.

Edit: Okay, that did the trick. It seems I can’t set the default value of $rawdob when declaring the function.. or maybe I’m doing it wrong, but I guess that if() check for a blank value should suffice for that.

Would this work though? I mean, can I nest EE tags within each other in the declaration described in my usage text? I’m about to give it a go, I just need to make a bunch of edits to the template to make it show up. I’d like to know if there are any flaws with my reasoning though, as this is the first plugin I’ve designed.

Thanks again!

       
DarkScythe's avatar
DarkScythe
36 posts
17 years ago
DarkScythe's avatar DarkScythe

Okay, just an update.. It’s clear that this plugin needs some refining.

I made a quick test to see if it would even display what I wanted it to come up with - the age. I added {exp:age dob="{birthday}”} to the index template. When the user is logged in, and has set a birthday, it works well - it will display the user’s birthday. When the user is not logged in, it seems EE does not display it at all, which is good if it parsed everything and simply decided to hide it. This is bad if there was some sort of error and couldn’t parse it at all though. Finally, when the user is logged in and does NOT have a birthday set, it will give me an error about undefined indexes. According to the line numbers, it correlates to $dob and $yob accessing the $rmob array after I explode it. Setting the first if() condition to detect if $rawdob is empty ($rawdob = ”) or NULL ($rawdob = NULL) does not seem to work, and consequently, I think it’s skipping or ignoring the action to set the variable to the current date if no birthdate is found.

I tried to take this one step further closer to what I’m trying to do with this plugin (using the step that worked - logged in and with a birthday set.) I tried to set up an {if} conditional to return different text (eventually, I’m trying to have it display a different set of displayable categories.) However, this resulted again in the blank screen. This is the code I tried:

{if (exp:age dob="{birthday}") >= 18}Hello, adult!{/if}
{if (exp:age dob="{birthday}") < 18}Hello, Minor!{/if}

Any ideas where I’m going wrong this time?

Thanks again.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.