Page title in categories and files

Phoca Download - download manager
gray
Phoca Member
Phoca Member
Posts: 39
Joined: 03 Jul 2008, 13:30

Page title in categories and files

Post by gray »

I observed that page title in all PD v2.1.1 component is the same - menu title linked to PD. This is not good at all.
So, in
/components/com_phocadownload/views/file/view.html.php
if found this piece of code

Code: Select all

		$title = $this->params->get('page_title', '');
		if (empty($title)) {
			$title = htmlspecialchars_decode($app->getCfg('sitename'));
		} else if ($app->getCfg('sitename_pagetitles', 0)) {
			$title = JText::sprintf('JPAGETITLE', htmlspecialchars_decode($app->getCfg('sitename')), $title);
		}
		$this->document->setTitle($title);

		if (empty($title)) {
			$title = $this->item->title;
		}
		$this->document->setTitle($title);
First question I have, why $this->document->setTitle($title); is set 2 times. I simply disabled it the first line.

Second, I could not figure out the source of the title, and just set the second $this->document->setTitle($title); to

Code: Select all

$this->document->setTitle($file->title);
The same refers to category titles set in /components/com_phocadownload/views/category/view.html.php
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48610
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Page title in categories and files

Post by Jan »

Hi, the title can be set in menu link parameters.

$this->document->setTitle($title); 2x - will be fixed in next release.

Jan
If you find Phoca extensions useful, please support the project
gray
Phoca Member
Phoca Member
Posts: 39
Joined: 03 Jul 2008, 13:30

Re: Page title in categories and files

Post by gray »

I updated to PD 2.1.3, but the problem remains. I set page title in the menu manage - it shows on the browser's title. It's OK, but the issue is that it's the same for all pages.
Moreover, if I try to use this code (assume the title is empty)

Code: Select all

if (empty($title) || (isset($title) && $title == '')) {
  $title = $this->item->title;
}
I got error Notice: Undefined property: PhocaDownloadViewFile::$item, so $title = $this->item->title; is not working at all.

Finally I change the above piece of code to

Code: Select all

$title = $file->title . ' | ' . $category->title . ' | ' . $title;
This includes file's name first, then category title, and adds the menu title (or custom title set in menu's options).

The same I did with category view, simple replacing the if block with

Code: Select all

$title = $category->title . ' | ' . $title;
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48610
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Page title in categories and files

Post by Jan »

Hi, thank you for this info.

Jan
If you find Phoca extensions useful, please support the project
laita
Phoca Newbie
Phoca Newbie
Posts: 1
Joined: 18 Jan 2012, 12:43

Re: Page title in categories and files

Post by laita »

Hi, need your help with similar problem.
Is there something that can be done with PD 1.3.9 to change page title in the browser?
Post Reply