Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Custom Element Error

Hi guys my custom element is not working it gives me an error

Fatal error: Call to undefined method Phalcon\Mvc\User\Component::SetMeta() in C:\Users\spilagan20140973\Desktop\BOOTSTRAP FILES\PORTABLES\USBWebserver v8.6\root\PHALCON\app\cache\c__users_spilagan20140973_desktop_bootstrap files_portables_usbwebserver v8.6_root_phalcon_app_views_index.volt.php on line 12

here is my code

my index.php

<!DOCTYPE html>
<!--[if lt IE 7 ]><html lang="en" class="no-js ie6"><![endif]-->
<!--[if IE 7 ]><html lang="en" class="no-js ie7"><![endif]-->
<!--[if IE 8 ]><html lang="en" class="no-js ie8"><![endif]-->
<!--[if IE 9 ]><html lang="en" class="no-js ie9"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en" class="no-js"><!--<![endif]-->
    {{ get_title() }}
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    {{ metaelements.SetMeta() }}

    {{ assets.outputCss('header_assets') }}
    <!--[if lt IE 9]>
        <script src=""></script>
        <script src=""></script>

    <section class="container-fluid container-main">

        {{ content() }}


    {{ assets.outputJs('footer_assets') }}



use Phalcon\Mvc\User\Component as Elements;
$di->set('metaelements', function(){
    return new Elements();

* Register Top Navigation Elements
$di->set('topnavelements', function(){
    return new Elements();

* Register bottom Navigation Elements
$di->set('bottomnavelements', function(){
    return new Elements();



$loader = new \Phalcon\Loader();

 * We're a registering a set of directories taken from the configuration file

Metaelements.php on my library folder


use Phalcon\Mvc\User\Component as Elements;

class Metaelements extends Elements

    public function SetMeta(){

        echo "meta tag";


edited Nov '14

you try this

    {{ metaelements.SetMeta() }} tobe 
    {{ this. metaelements.SetMeta() }}

So you loader is registerDirs so remove "use Phalcon\Mvc\User\Component as Elements;" in file service.php

    $di->set('Metaelements', function(){
        return new Elements();

thnks @Thiện big help :)