3

So i've got this little plugin named AnnuaireAdherents with a variable that i try to access from within a template : annuaireadherents/ ├── AnnuaireAdherentsPlugin.php ├── services │   ├── AnnuaireAdherents_Service.php │   └── Proxy.php ├── twigextensions │   └── AnnuaireAdherentsTwigExtension.php └── variables └── AnnuaireAdherentsVariable.php

The variable should return a dynamic array, but let's try a static one first :

<?php namespace Craft;

/**
 * Variables provides access to list of adherents inside templates
 */
class AnnuaireAdherentsVariable {

    /**
     * Liste d'adhérents
     *
     * @return array
     */
    public function adherents() {
        return array(
            array(
                "raison_sociale" => "JOHN DOE & Co",
                "contact" => "JOHN DOE",
                "cp" => "99999",
                "address1" => "DESTINY STREET",
                "locality" => "NOWHERE",
                "mail" = "[email protected]"
            )
        );
    }
}

I've tried every namespace variants i could think of to access it inside a template :

{% for adh in craft.annuaireAdherents.adherents %}
    {{ adh.raison_sociale }}
{% endfor %}

but i keep receiving the error :

Method "annuaireAdherents" for object "Craft\CraftVariable" does not exist

Is it the correct namespace ? Do i have to relaunch Apache and Craft between each code modification to retest my variable ? Could there be another error that is masking me the true cause of this message ?

Thanks a lot for any clue / direction to investigate.

2
  • 3
    Sorry to ask, but did you install your plugin in Settings/Plugins?
    – carlcs
    Commented Oct 12, 2015 at 23:00
  • Don't be sorry to ask : it was the main cause ! I have to sync with the craft database updated by my coworker, and by doing that, i totally forgot that my plugin would be uninstalled as he doesn't have the plugin yet !! Thanks a lot for that silly one ! My apologies ! :)
    – zipang
    Commented Oct 13, 2015 at 7:43

1 Answer 1

3

Reinstalling the plugin after a database update just solved the problem : the database i sync'ed with didn't have the plugin installed (as it is still in development)

Sorry for that one... :)

Your Answer

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

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