{"id":3254,"date":"2014-05-23T18:04:40","date_gmt":"2014-05-23T18:04:40","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2014\/05\/23\/undefined-method\/"},"modified":"2023-06-08T09:43:26","modified_gmt":"2023-06-08T13:43:26","slug":"undefined-method","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/","title":{"rendered":"Fatal error: Call to undefined method &#8211; Joomla 3 Component Development"},"content":{"rendered":"<p>When <a href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/intro\/\">creating a Joomla 3 component<\/a>, you can declare functions \/ methods within your <a href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/add-new-model\/\">models<\/a>. When calling these methods in your <a href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/add-new-view\/\">views<\/a>, you might see an error similar to the following:<\/p>\n<p class=\"alert alert-warning\"><strong>Fatal error: Call to undefined method<\/strong> ComponentViewName::yourMethod() in \/home\/userna5\/public_html\/components\/com_component\/views\/component\/view.html.php on line 19<\/p>\n<p>This error can be resolved using <a href=\"https:\/\/docs.joomla.org\/API16:JController\/getModel\" target=\"_blank\" rel=\"noopener noreferrer\">the getModel method<\/a>, and this is how you can edit your view.html.php file to do so.<\/p>\n<table class=\"article_table\">\n<tbody>\n<tr>\n<th>Replace this:<\/th>\n<td>\n<pre class=\"code_block\">$this-&gt;<span style=\"color: red;\">someMethod<\/span>();<\/pre>\n<\/td>\n<\/tr>\n<tr>\n<th>With this:<\/th>\n<td>\n<pre class=\"code_block\">$model = $this-&gt;getModel(); $model-&gt;<span style=\"color: red;\">someMethod<\/span>();<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Below, we\u2019ve created a screenshot that shows the getModel method being used:<\/p>\n<p><a href=\"\/support\/images\/stories\/edu\/joomla-3\/create-component\/getModel-in-action.png\" rel=\"lightbox-0\"><img decoding=\"async\" class=\"std_ss\" style=\"max-width: 100%; max-height: 500px;\" src=\"\/support\/images\/stories\/edu\/joomla-3\/create-component\/getModel-in-action.png\" alt=\"getModel method in action\"><\/a><\/p>\n<div style=\"clear: both;\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>When creating a Joomla 3 component, you can declare functions \/ methods within your models. When calling these methods in your views, you might see an error similar to the following: Fatal error: Call to undefined method ComponentViewName::yourMethod() in \/home\/userna5\/public_html\/components\/com_component\/views\/component\/view.html.php on line 19 This error can be resolved using the getModel method, and this is<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/\"> Read More ><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4403,94,4335],"tags":[4404],"class_list":["post-3254","post","type-post","status-publish","format-standard","hentry","category-joomla","category-joomla-3","category-error-numbers","tag-joomla-v3"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Fatal error: Call to undefined method - Joomla 3 Component Development | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"If you&#039;re creating a component in Joomla and you get a &quot;Call to undefined method&quot; error, you may be able to use getMethod to fix the error.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Fatal error: Call to undefined method - Joomla 3 Component Development | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"If you&#039;re creating a component in Joomla and you get a &quot;Call to undefined method&quot; error, you may be able to use getMethod to fix the error.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2014-05-23T18:04:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-08T13:43:26+00:00\" \/>\n<meta name=\"author\" content=\"Brad Markle\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Brad Markle\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/\"},\"author\":{\"name\":\"Brad Markle\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf\"},\"headline\":\"Fatal error: Call to undefined method &#8211; Joomla 3 Component Development\",\"datePublished\":\"2014-05-23T18:04:40+00:00\",\"dateModified\":\"2023-06-08T13:43:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/\"},\"wordCount\":103,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"keywords\":[\"Joomla v3\"],\"articleSection\":[\"Joomla\",\"Joomla 3\",\"Website Error Numbers\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/\",\"name\":\"Fatal error: Call to undefined method - Joomla 3 Component Development | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2014-05-23T18:04:40+00:00\",\"dateModified\":\"2023-06-08T13:43:26+00:00\",\"description\":\"If you're creating a component in Joomla and you get a \\\"Call to undefined method\\\" error, you may be able to use getMethod to fix the error.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Fatal error: Call to undefined method &#8211; Joomla 3 Component Development\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf\",\"name\":\"Brad Markle\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/bradm\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Fatal error: Call to undefined method - Joomla 3 Component Development | InMotion Hosting","description":"If you're creating a component in Joomla and you get a \"Call to undefined method\" error, you may be able to use getMethod to fix the error.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/","og_locale":"en_US","og_type":"article","og_title":"Fatal error: Call to undefined method - Joomla 3 Component Development | InMotion Hosting","og_description":"If you're creating a component in Joomla and you get a \"Call to undefined method\" error, you may be able to use getMethod to fix the error.","og_url":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2014-05-23T18:04:40+00:00","article_modified_time":"2023-06-08T13:43:26+00:00","author":"Brad Markle","twitter_card":"summary_large_image","twitter_creator":"@InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"Brad Markle","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/"},"author":{"name":"Brad Markle","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf"},"headline":"Fatal error: Call to undefined method &#8211; Joomla 3 Component Development","datePublished":"2014-05-23T18:04:40+00:00","dateModified":"2023-06-08T13:43:26+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/"},"wordCount":103,"commentCount":0,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"keywords":["Joomla v3"],"articleSection":["Joomla","Joomla 3","Website Error Numbers"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/","url":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/","name":"Fatal error: Call to undefined method - Joomla 3 Component Development | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2014-05-23T18:04:40+00:00","dateModified":"2023-06-08T13:43:26+00:00","description":"If you're creating a component in Joomla and you get a \"Call to undefined method\" error, you may be able to use getMethod to fix the error.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/joomla\/joomla-3\/undefined-method\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"Fatal error: Call to undefined method &#8211; Joomla 3 Component Development"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5ae05d1210b0ef63c437ccedce2799bf","name":"Brad Markle","url":"https:\/\/www.inmotionhosting.com\/support\/author\/bradm\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":null,"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3254","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=3254"}],"version-history":[{"count":5,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3254\/revisions"}],"predecessor-version":[{"id":104880,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3254\/revisions\/104880"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=3254"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=3254"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=3254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}