[solved] Is theming support incomplete? (admin.tpl)

cainlevy

Joined: 2005-09-21
Posts: 60
Posted: Mon, 2005-10-10 16:02

Edit: do yourself a favor ... skip my ranting, go down 10+ comments, and find the solution. :)

I've been working on my own theme for G2, and I'm basing it off of Matrix. You can see it in progress at http://www.cainlevy.net/gallery2.0/main.php. The theme.tpl, album.tpl, and photo.tpl pages were all easy enough. It looks like module.tpl is going to be a breeze, too. I've never used Smarty before, but I'm happy with how it's all going ... mostly.

The part where I scratch my head is with admin.tpl. How am I supposed to theme that? It looks to me like pages are being created from files in modules/core/templates/, which doesn't appear to be something I can theme. For instance, in my theme I found it necessary to add markup around the gsSidebar, but since modules/core/templates/SiteAdmin.tpl isn't part of a theme and since it creates its own (Matrix) version of gsSidebar, my Site Admin page looks broken.

I wouldn't even care so much about the Site Admin page, because it's not a publicly visible part of my G2. But then there's the Login page. It uses the core.UserAdmin template, which again creates its own (Matrix) version of gsSidebar. Not good.

Now it's quite possible that I'm simply underestimating themes, and it could be my own ignorance, but it looks to me like either the admin pages are not themable aside from header/footer, or the themes available for G2 (Matrix, Siriux, Classic, etc.) are all incomplete in that none of them show how to theme admin.tpl.

Either way, theming support strikes me as incomplete.

 
RwD
RwD's picture

Joined: 2005-01-09
Posts: 383
Posted: Mon, 2005-10-10 16:41

When theming you are changing css files, altering elements based on their element name, relative position inside the DOM tree or (more often) their class name(s) and ids. The admin part is done sperately indeed but there are still element names, class names and ids that you can grab onto.

I have this in my theme for example:

#adminContent #gsContent h2.giSuccess,
#adminContent #gsContent h2.giSuccess * {
	color: #3a1;
}

#adminContent #gsContent h2.giWarning,
#adminContent #gsContent h2.giWarning * {
	color: #12f;
}

#adminContent #gsContent h2.giError,
#adminContent #gsContent h2.giError * {
	color: #e31;
}

If you paste this into your css file and then in the admin part change anything you should notice the difference.

Theming support is complete, the admin part was deliberately set apart, perhaps to ensure there is a sidebar or whatever...
______________________
I made a theme for G2, try it :)

 
cainlevy

Joined: 2005-09-21
Posts: 60
Posted: Mon, 2005-10-10 17:17

Theming does allow for new css files. But the presence of Smarty templates in the theme folders means that you can also change class names, add ids, shift blocks around, and furthermore change the markup. The problem is that you can't also change the markup for admin pages (that I can see). And changing the markup is indeed what I need to do for my theme ... there's simply no way to do what I want with stylesheets alone.

So if you can't control the gsSidebar on the admin pages then no theme can be complete, because it can't control the same parts of every page on the site.

If the admin part was set aside deliberately to make sure there's a sidebar, that strikes me as a straightforward mistake. If you're giving someone the ability to make themes, you're already giving them the ability to break the website ... I can't see a good reason to single out one thing (the sidebar on the admin page) and make it less breakable than the rest. And again, the problem isn't just with the Site Admin page, it's also with the User Admin/Login page ... which does not need a sidebar at all.

I hope to make this theme available to other G2 users eventually, so I'd really like to do it right and not have to resort to "local/" versions of core templates to make my site visually consistent.

 
cainlevy

Joined: 2005-09-21
Posts: 60
Posted: Mon, 2005-10-10 21:39

I found another thread that raises the same problem from a different angle. It also has a workaround option:
http://gallery.menalto.com/node/33177

Looks like better theme support is on the way. :)

EDIT: Hmm, I read more, and it looks like the problem is actually different enough that the workaround isn't feasible in the current situation. What I'm looking for is one template that all admin pages would use, without having to copy and maintain every core template that uses a gsSidebar.

 
RwD
RwD's picture

Joined: 2005-01-09
Posts: 383
Posted: Mon, 2005-10-10 22:02

So basically you are saying that it is ok to get rid of the sidebar, making it *unpossible* to administer the website? Doesn't sound right to me.

In any case; the way your theme looks now is also doable with the admin part in it's current state... (or at least a very good resemblence can be reached)

In my theme I didn't even style the admin part that much; just the thingsthat didn't lok right yet. most automatically got the style from the rest of the website because of shared class names...
______________________
I made a theme for G2, try it :)

 
cainlevy

Joined: 2005-09-21
Posts: 60
Posted: Mon, 2005-10-10 22:26

