Take the 2-minute tour ×
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It's 100% free, no registration required.

I'm trying to create a module tag but it just isn't working, I'm following the Hello World tutorial at Ellis Lab. My module is installed and the MCP part is working. Here is my mod file:

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Facebook_Photos {

    public $return_data = "";

    // Constructor
    public function __construct()
    {
        $this->EE =& get_instance();
        $this->return_data = 'Hello World';
        return $this->return_data;
    }

    public function get_photos()
    {
        $this->return_data = 'Hello World';
    }
}

?>

Just in case here is my tag pair in my template (it's the only template that exists):

{exp:facebook_photos:get_photos}

I’m getting the following error from EE:

The following tag cannot be processed:

{exp:facebook_photos:get_photos}

Please check that the ‘facebook_photos’ module is installed and that ‘get_photos’ is an available method of the module

share|improve this question
1  
Can you restructure your question to include the full module class code? It's really hard to see what's going on. Is get_photos in your Facebook_photos class? PS I highly doubt it's anything to do with your language file. –  Adrian Macneil Jan 14 '13 at 5:09
    
Thanks for the thought - I figured it out and posted the answer below. –  coldcoder Jan 14 '13 at 5:14
1  
I just reformatted your question to make it more clear what the actual problem was. In the future, try to format your questions so that it’s clear what the issue is, even to people who haven’t been involved in the thread, so that it might help someone else with the same issue. –  Brandon Kelly Jan 14 '13 at 14:37
add comment

2 Answers 2

up vote 6 down vote accepted

The ‘p’ in your module’s class name must be lowercased.

From http://ellislab.com/expressionengine/user-guide/development/modules.html#the-core-module-file-mod-module-name-php:

The Core Module file is used for outputting content via Templates and doing any processing that is required by both the Control Panel and any module tags contained in a template. It includes a class with a name that matches the package (the first letter of the class name must be capitalized).

share|improve this answer
add comment

Ok, finally got it - took me forever but now I can hopefully help someone else that runs into this.

I checked that my mod.facebook_photos.php had the method get_photos and that everything was spelled right and it was. So I thought I'd check if it was installed, it was - but at the same time it wasn't.

If you open system/expressionengine/libraries/Template.php and go to line 1224 you find the conditional that is causing the error. There I placed some debugging information:

echo 'Class Name: ' . $class_name . '<br/>';
echo 'Tag Data Class: <br/>';
var_dump($this->tag_data[$i]['class']);
echo '<br/>Modules: <br/>';
var_dump($this->modules);
echo '<br/>Module Data Class Name: <br/>';
var_dump($this->module_data[$class_name]);

Everything came back as expected except for the last one that threw a PHP error where it couldn't find that index. So I echoed out the $class_name and I received Facebook_photos. To my surprise on line 1205 you see the following:

$class_name = ucfirst($this->tag_data[$i]['class']);

So what I did was go to my upd.facebook_photos.php and renamed every place that Facebook_Photos to Fbphotos (I removed the underscores to create a shorter namespace). I then renamed all file names and class names to match this new namespace making sure that the class names have the first letter uppercased (as that is what ucfirst) does.

Also, my tag pair had to change due to the new namespace - it now looks like this:

{exp:fbphotos:get_photos}

Now the get_photos method works as expected. Hope this helps someone else!

share|improve this answer
1  
Maybe it was expecting Facebook_photos instead of Facebook_Photos? I didn't think PHP class names were case sensitive though. Glad you solved it, thanks for posting the solution! –  Adrian Macneil Jan 14 '13 at 5:17
    
I don't think that they are case sensitive, but when they're doing an in_array check that's what's throwing the error. –  coldcoder Jan 14 '13 at 5:29
    
Brandon Kelly's response above is correct. Case sensitivity is built-in. Not a bug. I just wanted to make sure that was noted. –  Erik Reagan Jan 14 '13 at 15:46
    
Yeah, I was posting my findings at the same time he was posting his response. They basically got published at the same time, sorry for the redundancy. –  coldcoder Jan 14 '13 at 18:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.