Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
Re: Get page title in admin theme PHP
Currently no.
Offline
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
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
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
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