Open Graph - com_content categories view

Phoca plugins - support for all Phoca plugins except Phoca Gallery plugins
Cony
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 24 Mar 2011, 15:51

Open Graph - com_content categories view

Post by Cony »

Hi,

after installing and setup both COntent and System plugin, I found, that I am not able to set properties for categories view of com_content.
It is because this view do not call onContentAfterDisplay event (so Content plugin doesn't work here), and System plugin block com_content at all, regardless view.

Simplest solution of this would be to modify System plugin, so it does not ignore categories view. Maybe something like this:

Code: Select all

	function onBeforeRender() {
		$app 	= JFactory::getApplication();
		$option	= $app->input->get('option');
    $view	= $app->input->get('view');
		
		$format = $app->input->get('format');
		if ($format == 'feed' || $format == 'pdf' || $format == 'json') {
			return true;
		}
		
		
		if ($app->getName() != 'site') { return;}
		
		
		$allowed		= 0;
		// Allow to display in article
    if ($option == 'com_content' && $view == 'article') {
  		$articleIds 		= $this->params->get('enable_article', '');
  		if ($articleIds != '') {
  			$articleIdsA =  explode(',', $articleIds);
  			if (!empty($articleIdsA)) {
  				$articleId	= $app->input->get('id', 0, 'int');
  				foreach ($articleIdsA as $k => $v) {
  					if ($option == 'com_content' && (int)$articleId > 0 &&(int)$articleId == (int)$v) {
  						$allowed = (int)$articleId;
  						break;
  					}
  				}
  			}
  		}
    } elseif ($option == 'com_content' && $view == 'categories') {
      $allowed		= 1;
    } elseif ($option != 'com_content') {
      $allowed		= 1;
    }
		
		//com_phocadownload
		//com_phocadocumentation
		//com_phocainclude
		if ($allowed) {
			$document 	= JFactory::getDocument();
			$config 	= JFactory::getConfig();
			$type		= $this->params->get('render_type', 1);
			// Site Name
			if ($this->params->get('site_name', '') != '') {
				plgSystemPhocaOpenGraphHelper::renderTag('og:site_name', $this->params->get('site_name', ''), $type);
			} else {
				plgSystemPhocaOpenGraphHelper::renderTag('og:site_name', $config->get('sitename'), $type);
			}
			plgSystemPhocaOpenGraphHelper::renderTag('og:title', $document->title, $type);
			plgSystemPhocaOpenGraphHelper::renderTag('og:description', $document->description, $type);
			plgSystemPhocaOpenGraphHelper::renderTag('og:url', $document->base, $type);
			plgSystemPhocaOpenGraphHelper::renderTag('og:type', 'website', $type);
			
			if ($this->params->get('image') != '') {
				plgSystemPhocaOpenGraphHelper::renderTag('og:image', JURI::base(false).$this->params->get('image'), $type);
			}
		}
	}
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47885
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Open Graph - com_content categories view

Post by Jan »

Hi, thank you for the info, I will take a look at it.

Jan
If you find Phoca extensions useful, please support the project
Post Reply