Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-02-02 21:36:29

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Get page title in admin theme PHP

Hi.

I’m building a new txp4 admin-side theme at the moment. Within the theme’s .php file is there a way I can pull in the title of the admin page currently being viewed? Kind of like…

<h1>{$pagetitle}</h1>

Thanks.

Offline

#2 2012-02-03 08:15:00

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: Get page title in admin theme PHP

Currently no.

Offline

#3 2012-02-03 08:28:43

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: Get page title in admin theme PHP

Damn. I think it would help useability if people knew what page they were on (without resorting to an indicator in the navigation). When running clients through textpattern over the phone it would make my life easier. Any chance it could be patched in?

Offline

#4 2012-02-03 08:33:12

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Get page title in admin theme PHP

As Robert says, you can’t get the page title as it’s only defined inside pagetop(). But you can get the name of the currently active tab by picking it from $this->menu array the same way as you would build a menu. Isn’t exactly the title, but as close it gets currently.

Last edited by Gocom (2012-02-03 08:35:29)

Offline

#5 2012-02-03 09:16:17

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: Get page title in admin theme PHP

Yes, I find this most helpful too. In the past I’ve only achieved this with a minor patch that grabs the page title (as it shows in the title bar). Two files need a very minor patch:

In txplib_head.php, a means of passing the value of the already existing $pagetitle to the admin theme. In the last couple of lines of function pagetop add the variable $pagetitle to the line beginning $theme->set_state...:

// MOD -pass $pagetitle variable to admin theme
		$theme->set_state($area, $event, $bm, $pagetitle, $message);
		echo pluggable_ui('admin_side', 'header', $theme->header());
		callback_event('admin_side', 'pagetop_end');

and in txplib_theme.php a corresponding pick-up point for the variable in the function set_state:

// MOD - accept pagetitle attribute
	function set_state($area, $event, $is_popup, $pagetitle, $message)
	{
		$this->is_popup = $is_popup;
// MOD - define pagetitle variable for use in themes
		$this->pagetitle = escape_title($pagetitle);
		$this->message = $message;

In your theme php file, you can then output the page title using the variable $this->pagetitle e.g.:

$out[] = n.'<h1 class="pagetitle">'.$this->pagetitle.'</h1>';

or similar.


TXP Builders – finely-crafted code, design and txp

Offline

#6 2012-02-03 09:27:35

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: Get page title in admin theme PHP

Cheers Jakob,

This is going to be a publicly available theme so I can’t resort to customising the core PHP files (though it’s good to know it’s possible). Could Robert build that functionality in for the 4.5.x release? My theme probably won’t be finished for another month or so anyway.

Offline

Board footer

Powered by FluxBB