extensionName = "Custom Object"; // This plugin works on all pages of the site. If it should work only in certain extensions, add them here (com_content, etc) // $this->supportedComponents[] = ''; // Define all types of pages this component can create and would be 'objects' #$this->addSupportedObject("Pretty name for display", "system_name"); $this->addSupportedObject("Custom Object Type", "custom"); } /* Method to determine the best ogObject instance the passed in queryVars would apply to, if any. * * @param array $queryVars Associative array of query variable for a given page. Values *must* be filtered if they are to be used in DB calls * * @return ogObject The best ogObject definition found, or null if none */ protected function findObjectType($queryVars) { $object = null; // Get all the custom objects the admin has created $types = $objectTypes = $this->getObjects('custom'); // Loop over each definition to see if this page fits the criteria foreach ($types as $type) { $matchParams = $type->params->get('og_query_parameters'); $matchParams = explode("\n", $matchParams); $match = true; foreach ($matchParams as $mp) { $pair = explode("=", $mp); if (array_key_exists($pair[0], $queryVars) && ($queryVars[$pair[0]] == trim($pair[1]))) continue; else { $match = false; break; } } if ($match) { $object = $type; break; } } // Return whatever was found, or null if nothing return $object; } /* Method to set the Open Graph tags on the page according to the Object that was found in findObjectType * This method can use the $this->object variable to get whatever information it needs on how the tags should be set for this type of view * The Open Graph 'type' should *not* be set here. All other tags are fair game. */ protected function setOpenGraphTags() { $tags = $this->object->params->get('og_open_graph_tags'); $tags = explode("\n", $tags); foreach ($tags as $tag) { $pair = explode("=", $tag); // Add this open graph tag to the page. If the final parameter is false, other objects or {SCOpenGraph} tags can overwrite the value. // If true, this tag is final. if ($pair[0] != "") $this->addOpenGraphTag($pair[0], trim($pair[1]), false); } } }