Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-06-02 18:22:40

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Admin Theme : How to

Hello all,

I’m working on my first admin theme – and I’m in need of a small bit of PHP help.

Just beneath my navigation I’m looking for a way to output the name of the current sub-tab.

ie: <h1>Write</h1>

I’m a bit out of my depth, so any help would be much appreciated.

P.S. Devs, any plans on extending the pluggable_ui to the articles tab?


Tom

Offline

#2 2010-06-02 20:32:38

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,000
Website GitHub

Re: Admin Theme : How to

Hi Tom,

I wanted to do something similar a few months back and Stef showed me a way to do what you are asking, though it wasn’t quite what I was trying to do. In your theme php file where the menu is being generated, you need to check if the current tab is active and if so place its label into a string, e.g. the if ($item['active']) section in the middle of this snippet from remora:

				$out[] = '<ul>';
				foreach ($tab['items'] as $item)
				{
					$class = ($item['active']) ? 'tabup active' : 'tabdown2 inactive';
					if ($item['active']) {
						$current_page = $item['label'];
					}
					$out[] = "<li class='secondary {$class}'><a href='?event={$item['event']}'>{$item['label']}</a></li>";
				}
				$out[] = '</ul>';

and then you can output that variable, for example, if it is to be at the top of the pane, then place it beneath the messagepane:

		$out[] = '<div id="messagepane">'.$this->announce($this->message).'</div>';
		$out[] = '<h1>'.$current_page.'</h1>';

—————

FWIW I was trying to do almost exactly the same thing, except that I wanted to show $pagetitle (what you see in the page title tag / window bar) which is more informative than the tab label. I couldn’t find a way to do this without a (very simple) hack that passes $pagetitle to the theming functions:

In txplib_head.php add $pagetitle to set_state to pass it to make it available for theming (around line 182 just before pluggable_ui is echoed):

 $theme->set_state($area, $event, $bm, $pagetitle, $message);

In txplib_theme.php add $pagetitle to the corresponding set_state function and define it:

	function set_state($area, $event, $is_popup, $pagetitle, $message)
	{
		$this->is_popup = $is_popup;
		$this->message = $message;
		$this->pagetitle = escape_title($pagetitle);
		...

In your theme’s php file in function header, you just need to add $pagetitle to the line beginning global.

function header()
	{
		global $sitename,$txp_user,$pagetitle;
		...

and then you can use $pagetitle whereever you like:

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

And a sample of how it looks:

Maybe the Devs would entertain adding the ability to pass $pagetitle for theming.

Or: some clever person can show me another way to do the same…

Last edited by jakob (2010-06-02 20:38:13)


TXP Builders – finely-crafted code, design and txp

Offline

#3 2010-06-03 00:30:04

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: Admin Theme : How to

Jakob,

You are insanely helpful – as always. :)

You’re right $pagetitle would be great. For now you have helped me a ton as I’m trying to build admin themes that don’t require any hacking – although it’s really tempting. :)

On that note – have you had any luck creating a 2 column layout on the write tab using the pluggable_ui?
I’d like to implement some of the ideas I’ve been working on for the xpat theme
http://www.tomrenodesign.com/development/xpattern

Thanks again.
:)

Offline

#4 2010-06-03 07:25:27

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,000
Website GitHub

Re: Admin Theme : How to

You are insanely helpful

BTW: I found the source from which the above was extracted in one of Stef’s posts on a breadcrumb theme.

On that note – have you had any luck creating a 2 column layout on the write tab using the pluggable_ui?

Aside from using css to hide one column or jquery dom-relocation trickery after page render, when I last asked this was not yet possible but may be in future – see this thread topic.

http://www.tomrenodesign.com/development/xpattern

nice, I’d forgotten about that.


TXP Builders – finely-crafted code, design and txp

Offline

#5 2010-06-03 10:15:04

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

Re: Admin Theme : How to

renobird wrote:

P.S. Devs, any plans on extending the pluggable_ui to the articles tab?

Depends. What would you propose?

Last edited by wet (2010-06-03 10:15:17)

Online

#6 2010-06-03 11:30:09

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: Admin Theme : How to

Hi Wet,

I’d love to have to ability to make an interface switcher (via jquery tabs probably).
Maybe the current view could be “classic mode” so that any plugins that rely on that markup would still work correctly.

My goal would be to create a view of articles that is similar to what stm_article_order does.
Essentially a sortable list of articles by section. True – that can already be done (sort of) with a plugin – but I’m sure there are a lot of other options out there for creating an alternate view of articles.

Just my 2 cents. :)


Tom

Offline

#7 2010-06-11 00:42:08

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: Admin Theme : How to

Bump. Any thoughts on letting us get our grubby little mitts on the article tab?

Offline

#8 2010-06-11 15:51:49

JanDW
Plugin Author
From: Providence, RI, USA
Registered: 2008-07-18
Posts: 327
Website

Re: Admin Theme : How to

renobird wrote:

I’d like to implement some of the ideas I’ve been working on for the xpat theme
http://www.tomrenodesign.com/development/xpattern

A lot of nice fantastic stuff in that theme… if we could only get that in txp.

Last edited by JanDW (2010-06-11 15:58:05)


TXPDream – A Textpattern Tag Library for Adobe Dreamweaver. (updated for 4.2.0) | jdw_if_ajax – Only serve certain parts of a page when requested with AJAX

Offline

#9 2010-06-11 15:59:24

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: Admin Theme : How to

Thanks Jan,

I’m hard at work on a TXP theme that incorporates as much of that stuff as I can. It’s a bit of a “head to desk” process.


Tom

Offline

#10 2010-06-11 16:24:33

JanDW
Plugin Author
From: Providence, RI, USA
Registered: 2008-07-18
Posts: 327
Website

Re: Admin Theme : How to

Cool – Isn’t webdev usually about wanting to bludgeon your own skull? If you’d need a beta tester at some point, I’m up for it.


TXPDream – A Textpattern Tag Library for Adobe Dreamweaver. (updated for 4.2.0) | jdw_if_ajax – Only serve certain parts of a page when requested with AJAX

Offline

Board footer

Powered by FluxBB