PHP to show Category or File Title

Phoca Download - download manager
aran.gibbs
Phoca Newbie
Phoca Newbie
Posts: 9
Joined: 07 Mar 2017, 17:29

PHP to show Category or File Title

Post by aran.gibbs »

Hi Guys,

On the site I'm building I use some PHP to display H1 pages on article pages be cause we want them in a separate module to the actual article itself. The code we use is below and it works very well. I'd like to do something similar on phocadownload pages so the category title or file title appears in the separate custom module. I'll admit my php skills are very limited

Code used to display Joomla Article Title:

Code: Select all

<h1><?php 
$input = JFactory::getApplication()->input;
$id = $input->getInt('id'); //get the article ID
$article = JTable::getInstance('content');
$article->load($id);

echo $article->get('title'); // display the article title
?></h1>
What I'd like to see:

Code: Select all

<h1>Downloads: {phocodownload current category or page title}</h1>
Is there an equivalent piece of code that can be used to display the category or file title of the page I'm currently on. This will help the SEO by stopping us using a static title and having multiple duplicate H1 tags across the phocadownload pages.

See Example Screen Shot https://www.sos-webdesign.co.uk/title.png

Thanks,

Aran
christine
Phoca Hero
Phoca Hero
Posts: 2737
Joined: 28 Nov 2010, 17:20

Re: PHP to show Category or File Title

Post by christine »

Hi Aran,

sorry, I don't know. Hv to check something. Your screenshot I didn't see before.
Is it not possible e.g. under: Categories > your category > description > in the text-box: > <h1>my title</h1> ? Or maybe with an Override?
So, wait for Jan please :-)

Kind regards Christine
aran.gibbs
Phoca Newbie
Phoca Newbie
Posts: 9
Joined: 07 Mar 2017, 17:29

Re: PHP to show Category or File Title

Post by aran.gibbs »

Hi Christine,

I could put the H1 in the description for category or file but that would then not be consistent in look to the rest of the pages in the site all of which have the H1 in the grey box above the breadcrumbs. If Jan has a way to achieve what I'd like that would be fantastic, I'm sure with some PHP knowledge it must be possible but my skills in that area just aren't good enough.

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

Re: PHP to show Category or File Title

Post by Jan »

Hi, you can customize the category or file output here:

components/com_phocadownload/views/category/tmpl/default ... php
components/com_phocadownload/views/file/tmpl/default ... php

Or you can override these files by your template (with standard Joomla! override function)

Jan
If you find Phoca extensions useful, please support the project
aran.gibbs
Phoca Newbie
Phoca Newbie
Posts: 9
Joined: 07 Mar 2017, 17:29

Re: PHP to show Category or File Title

Post by aran.gibbs »

Hi Jan,

I know I can edit those files to change how the section looks but thats not what I'm trying to achieve.

I have a separate module on each page into which I would like to display the category or file name for the page I'm on so it is consistent with the look of the rest of the site. Can you give me the php code to insert into my module to look up & display the title of the phocadownload category or file I'm currently on?

For example from the files you suggested above I know the code to use the code to display the name of the category but I'm not sure how to get it to identify the category.

To display Category Title:

Code: Select all

echo '<h1>'.$this->category[0]->title. '</h1>';
To Display File Title:

Code: Select all

echo '<h1>'.$l->getName($v->title, $v->filename, 1). '</h1>';

Thanks,

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

Re: PHP to show Category or File Title

Post by Jan »

Hi, what you exactly mean with "I'm not sure how to get it to identify the category"?

Jan
If you find Phoca extensions useful, please support the project
aran.gibbs
Phoca Newbie
Phoca Newbie
Posts: 9
Joined: 07 Mar 2017, 17:29

Re: PHP to show Category or File Title

Post by aran.gibbs »

Hi Jan,

My php skills are very limited but in the other piece of php I use I believe the first section of the code identifies which article I'm looking at and the second half, the echo line displays the title of that article. So I assume to get the echo lines to work for phoca in the same way ie. display the title of the category or file there has to be a piece of php code that identifies which category oe file pages I'm currently on. I need to know what the piece of code is.

This is the code I use to identify the display the article name in my module, as you can see from the comments in it the first part gets the article ID and the second part shows the title:

Code: Select all

<h1><?php 
$input = JFactory::getApplication()->input;
$id = $input->getInt('id'); //get the article ID
$article = JTable::getInstance('content');
$article->load($id);

echo $article->get('title'); // display the article title
?></h1>
I tried amending the existing code I have to the code below but that just causes the page not to load:

Code: Select all

<?php 
$input = JFactory::getApplication()->input;
$id = $input->getInt('id'); //get the category ID
$category = JTable::getInstance('phocadownload_categories');
$category->load($id);

echo $category->get('title'); // display the category title
?>
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 47887
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: PHP to show Category or File Title

Post by Jan »

Hi, in Phoca Download, there are two ID types.
In Category view - the ID represents the category ID
In File view - the ID represents the file ID

So it depends on in which view you get the ID.

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