Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

added loggedIn class to main tpl container #194

Merged
merged 5 commits into from

3 participants

@selfthinker
Collaborator

This is a feature, not a bug fix. And it's in a pull request because it's after feature freeze. But it would be great to have it in the next release anyway.

@selfthinker
Collaborator

I wonder if it makes sense to introduce something like WordPress's "body_class()", so maybe tpl_template_class()? To have the mode in there makes sense as well, but maybe not the sidebar classes (as some templates might not use them).

@splitbrain
Owner

I'd be fine with merging this, but yes, a Wordpress like class output function could be useful across different templates.

@selfthinker
Collaborator

I only planned to keep this quick and simple because I had hoped it would make it into the release. Now that it's after the release, I'm fine with adding an appropriate function instead.

@splitbrain
Owner

@selfthinker okay, we're waiting for your function

@Chris--S Chris--S merged commit 806bda3 into master
@Chris--S Chris--S deleted the loggedin-class branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
18 inc/template.php
@@ -1748,5 +1748,23 @@ function tpl_media() {
echo '</div>'.NL;
}
+/**
+ * Return useful layout classes
+ *
+ * @author Anika Henke <anika@selfthinker.org>
+ */
+function tpl_classes() {
+ global $ACT, $conf, $ID, $INFO;
+ $classes = array(
+ 'dokuwiki',
+ 'mode_'.$ACT,
+ 'tpl_'.$conf['template'],
+ $_SERVER['REMOTE_USER'] ? 'loggedIn' : '',
+ $INFO['exists'] ? '' : 'notFound',
+ ($ID == $conf['start']) ? 'home' : '',
+ );
+ return join(' ', $classes);
+}
+
//Setup VIM: ex: et ts=4 :
View
4 lib/tpl/dokuwiki/detail.php
@@ -28,8 +28,8 @@
<body>
<!--[if lte IE 7 ]><div id="IE7"><![endif]--><!--[if IE 8 ]><div id="IE8"><![endif]-->
- <div id="dokuwiki__site"><div id="dokuwiki__top"
- class="dokuwiki site mode_<?php echo $ACT ?>">
+ <div id="dokuwiki__site"><div id="dokuwiki__top" class="site <?php echo tpl_classes(); ?> <?php
+ echo ($showSidebar) ? 'showSidebar' : ''; ?> <?php echo ($hasSidebar) ? 'hasSidebar' : ''; ?>">
<?php include('tpl_header.php') ?>
View
5 lib/tpl/dokuwiki/main.php
@@ -27,9 +27,8 @@
<body>
<!--[if lte IE 7 ]><div id="IE7"><![endif]--><!--[if IE 8 ]><div id="IE8"><![endif]-->
- <div id="dokuwiki__site"><div id="dokuwiki__top"
- class="dokuwiki site mode_<?php echo $ACT ?> <?php echo ($showSidebar) ? 'showSidebar' : '';
- ?> <?php echo ($hasSidebar) ? 'hasSidebar' : ''; ?>">
+ <div id="dokuwiki__site"><div id="dokuwiki__top" class="site <?php echo tpl_classes(); ?> <?php
+ echo ($showSidebar) ? 'showSidebar' : ''; ?> <?php echo ($hasSidebar) ? 'hasSidebar' : ''; ?>">
<?php include('tpl_header.php') ?>
Something went wrong with that request. Please try again.