How does the login page require a sidebar? It's in the same situation as the Site Admin page, as I mentioned earlier.

Oh, and how are you even supposed to get to the Site Admin page if your theme's template is broken at such a fundamental level that there're no SystemLinks? Maybe you have to hand-craft the links that'll get you to the Login page and the SiteAdmin page. At that point, why not hand-craft the link that'll get you to the part where you can change the theme back?

I do believe that once you give someone the power that already exists in templates, there's no reason to stop with the admin pages. Any site administrator that's worried about someone else's templates breaking something fundamental just shouldn't install that template at the root level.

Once I figure this bit out and polish up my theme a bit, I'd actually really appreciate any feedback or suggestions you might have. I apologize if I sound abrupt, I really am quite happy with Gallery, and would like to contribute my theme when I'm done as a token of my appreciation.

EDIT: Heh, if there were a setting to go into Edit mode immediately after posting, I'd probably use it. I just thought of some other already available ways to break a site with themes:
* you could put "body {display: none;}" in the stylesheet
* you could have the admin.tpl sheet not display anything
* you could add javascript that makes all links unclickable (in IE, you can do this with a runtime filter designed to make transparent PNGs work)
* probably more, but there's the idea ...

 
RwD
RwD's picture

Joined: 2005-01-09
Posts: 383
Posted: Tue, 2005-10-11 07:49
cainlevy wrote:
How does the login page require a sidebar? It's in the same situation as the Site Admin page, as I mentioned earlier.

It doesn't really

Quote:
Oh, and how are you even supposed to get to the Site Admin page if your theme's template is broken at such a fundamental level that there're no SystemLinks? Maybe you have to hand-craft the links that'll get you to the Login page and the SiteAdmin page. At that point, why not hand-craft the link that'll get you to the part where you can change the theme back?

That is even worse, but I think you van go to www.site.com/admin (not sure)

Quote:
I do believe that once you give someone the power that already exists in templates, there's no reason to stop with the admin pages. Any site administrator that's worried about someone else's templates breaking something fundamental just shouldn't install that template at the root level.

Are you suggesting to have every template include theming for every module?? I mean I can create any nr of modules that need to be administered using the admin pages, but should every theme do the html for this? How could they?

Quote:
Once I figure this bit out and polish up my theme a bit, I'd actually really appreciate any feedback or suggestions you might have. I apologize if I sound abrupt, I really am quite happy with Gallery, and would like to contribute my theme when I'm done as a token of my appreciation.

Sure, but I think things are still a bit cloudy for you as to why they made the admin part stylable the way they did. But it does make sense...

Quote:
EDIT: Heh, if there were a setting to go into Edit mode immediately after posting, I'd probably use it. I just thought of some other already available ways to break a site with themes:
* you could put "body {display: none;}" in the stylesheet
* you could have the admin.tpl sheet not display anything
* you could add javascript that makes all links unclickable (in IE, you can do this with a runtime filter designed to make transparent PNGs work)
* probably more, but there's the idea ...

I can also do a DOS-attack on your website so that even though your admin pages work you are not getting there. So what exactly is your point? There is always a way...

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-10-11 10:47

what exactly is the point of this discussion?

quoting myself from the linked topic http://gallery.menalto.com/node/33177 :

Quote:
Maybe the current concept won't work here, but sooner or later there will be the option to put override templates in the theme dir structure.

so you'll be able to have themes/mytheme/templates/core/AdminCore.tpl which automatically overrides modules/core/templates/AdminCore.tpl .

 
RwD
RwD's picture

Joined: 2005-01-09
Posts: 383
Posted: Tue, 2005-10-11 10:58

nice
______________________
I made a theme for G2, try it :)

 
cainlevy

Joined: 2005-09-21
Posts: 60
Posted: Tue, 2005-10-11 15:25

Valiant, I guess my original post had two purposes, and we got sidetracked by just one of them. I was originally wanting to know both how I could theme admin pages, and if I couldn't, why not. RwD responded with the argument that admin pages were not supposed to be stylable because, from what I could make of his argument, that would give too much power to a theme. So we spent probably too much time discussing whether it's even desirable to theme admin pages.

With the ability to add overrides, there's definitely a workaround for the admin theming. I do call it a workaround, though, since it doesn't seem consistent with the rest of the theming. No, RwD, I do not think that every theme should have to style every template for every module, although with overrides you'd be able to do that. But I don't see why the admin pages can't behave more like the other modules, where they register a number of blocks for the sidebar and provide the templater with everything that goes in the main area. That way admin.tpl could handle at least as much of the admin pages as it does of the module pages.

