Lila: Ego, Rot: Active, Orange: Public, Gelb: Special
Design
Umsetzung
Vorträge
Schriftlich
Sonstiges
Gehalt verhandeln
Frauen ermutigen
GeekCode 4.0
Vortragstipps
Good presentations
Klausurtipps
Snippets
   
Home

Etomite-Snippets

Nach langer Recherche habe ich Etomite als meinen Liebling unter den PHP-basierten Open-Source Content Management Systemen gekürt. Unter anderem deshalb, weil es sich supereinfach mit eigenen kleinen Skripten, sogenannten "Snippets" erweitern lässt. Hier ist eine Liste der Snippets die ich im Laufe der Zeit geschrieben habe:

Glossary-List2

/* "Glossary-List2" by Corinna Habets - snippet@corinna-habets.de
* Created: 2006-07-05
*
* Usage: [[Glossary-List2?id=x]] or [[Glossary-List2]]
* The latter will assume that you want to list the
* children of the page that calls the snippet.
*
* Output:
* First all characters, that are leading characters of at least one entry;
* each is a link to the respective block
* (This is the main difference to "Glossary-List")
*
* Below that all entries in alphabetical order;
* Whenever the leading character changes it is displayed
* seperately (and has a named anchor).
*
* I created this snippet to work together with "InsertGlossar".
* See it in action on: http://corinna-habets.de/Glossar.html
*
* Based on "Glossary-List" by Nutter
*/

$characters = '';
$titles = '';

if (isset($id)) {
$thisid = $id;

} else if ($etomite->documentObject['isfolder']){
$thisid = $etomite->documentIdentifier;

} else {
return '';
}

$children = $etomite->getActiveChildren($thisid, 'pagetitle', 'ASC');
$childrenCount = count($children);

if($children==false) {
return '';
}

// What's the first character of the very first entry?
$curchar = strtoupper(substr($children[0]['pagetitle'], 0, 1));
if (!is_numeric($curchar)) {
$titles .= '<span class="gls_header">'.$curchar.'</span><a name="'.$curchar.'"></a><br />';
$characters .= '<a href="#'.$curchar.'">'.$curchar.'</a>';
} else {
$titles .= '<span class="gls_header">#</span>';
}

for($x=0; $x<$childrenCount; $x++) {
$firstchar = strtoupper(substr($children[$x]['pagetitle'], 0, 1));
if ($firstchar!=$curchar && !is_numeric($firstchar)) {
$curchar = $firstchar;
$characters .= ' | <a href="#'.$curchar.'">'.$curchar.'</a>';
$titles .= '<br /><span class="g_header">'.$curchar.'</span><a name="'.$curchar.'"></a><br />';
}
$titles .= '<a href="[~'.$children[$x]['id'].'~]">'.$children[$x]['pagetitle'].'</a><br />';
}

return "<p>$characters</p><p>$titles</p>";

InsertGlossary

/* "InsertGlossary" by Corinna Habets - snippet@corinna-habets.de
* Created: 2006-07-04
*
* The browser-rendered output of this snippet is just a word, but in
* the HTML is a <span>-construct, that will 'on hover' show a little box
* with additional text. The text to show comes from an extra page (of
* which you pass the ID).
* You NEED the following CSS to make the 'hover'-trick work (please cut + paste):

.glossar a {
color:#333333;
font-style:italic;
text-decoration:none;
}

.glossar a span{
display:none;
}

.glossar a:hover {
font-style:normal;
text-decoration:none;
}

.glossar a:hover span{
display:inline;
position:absolute;
background-color:#FFFFFF;
color:#222222;
font-size:0.7em;
border:1px solid #385b91;
width:18em;
padding:0.5em;
}

* The CSS is kindly provided by Tobias Baldauf - http://www.css-petals.net
*
* Usage: [[InsertGlossary?id=x&name=Output]] or [[InsertGlossary?id=x]]
* The ID specifies from which page to show the content on hover.
* With the first variant the hover-able output is whatever you give as
* 'name'. In the second variant the pagetitle is used instead.
*
* See this snippet in action on: http://corinna-habets.de/Leistungen.html
* Search for 'Webserver' (it's italic). Hover and enjoy :)
*
* (To also offer all glossary entries on one page I created "Glossary-List2".)
*/

if (!isset($id)) { // Is the necessary information given?
if(isset($name)) { // No, so we will return the name, if given
return $name;
}
return; // nothing was given, so we'll do nothing as well
}

// We got an id, so let's start:
$entry = $etomite->getDocument($id, $fields="*");

if (!isset($name)) { // If no name was given we take the entry title
$name = $entry['pagetitle'];
}

$output = '<span class="glossar"><a href="#">';
$output .= $name;
$output .= '<span>';

$output .= $entry['content'];

$output .= '</span></a></span>';

return $output;


Link2Validation

/* "Link2Validation" by Corinna Habets - snippet@corinna-habets.de
* Created: 2006-07-07
*
* This snippet adds a link to a W3C-Validation-Page (right now either
* CSS- or HTML-Validation) which passes the current page to the
* validation service.
*
* Usage: [[Link2Validation]]
*
* See it in action on: http://corinna-habets.de/
* At the bottom of each page
*
*/

// CONFIGURE
$baseURL = 'http://www.corinna-habets.de/'; // URL of your site

// Do you want HTML or CSS verification? Leave only one of the following two lines.
$validatorURL = '<a href="http://jigsaw.w3.org/css-validator/validator?uri='; //CSS
//$validatorURL = '<a href="http://validator.w3.org/check?uri='; //HTML

// What do you want as linked, visible output? (I show a small "Valid x"-Button, but it could just as well be text.)
$visible = '<img src="assets/images/buttons/css.png" alt="Valid CSS" width="80" height="15" />';

// SCRIPT
$id = $etomite->documentObject['id'];
$output ="";

$output .= $validatorURL.$baseURL;
$output .= "[~$id~]";
$output .= '">';

$output .= $visible;
$output .= '</a>';

return $output;

SectionPic

/* Snippet by Corinna Habets (pallas) - snippet@geekin.de
* 2006-02-03 - A modification of "SiteImage" (www.pemacviper.de)
*
* With this snippet you can insert a pic anywhere in your page. The
* picture will be set according to the caller's document-ID. The new turn
* is, that all pages will inherit the pic of their 'top-level-ancestor'. This
* way you can have section-wide pictures very easy. (With a 'section'
* being a top-level-page and all its children.)
*
* If no pic is specified for a top-level-page, there's still a default to fall back to.
*/

$id = $etomite->documentIdentifier;

// Get top-level-ancestor of current page
$pid = $etomite->documentObject['parent'];
while($pid) {
$id = $pid;
$parent=$etomite->getParent($pid);
$pid = $parent['parent'];
}

// Return specified picture
switch ($id) {

case 8: // The case is the document-id of the top-level-ancestor
$img = 'news';
break;

case 24:
$img = 'staff';
break;

case 23:
$img = 'teaching';
break;

case 22:
$img = 'publications';
break;

case 20:
$img = 'projects';
break;

case 19:
$img = 'research';
break;

case 18:
$img = 'jobs';
break;

case 16:
$img = 'contact';
break;

default:
$img = 'home';
//if no default-pic is desired, comment it out
}

return $img;



Letzte Aktualisierung: 20-Mar-2007 17:01






Home   Logbuch   Sitemap   Kontakt