I can set meta descriptions and meta keywords as follows:

  $document = JFactory::getDocument();
  $document->setDescription("a meta description");
  $document->setMetaData('keywords', 'some,keywords');

Is there a similar way to set the page heading? By "page heading" I am referring to the "Page Heading" field in the menu item (see below) which usually (depending on the template you are using) results in a H1 heading at the top of the content.

enter image description here

  • Why do you actually need to have a way to set this, and what you have in mind when you want to set it - how do you plan to use it? After all, all this is, is a variable. If you are on your view/template file, you can simply create/call another variable.
    – FFrewin
    Nov 19, 2016 at 13:41
  • The page has a ChronoForm on it displaying records from the database. I'd like to improve SEO by setting the Page Heading to something unique and matching the record that is being displayed. Feb 9, 2017 at 22:23

3 Answers 3


you can set this variable as so:

$this->params->set('page_heading', "garr, I be a page heading");

Make sure you insert this code before the page_header is loaded, as setting it after it has loaded will mean it loads first, with the existing value, and then you set it after, but you have not told it to update. If you need to set it after, then you would need to call the page_heading again. I suspect loading it before the original call is better in most cases.

To understand where the page_header is loaded, look at the other answer to this question, which shows you how to load the page_header. For example on my blog page it is

echo $this->escape($this->params->get('page_heading'));


Joomla Dynamic page title

$document = JFactory::getDocument();

$document->setTitle('your title');      
  • Thanks @Josef, I need to set the page heading rather than the page title Sep 17, 2016 at 7:02
  • What do you mean exactly by "heading"? Is it the article title? Or do you mean the headers? Would it be possible to give an example?
    – itoctopus
    Sep 17, 2016 at 22:46
  • I am referring to the main (usually H1) heading on the page and have updated my question to make this clearer, thanks. Sep 18, 2016 at 23:38
  • The thing is, the document stuff usually sets meta data so far as I know. The page_heading is not meta data, it is a field within the page. Meta data would count as <meta description> <meta title> <meta keywords> so we need to do it in a different way which will not use $document
    – Eoin
    Nov 18, 2016 at 20:17

This is the standard code that you can find in joomla's core components (like com_content):

<?php if($this->params->get('show_page_heading')){ ?>
    <div class="page-header">
        <h1><?php echo $this->escape($this->params->get('page_heading')); ?></h1>
<?php } ?>
  • This is how you show the page heading, not how you set the page heading.
    – Eoin
    Nov 18, 2016 at 19:52
  • Sorry, I didn't mean to downvote you, I meant to retract my upvote. Good effort trying to help, that code is still pretty useful :)
    – Eoin
    Nov 18, 2016 at 20:15
  • Actually I've misread the question, so your downvote is well accepted! :)
    – Kitase88
    Nov 19, 2016 at 10:31
  • 1
    You're a gentleman AND a scholar :)
    – Eoin
    Nov 22, 2016 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.