If you think this discussion is better taken somewhere else, Valiant, let me know. Or if you want to continue debating whether admin pages should even be themeable, RwD, maybe we could continue by email.

 
RwD
RwD's picture

Joined: 2005-01-09
Posts: 383
Posted: Wed, 2005-10-12 09:55

cainlevy,
I don't see any reason to continue elsewhere...

Perhaps it would be a better idea to have the admin.tpl provide control over the sidebar stuff since that is standardized anyway and have the main part include the specific templates like it is done right now anyway.

Then perhaps in the future the ability to override standard module templates and the themeing support is complete, is it not??
______________________
I made a theme for G2, try it :)

 
cainlevy

Joined: 2005-09-21
Posts: 60
Posted: Fri, 2005-10-14 03:59

Hey, sorry I disappeared for a bit.

With the ability to add overrides, theme support would definitely be complete. Easily complete. :)

But maybe not as good as it could be ... if you could just control the sidebar on admin pages, like you mentioned RwD, that'd even things up between admin and module pages, theme-wise.

 
allanh1

Joined: 2005-08-09
Posts: 6
Posted: Wed, 2005-10-26 06:07

I would really, really, really LOVE the ability to theme the admin areas.

At the moment, I am producing a template for my site that unifies all the different sections -- the store, the gallery and the blog and my template is a table-less layout that puts the content *first*. This means that I've been switching around where my sidebar is in my publicly-accessible areas so that the code for gsSidebar comes *after* gsContent which involves removing a lot of the table code.

So far it's worked really well and I'm really happy with the results -- except for now I have a messed up backend as it's squishing my entire sidebar and content area into one small area because I can't do anything with the admin templates.

I'm going to go and dig around and try to find a thread that explains why tables were used *at all* for this project :-) (I do sort of get it, but not really).

Anyhow, no real reason for posting this except to voice my suppport themeable admin areas.

GREAT WORK G2 TEAM !!! I LOVE G2!

 
RwD
RwD's picture

Joined: 2005-01-09
Posts: 383
Posted: Wed, 2005-10-26 06:49

allanh1,
Tables where used in two ways. First way is for table data, which is good. The second way was in the lay out, and for as far as I know this visually solved more problems then that it made new ones. Now the lay out doesn't break anymore. But if there was another reason to use tables I am sure one of the developers will mention it here.

You do have *some* control over the admin area specifically if you add a div around the admin-include part in admin.tpl having an id like adminContent. Now you can style the admin area in any way you want. Just because something is inside a table doesn't mean you cannot place it anywhere else on the page.

Consider this example:
In this example the red box is the left table cell and the blue box is the right one. However I used CSS to turn them around, and this works for both IE and FF.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">

<head>
	<title>Test</title>

	<style type="text/css">
		* {
			padding: 0;
			margin: 0;

			font-family: Verdana;
			font-size 11px;
		}

		#tableOne {
			border-collapse: collapse;
		}

		#tdRed {
			position: absolute;
			left: 200px;

			background-color: #f00;
			color: #fff;
			width: 200px;
		}

		#tdBlue {
			background-color: #00f;
			color: #fff;
			width: 200px;
		}
	</style>
</head>

<body>

<table id="tableOne">
	<tbody>
		<tr>
			<td id="tdRed">Some text here</td>
			<td id="tdBlue">Some text there</td>
		</tr>
	</tbody>
</table>

</body>

</html>

Now the admin table will give you some more CSS to make it work, but my initial idea about it is that it would be possible to do it.

What do you think of this?
______________________
I made a theme for G2, try it :)

 
cainlevy

Joined: 2005-09-21
Posts: 60
Posted: Wed, 2005-10-26 07:18

Ok, you know, this didn't turn out to be so hard.

Here's the Matrix admin.tpl adapted for admin theming:

{*
 * $Revision: 1.2 $
 * If you want to customize this file, do not edit it directly since future upgrades
 * may overwrite it.  Instead, copy it into a new directory called "local" and edit that
 * version.  Gallery will look for that file first and use it if it exists.
 *}
{if $theme.adminTemplate == 'modules/core/templates/UserAdmin.tpl'}
  I'm the UserAdmin template. Watch me dance.
{elseif $theme.adminTemplate == 'modules/core/templates/ItemAdmin.tpl'}
  I'm the ItemAdmin template. Hear me roar.
{elseif $theme.adminTemplate == 'modules/core/templates/SiteAdmin.tpl'}
  I'm the SiteAdmin template. Feel my biceps.
{else}
  {include file="gallery:`$theme.adminTemplate`" l10Domain=$theme.adminL10Domain}
{/if}

So ... ignore all my previous ranting. This doesn't let themes provide custom templates for modules, but at least admin pages are very doable. My apologies for not going beyond the provided themes to look for a solution. :|