Phoca Open Graph Titles

Phoca plugins - support for all Phoca plugins except Phoca Gallery plugins
micherts
Phoca Newbie
Phoca Newbie
Posts: 4
Joined: 05 Oct 2013, 11:12

Phoca Open Graph Titles

Post by micherts »

The plugin uses the menu title as the og:title but Joomla allows for this title to be changed either by entering 'Browser Page Title' in Page Display Options or by selecting 'Use site name in page titles' from Global Configuration. Neither of these options are picked up by Phoca OG - would it be possible to incorporate these features?

Thanks for your help.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48402
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Phoca Open Graph Titles

Post by Jan »

Hi, not sure if I understand correctly what exactly is missing?

First the title is set by item:

Code: Select all

$thisTitle	= $row->title;
If it is the category view, then from category:

Code: Select all

if (isset($cItem[0]->title) && $cItem[0]->title != '') {
					$thisTitle		= $cItem[0]->title;
				}
In case it it set in parameters:

Code: Select all

// Title
		if ($this->params->get('title'.$suffix, '') != '') {
			$document->setMetadata('og:title', htmlspecialchars($this->params->get('title'.$suffix, '')));
		} else if ($row->title != '') {
			$document->setMetadata('og:title', htmlspecialchars($thisTitle));
		}
Means: if it set in parameters set the title by parameters, if not set the title by item or category (parameters value itself decides it if is taken from global configuration or parameters menu link :idea: )

The same with site name:

Code: Select all

// Site Name
		if ($this->params->get('site_name'.$suffix, '') != '') {
			$document->setMetadata('og:site_name', htmlspecialchars($this->params->get('site_name'.$suffix, '')));
		} else if ($thisTitle != '') {
			$document->setMetadata('og:site_name', htmlspecialchars($config->get('sitename')));
		}
If you find Phoca extensions useful, please support the project
micherts
Phoca Newbie
Phoca Newbie
Posts: 4
Joined: 05 Oct 2013, 11:12

Re: Phoca Open Graph Titles

Post by micherts »

Hi Jan,
Thanks for your detailed response. Unfortunately, I don't fully grasp your code as I'm not an expert. It sounds like you have it covered but I'm not experiencing the desired outcome. Let me explain further in layman's terms.
I have a page whose menu item title is 'Monitoring' and the site name is 'Camplex'. In Global Configuration the setting 'Include Site Name in Page Titles' is set to 'After'. Hence if you examine the HTML Source the title of the page is entered as <title>Monitoring - Camplex</title>. However, the OG title is entered as <meta property="og:title" content="Monitoring" />. I want the OG tag to match the Title tag.
If it helps, I can provide you a link and login for the site, as it's currently offline for construction.
Thanks for your help,
Michael
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48402
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Phoca Open Graph Titles

Post by Jan »

Hi, not sure which version you are running, maybe some old which does not have such feature?
If you find Phoca extensions useful, please support the project
micherts
Phoca Newbie
Phoca Newbie
Posts: 4
Joined: 05 Oct 2013, 11:12

Re: Phoca Open Graph Titles

Post by micherts »

I'm running Joomla! 3.1.5, Phoca Open Graph Plugin 3.0.0.
teamtmedia
Phoca Newbie
Phoca Newbie
Posts: 3
Joined: 12 Oct 2013, 02:53

Re: Phoca Open Graph Titles

Post by teamtmedia »

Just wanted to add a little weight into this. I have the same issue as described here and I am experiencing another common issue as below.

I am also experiencing the og:title being scraped from a module that is showing a K2 item from a category. Even when I have a K2 item or category in the main component I am still experiencing this effect. Being that I have "inspirational" business quotes my title

"services for your business" is showing as og:title="Mahatma Gandhi" and whilst I believe that M Gandhi's quote about customer service is the most important business quote ever I would much rather the og:title is the first

Code: Select all

<h?>
tag in the main component.

Again my site is on localhost so there is no option to have you poke around but here are the key lines of code for you to examine. Please ask questions.

Code: Select all

<meta property="og:title" content="Pareto principle" />
  <meta property="og:type" content="article" />

<title>teamTmedia - teamTmedia services for your business</title>

<!-- Category title -->
			<h2>our services for your business</h2> (the correct place to take the og:title from)

<a class="moduleItemTitle" href="/teamtmedia/index.php/teamtmedia-services-for-business/67/pareto-principle">Pareto principle</a> (where it is being taken from)
I post this here as I view the option that micherts is discussing to be an acceptable workaround for now as I have effective titles set throughout my site.
micherts
Phoca Newbie
Phoca Newbie
Posts: 4
Joined: 05 Oct 2013, 11:12

Re: Phoca Open Graph Titles

Post by micherts »

Hi Jan, do you have any further update on this issue?

Many thanks
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48402
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Phoca Open Graph Titles

Post by Jan »

Hi, as written above, there is no dependency to html ouptut (there is no search for the title).

The title is get from content values (content includes information, one of them is title, such is then used for the title). But only in case it is not overwritten by options. The plugin does not decide which parameter will be set, it is set by Joomla! rules (which parameters overwrite other parameters). In the module it is only set that if title which is set in options (the ordering of overwriting is set by Joomla!) is empty, then the article title is used.

So maybe the solution can be following, to add the page name, try to edit the plugin an let me know.

FROM:

Code: Select all

if ($this->params->get('title'.$suffix, '') != '') {
	$document->setMetadata('og:title', htmlspecialchars($this->params->get('title'.$suffix, '')));
} else if ($row->title != '') {
	$document->setMetadata('og:title', htmlspecialchars($thisTitle));
}
TO:

Code: Select all

if ($this->params->get('page_heading') != '') {
	$document->setMetadata('og:title', htmlspecialchars($this->params->get('page_heading')));
} else if ($this->params->get('title'.$suffix, '') != '') {
	$document->setMetadata('og:title', htmlspecialchars($this->params->get('title'.$suffix, '')));
} else if ($row->title != '') {
	$document->setMetadata('og:title', htmlspecialchars($thisTitle));
}
Please test and let me know (for now I am not on my pc to test it so don't know if the page_heading is included in the plugin)

Jan
If you find Phoca extensions useful, please support the project
teamtmedia
Phoca Newbie
Phoca Newbie
Posts: 3
Joined: 12 Oct 2013, 02:53

Re: Phoca Open Graph Titles

Post by teamtmedia »

Thanks Jan

For me this is not working as a solution. I guess it is not getting the page-title to display (or I have the wrong settings in the plug-in).

Cheers

Justin
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48402
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Phoca Open Graph Titles

Post by Jan »

For now I don't have any other information about what needs to be set there. In the plugin, you get the information which is available in the content or information which is available from configuration site - In fact the plugin gets content data and there is no other way to get them from other place as plugin is the part of content :idea:
If you find Phoca extensions useful, please support the project
Post Reply