Display Joomla Article Title The Full Page Width

For Joomla! 3.x Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Post Reply
User avatar
websitedons
I've been banned!
Posts: 389
Joined: Sat May 27, 2017 9:42 am

Display Joomla Article Title The Full Page Width

Post by websitedons » Thu Jun 15, 2017 9:20 am

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!
You do not have the required permissions to view the files attached to this post.

User avatar
robwent
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 113
Joined: Tue Jan 26, 2010 11:26 pm
Location: Loughborough, UK
Contact:

Re: Display Joomla Article Title The Full Page Width

Post by robwent » Tue Sep 25, 2018 9:20 pm

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; ?>


Post Reply

Return to “Joomla! 3.x Coding”