Page 1 of 1

Display Joomla Article Title The Full Page Width

Posted: Thu Jun 15, 2017 9:20 am
by websitedons
Sometimes you just want the title to span the page width instead of being locked into the component block and cut off by a side bar, for a variety of reasons.
spanned-title.png
To get it done requires title output in the template index.php since the element needs to exist outside the contained component element.

Add the following to the php coding at the top of the default template's index.php

Code: Select all

$app = JFactory::getApplication();
$post = JTable::getInstance('content');
$post->load( $app->input->getInt('id') );
In the <body> area, add the element where you desire

Code: Select all

<div class="pagetitle"><h1><?php echo $post->get('title'); ?></h1></div>
das it!

Re: Display Joomla Article Title The Full Page Width

Posted: Tue Sep 25, 2018 9:20 pm
by robwent
Thank you from the future!

I combined this with the checks for the type of page from protostar to get the article title if it's a single article, or get the menu title if it's 'something else...'

Code: Select all

// Detecting Active Variables
$option   = $app->input->getCmd( 'option', '' );
$view     = $app->input->getCmd( 'view', '' );
$layout   = $app->input->getCmd( 'layout', '' );
$task     = $app->input->getCmd( 'task', '' );
$itemid   = $app->input->getCmd( 'Itemid', '' );
$sitename = $app->get( 'sitename' );

$header_title = false;
if ($option === 'com_content' && $view === 'article' && $layout == '') {
    $header_title = true;
	// Getting the current page title
	$post = JTable::getInstance('content');
	$post->load( $app->input->getInt('id') );
	$header_title = $post->get('title');
} else {
    $menu_item = JFactory::getApplication()->getMenu()->getActive();
    if ($menu_item->type === "component") {
	    $header_title = $menu_item->title;
    }
}
Then later:

Code: Select all

<?php if ($header_title) : ?>
                <div class="col-10 col-md-11">
                    <h1><?php echo $header_title; ?></h1>
                </div>
	            <?php endif; ?>